momepy.straightness_centrality

momepy.straightness_centrality(graph, weight='mm_len', normalized=True, name='straightness')[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.

Parameters
graphnetworkx.Graph

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

weightstr (default ‘mm_len’)

attribute holding length of edge

normalizedbool

normalize to number of nodes-1 in connected part

namestr, optional

calculated attribute name

Returns
Graph

networkx.Graph

References

Porta S, Crucitti P and Latora V (2006) The network analysis of urban streets: A primal approach. Environment and Planning B: Planning and Design 33(5): 705–725.

Examples

>>> network_graph = mm.straightness_centrality(network_graph)