code: def clustering_coef_bu(G):
      '''
      The clustering coefficient is the fraction of triangles around a node
      (equiv. the fraction of nodes neighbors that are neighbors of each other).
  
      Parameters
      ----------
      A : NxN np.ndarray
          binary undirected connection matrix
  
      Returns
      -------
      C : Nx1 np.ndarray
          clustering coefficient vector
      '''
      n = len(G)
      C = np.zeros((n,))
  
      for u in range(n):
          V, = np.where(G[u, :])
          k = len(V)
          if k >= 2:  # degree must be at least 2
              S = G[np.ix_(V, V)]
              C[u] = np.sum(S) / (k * k - k)
  
      return f clustering_coef_bu(G):
      '''
      The clustering coefficient is the fraction of triangles around a node
      (equiv. the fraction of nodes neighbors that are neighbors of each other).
  
      Parameters
      ----------
      A : NxN np.ndarray
          binary undirected connection matrix
  
      Returns
      -------
      C : Nx1 np.ndarray
          clustering coefficient vector
      '''
      n = len(G)
      C = np.zeros((n,))
  
      for u in range(n):
          V, = np.where(G[u, :])
          k = len(V)
          if k >= 2:  # degree must be at least 2
              S = G[np.ix_(V, V)]
              C[u] = np.sum(S) / (k * k - k)
  
      return C
docs: The clustering coefficient is the fraction of triangles around a node
      (equiv. the fraction of nodes neighbors that are neighbors of each other).
  
      Parameters
      ----------
      A : NxN np.ndarray
          binary undirected connection matrix
  
      Returns
      -------
      C : Nx1 np.ndarray
          clustering coefficient vector