iduedu.mode_graph

iduedu.mode_graph(street_graph, mode, *, simplify=True, keep_largest_subgraph=False)[source]

Take the graph of one mode from a street graph of get_street_graph().

The graph holds the edges the mode may use in at least one direction, with time_min from the time of the mode, and the nodes of those edges. Walking gives an undirected graph. Driving and cycling give directed graphs with an oneway column, as their builders do; an edge the mode may use only against its drawing is turned (u and v swap and the geometry is reversed). With simplify the edges are merged through the nodes that have only two edges of this mode (see simplify_graph()), so a road is not cut where only a footway joins it.

Parameters:
  • street_graph (UrbanGraph) – Graph of get_street_graph().

  • mode (Literal['walk', 'drive', 'bike']) – "walk", "drive" or "bike".

  • simplify (bool) – Merge chains of edges through nodes of degree two of this mode.

  • keep_largest_subgraph (bool) – Keep only the largest connected part (strongly connected for driving and cycling).

Returns:

Multigraph of type mode with the columns of the matching builder.

Return type:

UrbanGraph

Raises:

ValueError – If the street graph has no columns for mode.