In [9]:
import numpy as np
import networkx as nx

In [2]:
G = nx.karate_club_graph()

In [3]:
L = nx.laplacian_matrix(G)

In [4]:
L


Out[4]:
<34x34 sparse matrix of type '<type 'numpy.int64'>'
	with 190 stored elements in Compressed Sparse Row format>

In [11]:
d = np.array([v for k,v in nx.degree(G).items()])

In [12]:
d


Out[12]:
array([16,  9, 10,  6,  3,  4,  4,  4,  5,  2,  3,  1,  2,  5,  2,  2,  2,
        2,  2,  3,  2,  2,  2,  5,  3,  3,  2,  4,  3,  4,  4,  6, 12, 17])

In [14]:
L.dot(d)


Out[14]:
array([187,  29,  34, -10, -14,  -9,  -9, -25, -34, -23, -14, -15, -18,
       -33, -25, -25,  -4, -21, -25, -33, -25, -21, -25, -15,  -4,  -5,
       -17, -19, -24, -20, -27, -18,  83, 224])

In [16]:
e = np.array([v for k,v in nx.betweenness_centrality(G).items()])

In [17]:
L.dot(e)


Out[17]:
array([ 6.45888348, -0.20052158,  0.66107353, -0.60963654, -0.46636003,
       -0.34830447, -0.34830447, -0.64713805, -0.76539202, -0.44603626,
       -0.46636003, -0.43763528, -0.44954455, -0.72189604, -0.44932209,
       -0.44932209, -0.05997475, -0.49157197, -0.44932209, -0.6982218 ,
       -0.44932209, -0.49157197, -0.44932209, -0.39034993, -0.15782077,
       -0.14657738, -0.30699705, -0.3782212 , -0.5806232 , -0.45524741,
       -0.5015377 , -0.06514851,  1.06608345,  4.69156295])

In [ ]: