@not_implemented_for('directed')
@not_implemented_for('multigraph')
def subgraph_centrality(G):
 import numpy
 import numpy.linalg
 nodelist = list(G)
 A = nx.to_numpy_matrix(G, nodelist)
 A[(A != 0.0)] = 1
 (w, v) = numpy.linalg.eigh(A.A)
 vsquare = (numpy.array(v) ** 2)
 expw = numpy.exp(w)
 xg = numpy.dot(vsquare, expw)
 sc = dict(zip(nodelist, map(float, xg)))
 return sc

@ not_implemented_for ( 'directed' ) @ not_implemented_for ( 'multigraph' ) def subgraph_centrality ( G ) : import numpy import numpy . linalg nodelist = list ( G ) A = nx . to_numpy_matrix ( G , nodelist ) A [ ( A != 0.0 ) ] = 1 ( w , v ) = numpy . linalg . eigh ( A . A ) vsquare = ( numpy . array ( v ) ** 2 ) expw = numpy . exp ( w ) xg = numpy . dot ( vsquare , expw ) sc = dict ( zip ( nodelist , map ( float , xg ) ) ) return sc
return subgraph centrality for each node in g .