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

Method D_v

easygraph/classes/graph.py:315–328  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

313
314 @property
315 def D_v(self):
316 import torch
317
318 r"""Return the diagnal matrix of vertex degree :math:`\mathbf{D}_v` with ``torch.sparse_coo_tensor`` format. Size :math:`(|\mathcal{V}|, |\mathcal{V}|)`.
319 """
320 if self.cache.get("D_v") is None:
321 _tmp = torch.sparse.sum(self.A, dim=1).to_dense().clone().view(-1)
322 self.cache["D_v"] = torch.sparse_coo_tensor(
323 torch.arange(0, len(self.nodes)).view(1, -1).repeat(2, 1),
324 _tmp,
325 torch.Size([len(self.nodes), len(self.nodes)]),
326 device=self.device,
327 ).coalesce()
328 return self.cache["D_v"]
329
330 def add_extra_selfloop(self):
331 r"""Add extra selfloops to the graph."""

Callers

nothing calls this directly

Calls 1

cloneMethod · 0.45

Tested by

no test coverage detected