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

Method D_e_of_group

easygraph/classes/hypergraph.py:945–968  ·  view source on GitHub ↗

r"""Return the hyperedge degree matrix :math:`\mathbf{D}_e` 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

943 return self.cache["D_e"]
944
945 def D_e_of_group(self, group_name: str) -> torch.Tensor:
946 r"""Return the hyperedge degree matrix :math:`\mathbf{D}_e` of the specified hyperedge group with ``torch.sparse_coo_tensor`` format.
947
948 Args:
949 ``group_name`` (``str``): The name of the specified hyperedge group.
950 """
951 assert (
952 group_name in self.group_names
953 ), f"The specified {group_name} is not in existing hyperedge groups."
954 if self.group_cache[group_name].get("D_e") is None:
955 _tmp = (
956 torch.sparse.sum(self.H_T_of_group(group_name), dim=1)
957 .to_dense()
958 .clone()
959 .view(-1)
960 )
961 _num_e = _tmp.size(0)
962 self.group_cache[group_name]["D_e"] = torch.sparse_coo_tensor(
963 torch.arange(0, _num_e).view(1, -1).repeat(2, 1),
964 _tmp,
965 torch.Size([_num_e, _num_e]),
966 device=self.device,
967 ).coalesce()
968 return self.group_cache[group_name]["D_e"]
969
970 @property
971 def D_e_neg_1(self) -> torch.Tensor:

Callers 4

deg_e_of_groupMethod · 0.95
D_eMethod · 0.95
D_e_neg_1_of_groupMethod · 0.95
test_D_groupFunction · 0.80

Calls 3

H_T_of_groupMethod · 0.95
cloneMethod · 0.45
sizeMethod · 0.45

Tested by 1

test_D_groupFunction · 0.64