momepy.
betweenness_centrality
Calculates the shortest-path betweenness centrality for nodes.
Wrapper around networkx.betweenness_centrality or networkx.edge_betweenness_centrality.
networkx.betweenness_centrality
networkx.edge_betweenness_centrality
Betweenness centrality of a node v is the sum of the fraction of all-pairs shortest paths that pass through v
where V is the set of nodes, \(\sigma(s, t)\) is the number of shortest \((s, t)\)-paths, and \(\sigma(s, t|v)\) is the number of those paths passing through some node v other than s, t. If s = t, \(\sigma(s, t) = 1\), and if v in {s, t}`, \(\sigma(s, t|v) = 0\).
Betweenness centrality of an edge e is the sum of the fraction of all-pairs shortest paths that pass through e
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.
Adapted from [PCL06].
Graph representing street network. Ideally generated from GeoDataFrame using momepy.gdf_to_nx()
momepy.gdf_to_nx()
calculated attribute name
mode of betweenness calculation. ‘node’ for node-based, ‘edges’ for edge-based
attribute holding the weight of edge (e.g. length, angle)
Include all neighbors of distance <= radius from n
Use specified edge data key as distance. For example, setting distance=’weight’ will use the edge weight to measure the distance from the node n during ego_graph generation.
distance=’weight’
weight
If True the betweenness values are normalized by 2/((n-1)(n-2)), where n is the number of nodes in subgraph.
if True, shows progress bars in loops and indication of steps
kwargs for networkx.betweenness_centrality or networkx.edge_betweenness_centrality
networkx.Graph
Notes
In case of angular betweenness, implementation is based on “Tasos Implementation”.
Examples
>>> network_graph = mm.betweenness_centrality(network_graph)