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

Method L_sym_of_group

easygraph/classes/hypergraph.py:1094–1119  ·  view source on GitHub ↗

r"""Return the symmetric Laplacian matrix :math:`\mathcal{L}_{sym}` of the specified hyperedge group with ``torch.sparse_coo_tensor`` format. .. math:: \mathcal{L}_{sym} = \mathbf{I} - \mathbf{D}_v^{-\frac{1}{2}} \mathbf{H} \mathbf{W}_e \mathbf{D}_e^{-1} \mathbf{H}^\top \mathbf{

(self, group_name: str)

Source from the content-addressed store, hash-verified

1092 return self.cache["L_sym"]
1093
1094 def L_sym_of_group(self, group_name: str) -> torch.Tensor:
1095 r"""Return the symmetric Laplacian matrix :math:`\mathcal{L}_{sym}` of the specified hyperedge group with ``torch.sparse_coo_tensor`` format.
1096
1097 .. math::
1098 \mathcal{L}_{sym} = \mathbf{I} - \mathbf{D}_v^{-\frac{1}{2}} \mathbf{H} \mathbf{W}_e \mathbf{D}_e^{-1} \mathbf{H}^\top \mathbf{D}_v^{-\frac{1}{2}}
1099
1100 Args:
1101 ``group_name`` (``str``): The name of the specified hyperedge group.
1102 """
1103 assert (
1104 group_name in self.group_names
1105 ), f"The specified {group_name} is not in existing hyperedge groups."
1106 if self.group_cache[group_name].get("L_sym") is None:
1107 L_HGNN = self.L_HGNN_of_group(group_name).clone()
1108 self.group_cache[group_name]["L_sym"] = torch.sparse_coo_tensor(
1109 torch.hstack(
1110 [
1111 torch.arange(0, self.num_v).view(1, -1).repeat(2, 1),
1112 L_HGNN._indices(),
1113 ]
1114 ),
1115 torch.hstack([torch.ones(self.num_v), -L_HGNN._values()]),
1116 torch.Size([self.num_v, self.num_v]),
1117 device=self.device,
1118 ).coalesce()
1119 return self.group_cache[group_name]["L_sym"]
1120
1121 @property
1122 def L_rw(self) -> torch.Tensor:

Callers 1

test_L_sym_groupFunction · 0.80

Calls 2

L_HGNN_of_groupMethod · 0.95
cloneMethod · 0.45

Tested by 1

test_L_sym_groupFunction · 0.64