momepy.meshedness#

momepy.meshedness(graph, radius=5, name='meshedness', distance=None, verbose=True)[source]#

Calculates meshedness for subgraph around each node if radius is set, or for whole graph, if radius=None. A subgraph is generated around each node within set radius. If distance=None, radius will define topological distance, otherwise it uses values in distance attribute.

\[\alpha=\frac{e-v+1}{2 v-5}\]

where \(e\) is the number of edges in a subgraph and \(v\) is the number of nodes in a subgraph.

Adapted from [Feliciotti, 2018].

Parameters:
graphnetworkx.Graph

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

radius: int, optional

Include all neighbors of distance <= radius from n.

namestr, optional

The 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.

verbosebool (default True)

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

Returns:
netxGraph

A networkx.Graph object if radius is set.

float

The meshedness for the graph if radius=None.

Examples

>>> network_graph = mm.meshedness(network_graph, radius=800, distance='edge_length')