momepy.subgraph

momepy.subgraph(graph, radius=5, distance=None, meshedness=True, cds_length=True, mode='sum', degree='degree', length='mm_len', mean_node_degree=True, proportion={0: True, 3: True, 4: True}, cyclomatic=True, edge_node_ratio=True, gamma=True, local_closeness=True, closeness_weight=None, node_density=True, verbose=True)[source]

Calculates all subgraph-based characters. Generating subgraph might be a time consuming activity. If we want to use the same subgraph for more characters, subgraph allows this by generating subgraph and then analysing it using selected options.

Parameters:
graph : networkx.Graph

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

radius : int

Include all neighbors of distance <= radius from n.

distance : str, 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.

meshedness : bool, default True

Calculate meshedness (True or ``False).

cds_length : bool, default True

Calculate cul-de-sac length (True or ``False).

mode : str (defualt 'sum')

If 'sum', calculate total cds_length, if 'mean' calculate mean cds_length.

degree : str

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

length='mm_len'

The name of the attribute of segment length (geographical).

mean_node_degree : bool, default True

Calculate mean node degree (True or ``False).

proportion : dict, default {3: True, 4: True, 0: True}

Calculate proportion {3: True/False, 4: True/False, 0: True/False}.

cyclomatic : bool, default True

Calculate cyclomatic complexity (True or ``False).

edge_node_ratio : bool, default True

Calculate edge node ratio (True or ``False).

gamma : bool, default True

Calculate gamma index (True or ``False).

local_closeness : bool, default True

Calculate local closeness centrality (True or ``False).

closeness_weight : str, optional

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

verbose : bool (default True)

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

Returns:

netx – A networkx.Graph object.

Return type:

Graph

Examples

>>> network_graph = mm.subgraph(network_graph)