from torch_cluster import graclus_cluster
[docs]def graclus(edge_index, weight=None, num_nodes=None):
r"""A greedy clustering algorithm from the `"Weighted Graph Cuts without
Eigenvectors: A Multilevel Approach" <http://www.cs.utexas.edu/users/
inderjit/public_papers/multilevel_pami.pdf>`_ paper of picking an unmarked
vertex and matching it with one of its unmarked neighbors (that maximizes
its edge weight).
The GPU algoithm is adapted from the `"A GPU Algorithm for Greedy Graph
edge_index (LongTensor): The edge indices.
weight (Tensor, optional): One-dimensional edge weights.
num_nodes (int, optional): The number of nodes, *i.e.*
:obj:`max_val + 1` of :attr:`edge_index`. (default: :obj:`None`)
row, col = edge_index
return graclus_cluster(row, col, weight, num_nodes)