momepy.betweenness_centrality¶

momepy.
betweenness_centrality
(graph, name='betweenness', mode='nodes', weight='mm_len', endpoints=True, radius=None, distance=None, normalized=False, **kwargs)[source]¶ Calculates the shortestpath betweenness centrality for nodes.
Wrapper around
networkx.betweenness_centrality
ornetworkx.edge_betweenness_centrality
.Betweenness centrality of a node v is the sum of the fraction of allpairs shortest paths that pass through v
\[c_B(v) =\sum_{s,t \in V} \frac{\sigma(s, tv)}{\sigma(s, t)}\]where V is the set of nodes, \(\sigma(s, t)\) is the number of shortest \((s, t)\)paths, and \(\sigma(s, tv)\) 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, tv) = 0\).
Betweenness centrality of an edge e is the sum of the fraction of allpairs shortest paths that pass through e
\[c_B(e) =\sum_{s,t \in V} \frac{\sigma(s, te)}{\sigma(s, t)}\]where V is the set of nodes, \(\sigma(s, t)\) is the number of shortest \((s, t)\)paths, and \(\sigma(s, te)\) is the number of those paths passing through edge e.
Adapted from [PCL06].
 Parameters
 graphnetworkx.Graph
Graph representing street network. Ideally generated from GeoDataFrame using
momepy.gdf_to_nx()
 namestr, optional
calculated attribute name
 modestr, default ‘nodes’
mode of betweenness calculation. ‘node’ for nodebased, ‘edges’ for edgebased
 weightstr (default ‘mm_len’)
attribute holding the weight of edge (e.g. length, angle)
 radius: int
Include all neighbors of distance <= radius from n
 distancestr, optional
Use specified edge data key as distance. For example, setting
distance=’weight’
will use the edgeweight
to measure the distance from the node n during ego_graph generation. normalizedbool, optional
If True the betweenness values are normalized by 2/((n1)(n2)), where n is the number of nodes in subgraph.
 **kwargs
kwargs for
networkx.betweenness_centrality
ornetworkx.edge_betweenness_centrality
 Returns
 Graph
networkx.Graph
Notes
In case of angular betweenness, implementation is based on “Tasos Implementation”.
Examples
>>> network_graph = mm.betweenness_centrality(network_graph)