Note

This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.

rustworkx.graph_edge_betweenness_centrality#

graph_edge_betweenness_centrality(graph, /, normalized=True, parallel_threshold=50)#

Compute the edge betweenness centrality of all edges in a PyGraph.

Edge betweenness centrality of an edge \(e\) is the sum of the fraction of all-pairs shortest paths that pass through :math`e`

\[c_B(e) =\sum_{s,t \in V} \frac{\sigma(s, t|e)}{\sigma(s, t)}\]

where \(V\) is the set of nodes, \(\sigma(s, t)\) is the number of shortest \((s, t)\)-paths, and \(\sigma(s, t|e)\) is the number of those paths passing through edge \(e\).

The above definition and the algorithm used in this function is based on:

Ulrik Brandes, On Variants of Shortest-Path Betweenness Centrality and their Generic Computation. Social Networks 30(2):136-145, 2008.

This function is multithreaded and will run in parallel if the number of nodes in the graph is above the value of parallel_threshold (it defaults to 50). If the function will be running in parallel the env var RAYON_NUM_THREADS can be used to adjust how many threads will be used.

See Also#

graph_betweenness_centrality

param PyGraph graph:

The input graph

param bool normalized:

Whether to normalize the betweenness scores by the number of distinct paths between all pairs of nodes.

param int parallel_threshold:

The number of nodes to calculate the the betweenness centrality in parallel at if the number of nodes in the graph is less than this value it will run in a single thread. The default value is 50

returns:

a read-only dict-like object whose keys are the edge indices and values are the betweenness score for each edge.

rtype:

EdgeCentralityMapping