percolation_centrality#
- graph_tool.centrality.percolation_centrality(g, states=None, weight=None, vprop=None)[git][source]#
Calculate the percolation centrality of each vertex.
- Parameters:
- g
Graph Graph to be used.
- states
VertexPropertyMap(optional, default:None) Percolation states of the vertices, between 0 and 1. If not supplied, every vertex has state 1.
- 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 centrality values.
- g
- Returns:
- percolation
VertexPropertyMap A vertex property map with the percolation centrality values.
- percolation
See also
betweennessShortest-path betweenness centrality
load_centralityLoad centrality
Notes
The percolation centrality [piraveenan-percolation-2013] of a vertex \(v\) is
\[PC(v) = \frac{1}{n-2}\sum_{s \neq v \neq t} \frac{\sigma_{st}(v)}{\sigma_{st}} \frac{x_s}{\sum_i x_i - x_v},\]where \(x_i\) is the percolation state of vertex \(i\) (e.g. the extent to which it is infected), \(\sigma_{st}\) is the number of shortest paths from \(s\) to \(t\), \(\sigma_{st}(v)\) the number of them that pass through \(v\), and the sum is over the ordered pairs, also for undirected graphs. It is the betweenness centrality (see
betweenness()) in which the paths are weighted by the relative state of their source.The algorithm of [brandes-faster-2001] is used, with a complexity of \(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
[piraveenan-percolation-2013]Mahendra Piraveenan, Mikhail Prokopenko, and Liaquat Hossain, “Percolation centrality: Quantifying graph-theoretic impact of nodes during percolation in networks”, PLoS ONE 8, e53095 (2013), DOI: 10.1371/journal.pone.0053095 [sci-hub, @tor]
[brandes-faster-2001]U. Brandes, “A faster algorithm for betweenness centrality”, Journal of Mathematical Sociology, 2001, DOI: 10.1080/0022250X.2001.9990249 [sci-hub, @tor]
Examples
>>> g = gt.collection.data["karate"] >>> x = g.new_vp("double", vals=np.linspace(0, 1, g.num_vertices())) >>> pc = gt.percolation_centrality(g, states=x) >>> print(pc.a.argmax(), pc.a.max()) 0 0.377591920...
The values can be visualized by drawing the network with vertex colors and sizes given by them:
>>> cmap = matplotlib.colors.LinearSegmentedColormap.from_list( ... "gray-blue", ["#d9d9d9", "#7dabd1"]) >>> gt.graph_draw(g, g.vp.pos, vertex_fill_color=pc, vcmap=cmap, ... vertex_size=gt.prop_to_size(pc, mi=5, ma=15), ... output="percolation_centrality-karate.pdf") <...>
Percolation centrality of the vertices of Zachary’s karate club network, with the percolation states increasing linearly with the vertex index from 0 to 1. The vertex colors, from gray to blue, and the vertex sizes increase with the value.#