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

Method D_v_neg_1_of_group

easygraph/classes/hypergraph.py:878–894  ·  view source on GitHub ↗

r"""Return the vertex degree matrix :math:`\mathbf{D}_v^{-1}` of the specified hyperedge group with ``torch.sparse_coo_tensor`` format. Args: ``group_name`` (``str``): The name of the specified hyperedge group.

(self, group_name: str)

Source from the content-addressed store, hash-verified

876 return self.cache["D_v_neg_1"]
877
878 def D_v_neg_1_of_group(self, group_name: str) -> torch.Tensor:
879 r"""Return the vertex degree matrix :math:`\mathbf{D}_v^{-1}` of the specified hyperedge group with ``torch.sparse_coo_tensor`` format.
880
881 Args:
882 ``group_name`` (``str``): The name of the specified hyperedge group.
883 """
884 assert (
885 group_name in self.group_names
886 ), f"The specified {group_name} is not in existing hyperedge groups."
887 if self.group_cache[group_name].get("D_v_neg_1") is None:
888 _mat = self.D_v_of_group(group_name).clone()
889 _val = _mat._values() ** -1
890 _val[torch.isinf(_val)] = 0
891 self.group_cache[group_name]["D_v_neg_1"] = torch.sparse_coo_tensor(
892 _mat._indices(), _val, _mat.size(), device=self.device
893 ).coalesce()
894 return self.group_cache[group_name]["D_v_neg_1"]
895
896 @property
897 def D_v_neg_1_2(self) -> torch.Tensor:

Callers 2

L_rw_of_groupMethod · 0.95
test_D_neg_groupFunction · 0.80

Calls 3

D_v_of_groupMethod · 0.95
cloneMethod · 0.45
sizeMethod · 0.45

Tested by 1

test_D_neg_groupFunction · 0.64