I am trying to find the weak ties as defined by Granovetter. So far I have tried using centrality measurements to plot the Stanford Facebook network dataset (facebook_combined.txt
) according to importance. The plot below uses degree centrality. I've indicated with blue rectangles some of the nodes that I wish to find (the 'weak ties').
Bridges seem close, but not quite there. How should I proceed in finding these nodes?
Example code:
import networkx as nx
fb = nx.read_edgelist("facebook_combined.txt")
degree_cent_fb = nx.degree_centrality(fb)
pos_fb = nx.spring_layout(fb ,iterations = 1000)
nsize = np.array ([v for v in degree_cent_fb.values ()])
nsize = 500*( nsize - min(nsize))/(max(nsize) - min(nsize))
nodes = nx.draw_networkx_nodes (fb , pos = pos_fb ,
node_size = nsize)
edges = nx.draw_networkx_edges (fb , pos = pos_fb ,
alpha = .1)
Here are some more example plots with other sizing functions:
Same data, sized by betweenness centrality:
And closeness centrality:
And with PageRank:
Note that weak ties or bridges refer to edges and you are looking rather for a node-level measure. You may be interested in Ron Burt's concept of a structural hole. Nodes occupying structural holes are brokers, connecting groups with limited overlap - sounds like what you are looking for.
NetworkX (as of version 2.0, if I recall correctly) has an implementation of Burt's constraint measure. Burt says a node occupies a structural hole if it has low constraint. One minus a node's constraint score seems to highlight the nodes in between communities quite well, though not in every case.
And here is the code. Beware - it takes some time to calculate constraint!
fb = nx.read_edgelist("facebook_combined.txt")
pos_fb = nx.spring_layout(fb ,iterations = 100)
cons = nx.constraint(fb)
plt.figure(figsize=(15,10))
nsize = np.array ([1-v for v in cons.values()])
nsize = 10**(nsize+1)
nodes = nx.draw_networkx_nodes (fb , pos = pos_fb , node_color=nsize, cmap=plt.cm.coolwarm,
node_size = nsize)
edges = nx.draw_networkx_edges (fb , pos = pos_fb ,
alpha = .1)
plt.axis('off')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With