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

Function compute_ppr

GCL/augmentors/functional.py:227–246  ·  view source on GitHub ↗
(edge_index, edge_weight=None, alpha=0.2, eps=0.1, ignore_edge_attr=True, add_self_loop=True)

Source from the content-addressed store, hash-verified

225
226
227def compute_ppr(edge_index, edge_weight=None, alpha=0.2, eps=0.1, ignore_edge_attr=True, add_self_loop=True):
228 N = edge_index.max().item() + 1
229 if ignore_edge_attr or edge_weight is None:
230 edge_weight = torch.ones(
231 edge_index.size(1), device=edge_index.device)
232 if add_self_loop:
233 edge_index, edge_weight = add_self_loops(
234 edge_index, edge_weight, fill_value=1, num_nodes=N)
235 edge_index, edge_weight = coalesce(edge_index, edge_weight, N, N)
236 edge_index, edge_weight = coalesce(edge_index, edge_weight, N, N)
237 edge_index, edge_weight = GDC().transition_matrix(
238 edge_index, edge_weight, N, normalization='sym')
239 diff_mat = GDC().diffusion_matrix_exact(
240 edge_index, edge_weight, N, method='ppr', alpha=alpha)
241 edge_index, edge_weight = GDC().sparsify_dense(diff_mat, method='threshold', eps=eps)
242 edge_index, edge_weight = coalesce(edge_index, edge_weight, N, N)
243 edge_index, edge_weight = GDC().transition_matrix(
244 edge_index, edge_weight, N, normalization='sym')
245
246 return edge_index, edge_weight
247
248
249def get_sparse_adj(edge_index: torch.LongTensor, edge_weight: torch.FloatTensor = None,

Callers 1

augmentMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected