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:
graphnetworkx.Graph

A Graph representing a street network. Ideally generated from GeoDataFrame using momepy.gdf_to_nx().

weightstr (default ‘mm_len’)

The attribute holding length of edge.

normalizedbool

Normalize to the number of nodes-1 in the connected part (for local straightness it is recommended to set to normalized=False).

namestr, optional

The calculated attribute name.

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 edge weight to measure the distance from the node n during ego_graph generation.

verbosebool (default True)

If True, shows progress bars in loops and indication of steps.

Returns:
netxGraph

A networkx.Graph object.

Examples

>>> network_graph = mm.straightness_centrality(network_graph)