momepy.straightness_centrality

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

Parameters
graphnetworkx.Graph

Graph representing street network. Ideally generated 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 (for local straightness is recommended to set to normalized False)

namestr, optional

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.

Returns
Graph

networkx.Graph

Examples

>>> network_graph = mm.straightness_centrality(network_graph)