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, 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
- graphnetworkx.Graph
Graph representing street network. Ideally generated from GeoDataFrame using
momepy.gdf_to_nx()
- radius: int
radius defining the extent of subgraph
- distancestr, optional
Use specified edge data key as distance. For example, setting
distance=’weight’
will use the edgeweight
to measure the distance from the node n.- meshednessbool, default True
Calculate meshedness (True/False)
- cds_lengthbool, default True
Calculate cul-de-sac length (True/False)
- modestr (defualt ‘sum’)
if
'sum'
, calculate total cds_length, if'mean'
calculate mean cds_length- degreestr
name of attribute of node degree (
momepy.node_degree()
)- lengthstr, default mm_len
name of attribute of segment length (geographical)
- mean_node_degreebool, default True
Calculate mean node degree (True/False)
- proportiondict, default {3: True, 4: True, 0: True}
Calculate proportion {3: True/False, 4: True/False, 0: True/False}
- cyclomaticbool, default True
Calculate cyclomatic complexity (True/False)
- edge_node_ratiobool, default True
Calculate edge node ratio (True/False)
- gammabool, default True
Calculate gamma index (True/False)
- local_closenessbool, default True
Calculate local closeness centrality (True/False)
- closeness_weightstr, optional
Use the specified edge attribute as the edge distance in shortest path calculations in closeness centrality algorithm
- verbosebool (default True)
if True, shows progress bars in loops and indication of steps
- Returns
- Graph
networkx.Graph
Examples
>>> network_graph = mm.subgraph(network_graph)