MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / D_v_neg_1_2

Method D_v_neg_1_2

easygraph/classes/graph.py:263–277  ·  view source on GitHub ↗
(
        self,
    )

Source from the content-addressed store, hash-verified

261
262 @property
263 def D_v_neg_1_2(
264 self,
265 ):
266 import torch
267
268 r"""Return the nomalized diagnal matrix of vertex degree :math:`\mathbf{D}_v^{-\frac{1}{2}}` with ``torch.sparse_coo_tensor`` format. Size :math:`(|\mathcal{V}|, |\mathcal{V}|)`.
269 """
270 if self.cache.get("D_v_neg_1_2") is None:
271 _mat = self.D_v.clone()
272 _val = _mat._values() ** -0.5
273 _val[torch.isinf(_val)] = 0
274 self.cache["D_v_neg_1_2"] = torch.sparse_coo_tensor(
275 _mat._indices(), _val, _mat.size(), device=self.device
276 ).coalesce()
277 return self.cache["D_v_neg_1_2"]
278
279 @property
280 def node2index(self):

Callers

nothing calls this directly

Calls 2

cloneMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected