def modularity_spectrum(G):
 from scipy.linalg import eigvals
 if G.is_directed():
  return eigvals(nx.directed_modularity_matrix(G))
 else:
  return eigvals(nx.modularity_matrix(G))

def modularity_spectrum ( G ) : from scipy . linalg import eigvals if G . is_directed ( ) : return eigvals ( nx . directed_modularity_matrix ( G ) ) else : return eigvals ( nx . modularity_matrix ( G ) )
return eigenvalues of the modularity matrix of g .