load_centrality#
- graph_tool.centrality.load_centrality(g, weight=None, vprop=None, eprop=None, norm=True, cutoff=None)[git][source]#
Calculate the load centrality of each vertex and edge.
- Parameters:
- g
Graph Graph to be used.
- weight
EdgePropertyMap(optional, default:None) Edge lengths. If not supplied, every edge has unit length.
- vprop
VertexPropertyMap(optional, default:None) Vertex property map to store the vertex load values.
- eprop
EdgePropertyMap(optional, default:None) Edge property map to store the edge load values.
- norm
bool(optional, default:True) Whether or not the load values should be normalized.
- cutoff
float(optional, default:None) If given, only the shortest paths of length at most
cutoffare considered.
- g
- Returns:
- vertex_load
VertexPropertyMap A vertex property map with the vertex load values.
- edge_load
EdgePropertyMap An edge property map with the edge load values.
- vertex_load
See also
betweennessShortest-path betweenness centrality
percolation_centralityPercolation centrality
Notes
The load centrality [goh-universal-2001] is a variant of the betweenness centrality (see
betweenness()) in which a unit of a commodity is sent from every vertex \(s\) to every other vertex \(t\) along the shortest paths, and divided at each vertex in equal parts among the neighbors that are closer to \(t\) (more precisely, among the edges to them that lie on shortest paths, so that parallel edges receive a share each), instead of in proportion to the number of shortest paths that go through them. The load of a vertex is the amount that passes through it, excluding the pairs in which it is an endpoint, and the load of an edge is the amount that passes along it. Since the load of a pair \((s,t)\) is in general different from the one of \((t,s)\), the sum is over the ordered pairs, and divided by two for undirected graphs. Ifnorm == True, the vertex values are divided by \((n-1)(n-2)\) and the edge values by \(n(n-1)\) (by half of these numbers for undirected graphs), as forbetweenness().The loads of all pairs with the same target are accumulated on the shortest-path tree of the target, in time \(O(VE)\) for unweighted graphs and \(O(VE + V(V+E)\log V)\) for weighted graphs.
Parallel implementation.
If enabled during compilation, this algorithm will run in parallel using OpenMP. See the parallel algorithms section for information about how to control several aspects of parallelization.
References
[goh-universal-2001]K.-I. Goh, B. Kahng, and D. Kim, “Universal behavior of load distribution in scale-free networks”, Physical Review Letters 87, 278701 (2001), DOI: 10.1103/PhysRevLett.87.278701 [sci-hub, @tor], arXiv: cond-mat/0106565
Examples
>>> g = gt.collection.data["karate"] >>> vl, el = gt.load_centrality(g) >>> print(vl.a.argmax(), vl.a.max()) 0 0.434683422...
The vertex and edge values can be visualized by drawing the network with colors and sizes given by them:
>>> cmap = matplotlib.colors.LinearSegmentedColormap.from_list( ... "gray-blue", ["#d9d9d9", "#7dabd1"]) >>> ecmap = matplotlib.colors.LinearSegmentedColormap.from_list( ... "gray-blue", ["#d9d9d9", "#377eb8"]) >>> gt.graph_draw(g, g.vp.pos, vertex_fill_color=vl, vcmap=cmap, ... vertex_size=gt.prop_to_size(vl, mi=5, ma=15), ... edge_color=el, ecmap=ecmap, ... edge_pen_width=gt.prop_to_size(el, mi=0.5, ma=4), ... output="load_centrality-karate.pdf") <...>
Load centrality of the vertices and edges of Zachary’s karate club network. The vertex colors, from gray to blue, and the vertex sizes increase with the vertex values, and the edge colors and widths with the edge values.#