momepy.cyclomatic

momepy.cyclomatic(graph, radius=5, name='cyclomatic', distance=None)[source]

Calculates cyclomatic complexity for subgraph around each node.

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=e-v+1\]

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

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.

Returns
Graph

networkx.Graph

References

Bourdic L, Salat S and Nowacki C (2012) Assessing cities: a new system of cross-scale spatial indicators. Building Research & Information 40(5): 592–605.

Examples

>>> network_graph = mm.cyclomatic(network_graph, radius=3)