@not_implemented_for('directed')
@not_implemented_for('multigraph')
def communicability(G):
 import numpy
 import scipy.linalg
 nodelist = list(G)
 A = nx.to_numpy_matrix(G, nodelist)
 A[(A != 0.0)] = 1
 (w, vec) = numpy.linalg.eigh(A)
 expw = numpy.exp(w)
 mapping = dict(zip(nodelist, range(len(nodelist))))
 c = {}
 for u in G:
  c[u] = {}
  for v in G:
   s = 0
   p = mapping[u]
   q = mapping[v]
   for j in range(len(nodelist)):
    s += ((vec[:, j][(p, 0)] * vec[:, j][(q, 0)]) * expw[j])
   c[u][v] = float(s)
 return c

@ not_implemented_for ( 'directed' ) @ not_implemented_for ( 'multigraph' ) def communicability ( G ) : import numpy import scipy . linalg nodelist = list ( G ) A = nx . to_numpy_matrix ( G , nodelist ) A [ ( A != 0.0 ) ] = 1 ( w , vec ) = numpy . linalg . eigh ( A ) expw = numpy . exp ( w ) mapping = dict ( zip ( nodelist , range ( len ( nodelist ) ) ) ) c = { } for u in G : c [ u ] = { } for v in G : s = 0 p = mapping [ u ] q = mapping [ v ] for j in range ( len ( nodelist ) ) : s += ( ( vec [ : , j ] [ ( p , 0 ) ] * vec [ : , j ] [ ( q , 0 ) ] ) * expw [ j ] ) c [ u ] [ v ] = float ( s ) return c
return communicability between all pairs of nodes in g .