momepy.local_betweenness_centrality(graph, radius=5, name='betweenness', distance=None, weight=None, normalized=False, **kwargs)[source]

Calculates the shortest-path betweenness centrality for nodes within subgraph.

Subgraph is generated around each node within set radius. If distance=None, radius will define topological distance, otherwise it uses values in distance attribute. Based on networkx.betweenness_centrality.

Betweenness centrality of a node v is the sum of the fraction of all-pairs shortest paths that pass through v

\[c_B(v) =\sum_{s,t \in V} \frac{\sigma(s, t|v)}{\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|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\).


Graph representing street network. Ideally genereated from GeoDataFrame using momepy.gdf_to_nx()

radius: int

number of topological steps defining the extent of subgraph

namestr, optional

calculated attribute name

distancestr, optional

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.

weightstr, optional

Use the specified edge attribute as the edge distance in shortest path calculations in closeness centrality algorithm

normalizedbool, optional

If True the betweenness values are normalized by 2/((n-1)(n-2)), where n is the number of nodes in subgraph.


kwargs for networkx.betweenness_centrality_subset




>>> network_graph = mm.local_betweenness_centrality(network_graph, radius=800, distance='edge_length')