MCPcopy Create free account
hub / github.com/PyGCL/PyGCL / _compute_pagerank

Function _compute_pagerank

GCL/augmentors/functional.py:162–173  ·  view source on GitHub ↗
(edge_index, damp: float = 0.85, k: int = 10)

Source from the content-addressed store, hash-verified

160
161def get_pagerank_weights(data, aggr: str = 'sink', k: int = 10):
162 def _compute_pagerank(edge_index, damp: float = 0.85, k: int = 10):
163 num_nodes = edge_index.max().item() + 1
164 deg_out = degree(edge_index[0])
165 x = torch.ones((num_nodes,)).to(edge_index.device).to(torch.float32)
166
167 for i in range(k):
168 edge_msg = x[edge_index[0]] / deg_out[edge_index[0]]
169 agg_msg = scatter(edge_msg, edge_index[1], reduce='sum')
170
171 x = (1 - damp) * x + damp * agg_msg
172
173 return x
174
175 pv = _compute_pagerank(data.edge_index, k=k)
176 pv_row = pv[data.edge_index[0]].to(torch.float32)

Callers 1

get_pagerank_weightsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected