修订版 | 0a0a791ee78b826ffa4675748e0ced1a0a88d7ea (tree) |
---|---|
时间 | 2009-06-19 00:07:53 |
作者 | isella |
Commiter | isella |
I added the calculation of the mean betweenness and explained the relation
with the igraph calculation. Careful again: it looks like there is a factor 2
calculated with networkx.
@@ -48,10 +48,17 @@ | ||
48 | 48 | |
49 | 49 | print "the mean shortest path is, ", short |
50 | 50 | |
51 | -betx=nx.betweenness_centrality(G) | |
51 | +bet_val=nx.betweenness_centrality(G, normalized=False) | |
52 | 52 | |
53 | +#NB: the betweenness is stored as a Python dictionary, now I need to use its .values() method | |
54 | +#to fetch the numerical values of the betweenness of each node | |
53 | 55 | |
56 | +bet_arr=s.asarray(bet_val.values()) #I changed the numerical values of the betweenness for each vertex | |
57 | +#into a numpy array | |
54 | 58 | |
59 | +print "the mean value of the betweenness is, ", bet_arr.mean()/2. #careful about the definitions here!!! | |
60 | +#there is a factor 2 between the (unnormalized) betweenness in networkx and in igraph | |
55 | 61 | |
62 | +#print "bet_arr is, ", bet_arr | |
56 | 63 | |
57 | 64 | print "So far so good" |