cugraph.analyzeClustering_modularity#

cugraph.analyzeClustering_modularity(G, n_clusters, clustering, vertex_col_name='vertex', cluster_col_name='cluster')[source]#

Compute the modularity score for a given partitioning/clustering. The assumption is that “clustering” is the results from a call from a special clustering algorithm and contains columns named “vertex” and “cluster”.

Parameters:
Gcugraph.Graph or networkx.Graph

graph descriptor. This graph should have edge weights.

n_clustersinteger

Specifies the number of clusters in the given clustering

clusteringcudf.DataFrame

The cluster assignment to analyze.

vertex_col_namestr or list of str, optional (default=’vertex’)

The names of the column in the clustering dataframe identifying the external vertex id

cluster_col_namestr, optional (default=’cluster’)

The name of the column in the clustering dataframe identifying the cluster id

Returns:
scorefloat

The computed modularity score

Examples

>>> from cugraph.datasets import karate
>>> G = karate.get_graph(download=True)
>>> df = cugraph.spectralBalancedCutClustering(G, 5)
>>> score = cugraph.analyzeClustering_modularity(G, 5, df)