# momepy.local_straightness_centrality¶

momepy.local_straightness_centrality(graph, radius=5, name='straightness', distance=None, weight='mm_len')[source]

Calculates local straightness for each node based on the defined distance.

Subgraph is generated around each node within set radius. If distance=None, radius will define topological distance, otherwise it uses values in distance attribute.

$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()

radius: int

number of topological steps defining the extent of subgraph

namestr, optional

calculated attribute name

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.

weightstr, optional

Use the specified edge attribute as the edge distance in shortest path calculations in closeness centrality algorithm

Returns
Graph

networkx.Graph

Examples

>>> network_graph = mm.local_straightness_centrality(network_graph, radius=400, distance='edge_length')