150 8 Network Analysis
In [8]:
Out[8]: Facebook betweenness centrality: [(u’107’, 0.4805180785560141), (u’1684’,
0.33779744973019843), (u’3437’, 0.23611535735892616),
(u’1912’, 0.2292953395868727), (u’1085’, 0.1490150921166526),
(u’0’, 0.1463059214744276), (u’698’, 0.11533045020560861),
(u’567’, 0.09631033121856114), (u’58’, 0.08436020590796521),
(u’428’, 0.06430906239323908)]
Out[8]: Facebook closeness centrality: [(u’107’, 0.45969945355191255), (u’58’, 0.3974018305284913),
(u’428’, 0.3948371956585509),
(u’563’, 0.3939127889961955), (u’1684’, 0.39360561458231796),
(u’171’, 0.37049270575282134), (u’348’, 0.36991572004397216),
(u’483’, 0.3698479575013739), (u’414’, 0.3695433330282786),
(u’376’, 0.36655773420479304)]
Facebook eigenvector centrality: [(u’1912’, 0.09540688873596524), (u’2266’,
0.08698328226321951), (u’2206’, 0.08605240174265624),
(u’2233’, 0.08517341350597836), (u’2464’, 0.08427878364685948),
(u’2142’, 0.08419312450068105), (u’2218’, 0.08415574433673866),
(u’2078’, 0.08413617905810111), (u’2123’, 0.08367142125897363),
(u’1993’, 0.08353243711860482)]
As can be seen in the previous results, each measure gives a different ordering
of the nodes. The node ‘107’ is the most central node for degree (see box Out
[7]), betweenness, and closeness centrality, while it is not among the 10 most central
nodes for eigenvector centrality. The second most central node is different for
closeness and eigenvector centralities; while the third most central node is
different for all four centrality measures.
Another interesting measure is the current flow betweenness centrality, also called
random walk betweenness centrality, of a node. It can be defined as the
probability of passing through the node in question on a random walk starting
and ending at some node. In this way, the betweenness is not computed as a
function of shortest paths, but of all paths. This makes sense for some social
networks where messages may get to their final destination not by the shortest
path, but by a random path, as in the case of gossip floating through a social
network for example.
Computing the current flow betweenness centrality can take a while, so we
b e t w e e n n e s s _ f b = nx . b e t w e e n n e s s _ c e n t r a l i t y ( fb )
c l o s e n e s s _ f b = nx . c l o s e n e s s _ c e n t r a l i t y ( fb )
e i g e n c e n t r a l i t y _ f b = nx . e i g e n v e c t o r _ c e n t r a l i t y ( fb )
pr in t ’ F a c e b o o k b e t w e e n n e s s c e n t r a l i t y : ’,
s or t e d ( b e t w e e n n e s s _ f b . i t em s () ,
key = lambda x: x [1] ,
reverse = T ru e ) [ :1 0 ]
pr i n t ’ F a c e b o o k c l o s e n e s s c e n t r a l i t y : ’,
s or t e d ( c l o s e n e s s _ f b . i te ms () ,
key = lambda x: x [1] ,
reverse = T ru e ) [: 1 0]
pr in t ’ F a c e b o o k e i g e n v e c t o r c e n t r a l i t y : ’,
s o r t ed ( e i g e n c e n t r a l i t y _ f b . i te m s () ,
key = lambda x: x [1] ,
reverse = T ru e ) [: 1 0]