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.digraph_betweenness_centrality#
- digraph_betweenness_centrality(graph, /, normalized=True, endpoints=False, parallel_threshold=50)#
Compute the betweenness centrality of all nodes in a PyDiGraph.
Betweenness centrality of a node
is the sum of the fraction of all-pairs shortest paths that pass throughwhere
is the set of nodes, is the number of shortest paths, and is the number of those paths passing through some node other than . If , , and if ,The algorithm used in this function is based on:
Ulrik Brandes, A Faster Algorithm for Betweenness Centrality. Journal of Mathematical Sociology 25(2):163-177, 2001.
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 varRAYON_NUM_THREADS
can be used to adjust how many threads will be used.See Also#
digraph_edge_betweenness_centrality()
- param PyDiGraph 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 bool endpoints:
Whether to include the endpoints of paths in pathlengths used to compute the betweenness.
- 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 node indices and values are the betweenness score for each node.
- rtype:
CentralityMapping