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

Method L_rw_of_group

easygraph/classes/hypergraph.py:1149–1190  ·  view source on GitHub ↗

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

(self, group_name: str)

Source from the content-addressed store, hash-verified

1147 return self.cache["L_rw"]
1148
1149 def L_rw_of_group(self, group_name: str) -> torch.Tensor:
1150 r"""Return the random walk Laplacian matrix :math:`\mathcal{L}_{rw}` of the specified hyperedge group with ``torch.sparse_coo_tensor`` format.
1151
1152 .. math::
1153 \mathcal{L}_{rw} = \mathbf{I} - \mathbf{D}_v^{-1} \mathbf{H} \mathbf{W}_e \mathbf{D}_e^{-1} \mathbf{H}^\top
1154
1155 Args:
1156 ``group_name`` (``str``): The name of the specified hyperedge group.
1157 """
1158 assert (
1159 group_name in self.group_names
1160 ), f"The specified {group_name} is not in existing hyperedge groups."
1161 if self.group_cache[group_name].get("L_rw") is None:
1162 _tmp = (
1163 self.D_v_neg_1_of_group(group_name)
1164 .mm(self.H_of_group(group_name))
1165 .mm(
1166 self.W_e_of_group(group_name),
1167 )
1168 .mm(
1169 self.D_e_neg_1_of_group(group_name),
1170 )
1171 .mm(
1172 self.H_T_of_group(group_name),
1173 )
1174 )
1175 self.group_cache[group_name]["L_rw"] = (
1176 torch.sparse_coo_tensor(
1177 torch.hstack(
1178 [
1179 torch.arange(0, self.num_v).view(1, -1).repeat(2, 1),
1180 _tmp._indices(),
1181 ]
1182 ),
1183 torch.hstack([torch.ones(self.num_v), -_tmp._values()]),
1184 torch.Size([self.num_v, self.num_v]),
1185 device=self.device,
1186 )
1187 .coalesce()
1188 .clone()
1189 )
1190 return self.group_cache[group_name]["L_rw"]
1191
1192 ## HGNN Laplacian smoothing
1193 @property

Callers 1

test_L_rw_groupFunction · 0.80

Calls 6

D_v_neg_1_of_groupMethod · 0.95
H_of_groupMethod · 0.95
W_e_of_groupMethod · 0.95
D_e_neg_1_of_groupMethod · 0.95
H_T_of_groupMethod · 0.95
cloneMethod · 0.45

Tested by 1

test_L_rw_groupFunction · 0.64