momepy.straightness_centrality¶
-
momepy.straightness_centrality(graph, weight=
'mm_len', normalized=True, name='straightness', radius=None, distance=None, verbose=True)[source]¶ Calculates the straightness centrality for nodes.
\[C_{S}(i)=\frac{1}{n-1} \sum_{j \in V, j \neq i} \frac{d_{i j}^{E u}} {d_{i j}}\]where \(\mathrm{d}^{\mathrm{E} \mathrm{u}}_{\mathrm{ij}}\) is the Euclidean distance between nodes i and j along a straight line.
Adapted from [Porta et al., 2006].
- Parameters:¶
- graph : networkx.Graph¶
A Graph representing a street network. Ideally generated from GeoDataFrame using
momepy.gdf_to_nx().- weight : str (default 'mm_len')¶
The attribute holding length of edge.
- normalized : bool¶
Normalize to the number of
nodes-1in the connected part (for local straightness it is recommended to set tonormalized=False).- name : str, optional¶
The calculated attribute name.
- radius : int¶
Include all neighbors of distance <= radius from
n.- distance : str, optional¶
Use specified edge data key as distance. For example, setting
distance=’weight’will use the edgeweightto measure the distance from the nodenduringego_graphgeneration.- verbose : bool (default True)¶
If
True, shows progress bars in loops and indication of steps.
- Returns:¶
netx – A networkx.Graph object.
- Return type:¶
Graph
Examples
>>> network_graph = mm.straightness_centrality(network_graph)