code: def analyzeClustering_modularity(
      G,
      n_clusters,
      clustering,
      vertex_col_name="vertex",
      cluster_col_name="cluster",
  ):
      """
      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
      ----------
      G : cugraph.Graph or networkx.Graph
          graph descriptor. This graph should have edge weights.
  
      n_clusters : integer
          Specifies the number of clusters in the given clustering
  
      clustering : cudf.DataFrame
          The cluster assignment to analyze.
  
      vertex_col_name : str or list of str, optional (default='vertex')
          The names of the column in the clustering dataframe identifying
          the external vertex id
  
      cluster_col_name : str, optional (default='cluster')
          The name of the column in the clustering dataframe identifying
          the cluster id
  
      Returns
      -------
      score : float
          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)
  
      """
      if type(vertex_col_name) is list:
          if not all(isinstance(name, str) for name in vertex_col_name):
              raise Exception("vertex_col_name must be list of string")
      elif type(vertex_col_name) is not str:
          raise Exception("vertex_col_name must be a string")
  
      if type(cluster_col_name) is not str:
          raise Exception("cluster_col_name must be a string")
  
      G, isNx = ensure_cugraph_obj_for_nx(G)
      if (
          G.edgelist.edgelist_df.dtypes[0] != np.int32
          or G.edgelist.edgelist_df.dtypes[1] != np.int32
      ):
          raise ValueError(
              "'analyzeClustering_modularity' requires the input graph's "
              "vertex to be of type 'int32'"
          )
  
      if G.renumbered:
          clustering = G.add_internal_vertex_id(
              clustering, "vertex", vertex_col_name, drop=True
          )
  
      if (
          clustering.dtypes[0] != np.int32
          or clustering.dtypes[1] != np.int32
      ):
          raise ValueError(
              "'analyzeClustering_modularity' requires both the clustering 'vertex' "
              "and 'cluster' to be of type 'int32'"
          )
  
      score = pylibcugraph_analyze_clustering_modularity(
          ResourceHandle(),
          G._plc_graph,
          n_clusters,
          clustering["vertex"],
          clustering[cluster_col_name],
      )
  
      return score
  
file_path: cugraph/python/cugraph/cugraph/community/spectral_clustering.py
imports: from cugraph.utilities import ensure_cugraph_obj_for_nx, df_score_to_dictionary
  from pylibcugraph import balanced_cut_clustering, spectral_modularity_maximization, analyze_clustering_modularity, analyze_clustering_edge_cut, analyze_clustering_ratio_cut
  from pylibcugraph import ResourceHandle
  import cudf
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: analyzeClustering_modularity(G, n_clusters, clustering, vertex_col_name, cluster_col_name) and returns: score