momepy.mean_node_degree

momepy.mean_node_degree(graph, radius=5, name='mean_nd', degree='degree', distance=None, verbose=True)[source]

Calculates mean node degree for subgraph around each node if radius is set, or for whole graph, if radius=None.

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

Parameters
graphnetworkx.Graph

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

radius: int

radius defining the extent of subgraph

namestr, optional

calculated attribute name

degreestr

name of attribute of node degree (momepy.node_degree())

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
Graph

networkx.Graph if radius is set

float

mean node degree for graph if radius=None

Examples

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