MCPcopy Index your code
hub / github.com/PyGCL/PyGCL / get_eigenvector_weights

Function get_eigenvector_weights

GCL/augmentors/functional.py:134–149  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

132
133
134def get_eigenvector_weights(data):
135 def _eigenvector_centrality(data):
136 graph = to_networkx(data)
137 x = nx.eigenvector_centrality_numpy(graph)
138 x = [x[i] for i in range(data.num_nodes)]
139 return torch.tensor(x, dtype=torch.float32).to(data.edge_index.device)
140
141 evc = _eigenvector_centrality(data)
142 scaled_evc = evc.where(evc > 0, torch.zeros_like(evc))
143 scaled_evc = scaled_evc + 1e-8
144 s = scaled_evc.log()
145
146 edge_index = data.edge_index
147 s_row, s_col = s[edge_index[0]], s[edge_index[1]]
148
149 return normalize(s_col), evc
150
151
152def get_degree_weights(data):

Callers

nothing calls this directly

Calls 2

normalizeFunction · 0.90
_eigenvector_centralityFunction · 0.85

Tested by

no test coverage detected