pylibcugraph.spectral_modularity_maximization#

pylibcugraph.spectral_modularity_maximization(
ResourceHandle resource_handle,
_GPUGraph graph,
num_clusters,
num_eigen_vects,
evs_tolerance,
evs_max_iter,
kmean_tolerance,
kmean_max_iter,
bool_t do_expensive_check,
random_state=None,
)[source]#

Compute a clustering/partitioning of the given graph using the spectral modularity maximization method.

Parameters:
resource_handleResourceHandle

Handle to the underlying device resources needed for referencing data and running algorithms.

graphSGGraph

The input graph.

num_clusterssize_t

Specifies the number of clusters to find, must be greater than 1

num_eigen_vectssize_t

Specifies the number of eigenvectors to use. Must be lower or equal to num_clusters.

evs_tolerance: double

Specifies the tolerance to use in the eigensolver.

evs_max_iter: size_t

Specifies the maximum number of iterations for the eigensolver.

kmean_tolerance: double

Specifies the tolerance to use in the k-means solver.

kmean_max_iter: size_t

Specifies the maximum number of iterations for the k-means solver.

do_expensive_checkbool_t

If True, performs more extensive tests on the inputs to ensure validitity, at the expense of increased run time.

random_state: int (Optional)

Random state to use when generating samples. Optional argument, defaults to a hash of process id, time, and hostname. (See pylibcugraph.random.CuGraphRandomState)

Returns:
A tuple containing the clustering vertices, clusters

Examples

>>> import pylibcugraph, cupy, numpy
>>> srcs = cupy.asarray([0, 1, 2], dtype=numpy.int32)
>>> dsts = cupy.asarray([1, 2, 0], dtype=numpy.int32)
>>> weights = cupy.asarray([1.0, 1.0, 1.0], dtype=numpy.float32)
>>> resource_handle = pylibcugraph.ResourceHandle()
>>> graph_props = pylibcugraph.GraphProperties(
...     is_symmetric=True, is_multigraph=False)
>>> G = pylibcugraph.SGGraph(
...     resource_handle, graph_props, srcs, dsts, weight_array=weights,
...     store_transposed=True, renumber=False, do_expensive_check=False)
>>> (vertices, clusters) = pylibcugraph.spectral_modularity_maximization(
...     resource_handle, G, num_clusters=5, num_eigen_vects=2, evs_tolerance=0.00001
...     evs_max_iter=100, kmean_tolerance=0.00001, kmean_max_iter=100)
# FIXME: Fix docstring result.
>>> vertices
############
>>> clusters
############