File: load.txt

package info (click to toggle)
python-networkx 1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,780 kB
  • ctags: 1,910
  • sloc: python: 29,050; makefile: 126
file content (225 lines) | stat: -rw-r--r-- 5,000 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
Centrality
==========

>>> from networkx import *

>>> K=krackhardt_kite_graph()
>>> P3=path_graph(3)
>>> P4=path_graph(4)
>>> K5=complete_graph(5)
>>> C4=cycle_graph(4)
>>> T=balanced_tree(r=2, h=2)
>>> Gb = Graph()
>>> Gb.add_edges_from([(0,1), (0,2), (1,3), (2,3), (2,4), (4,5), (3,5)])


>>> F=Graph() # Florentine families
>>> F.add_edge('Acciaiuoli','Medici')
>>> F.add_edge('Castellani','Peruzzi')
>>> F.add_edge('Castellani','Strozzi')
>>> F.add_edge('Castellani','Barbadori')
>>> F.add_edge('Medici','Barbadori')
>>> F.add_edge('Medici','Ridolfi')
>>> F.add_edge('Medici','Tornabuoni')
>>> F.add_edge('Medici','Albizzi')
>>> F.add_edge('Medici','Salviati')
>>> F.add_edge('Salviati','Pazzi')
>>> F.add_edge('Peruzzi','Strozzi')
>>> F.add_edge('Peruzzi','Bischeri')
>>> F.add_edge('Strozzi','Ridolfi')
>>> F.add_edge('Strozzi','Bischeri')
>>> F.add_edge('Ridolfi','Tornabuoni')
>>> F.add_edge('Tornabuoni','Guadagni')
>>> F.add_edge('Albizzi','Ginori')
>>> F.add_edge('Albizzi','Guadagni')
>>> F.add_edge('Bischeri','Guadagni')
>>> F.add_edge('Guadagni','Lamberteschi')


Load
----
>>> b=load_centrality(K5)
>>> for v in K5:
...     print "%0.2d %5.3f"%(v,b[v])
00 0.000
01 0.000
02 0.000
03 0.000
04 0.000

>>> b=load_centrality(P3)
>>> for v in P3:
...     print "%0.2d %5.3f"%(v,b[v])
00 0.000
01 1.000
02 0.000


>>> b=load_centrality(K)
>>> for v in K:
...     print "%0.2d %5.3f"%(v,b[v])
00 0.023
01 0.023
02 0.000
03 0.102
04 0.000
05 0.231
06 0.231
07 0.389
08 0.222
09 0.000


>>> b=load_centrality(F)
>>> for v in sorted(F):
...     print "%-13s %5.3f"%(v,b[v])
Acciaiuoli    0.000
Albizzi       0.211
Barbadori     0.093
Bischeri      0.104
Castellani    0.055
Ginori        0.000
Guadagni      0.251
Lamberteschi  0.000
Medici        0.522
Pazzi         0.000
Peruzzi       0.022
Ridolfi       0.117
Salviati      0.143
Strozzi       0.106
Tornabuoni    0.090


Unnormalized

>>> b=load_centrality(K5,normalized=False)
>>> for v in K5:
...     print "%0.2d %5.3f"%(v,b[v])
00 0.000
01 0.000
02 0.000
03 0.000
04 0.000

>>> b=load_centrality(P3,normalized=False)
>>> for v in P3:
...     print "%0.2d %5.3f"%(v,b[v])
00 0.000
01 2.000
02 0.000


>>> b=load_centrality(K,normalized=False)
>>> for v in K:
...     print "%0.2d %5.3f"%(v,b[v])
00 1.667
01 1.667
02 0.000
03 7.333
04 0.000
05 16.667
06 16.667
07 28.000
08 16.000
09 0.000



>>> b=load_centrality(F,normalized=False)
>>> for v in sorted(F):
...     print "%-13s %5.3f"%(v,b[v])
Acciaiuoli    0.000
Albizzi       38.333
Barbadori     17.000
Bischeri      19.000
Castellani    10.000
Ginori        0.000
Guadagni      45.667
Lamberteschi  0.000
Medici        95.000
Pazzi         0.000
Peruzzi       4.000
Ridolfi       21.333
Salviati      26.000
Strozzi       19.333
Tornabuoni    16.333

Difference Between Load and Betweenness
---------------------------------------
The smallest graph that shows the difference between
load and betweenness is G=ladder_graph(3) (Graph B below)

Graph A and B are from Tao Zhou, Jian-Guo Liu, Bing-Hong Wang:
Comment on ``Scientific collaboration networks. II. Shortest paths,
weighted networks, and centrality". http://arxiv.org/pdf/physics/0511084

Notice that unlike here, their calculation adds to 1 to the betweennes
of every node i for every path from i to every other node.  This is
exactly what it should be, based on Eqn. (1) in their paper: the eqn
is B(v) = \sum_{s\neq t, s\neq v}{\frac{\sigma_{st}(v)}{\sigma_{st}}},
therefore, they allow v to be the target node.

We follow Brandes 2001, who follows Freeman 1977 that make the sum for
betweenness of v exclude paths where v is either the source or target
node.  To agree with their numbers, we must additionally, remove edge
(4,8) from the graph, see AC example following (there is a mistake
in the figure in their paper - personal communication).

>>> A = Graph()
>>> A.add_edges_from([(0,1), (1,2), (1,3), (2,4), (3,5), (4,6), (4,7), (4,8), (5,8), (6,9), (7,9), (8,9)])
>>> B = Graph() # ladder_graph(3)
>>> B.add_edges_from([(0,1), (0,2), (1,3), (2,3), (2,4), (4,5), (3,5)])

>>> b = load_centrality(B,normalized=False)
>>> for v in B:
...     print "%0.2d %5.3f"%(v,b[v])
00 1.750
01 1.750
02 6.500
03 6.500
04 1.750
05 1.750


Edge Load
---------
>>> b = edge_load(C4)
>>> for v in C4.edges():
...     print "(%0.2d, %0.2d) %5.3f"%(v[0], v[1], b[v])
(00, 01) 6.000
(00, 03) 6.000
(01, 02) 6.000
(02, 03) 6.000

>>> b = edge_load(P4)
>>> for v in P4.edges():
...     print "(%0.2d, %0.2d) %5.3f"%(v[0], v[1], b[v])
(00, 01) 6.000
(01, 02) 8.000
(02, 03) 6.000

>>> b = edge_load(K5)
>>> for v in K5.edges():
...     print "(%0.2d, %0.2d) %5.3f"%(v[0], v[1], b[v])
(00, 01) 5.000
(00, 02) 5.000
(00, 03) 5.000
(00, 04) 5.000
(01, 02) 5.000
(01, 03) 5.000
(01, 04) 5.000
(02, 03) 5.000
(02, 04) 5.000
(03, 04) 5.000

>>> b = edge_load(T)
>>> for v in T.edges():
...     print "(%0.2d, %0.2d) %5.3f"%(v[0], v[1], b[v])
(00, 01) 24.000
(00, 02) 24.000
(01, 03) 12.000
(01, 04) 12.000
(02, 05) 12.000
(02, 06) 12.000