iduedu.join_pt_walk_graph¶
- iduedu.join_pt_walk_graph(public_transport_g, walk_g, max_dist=20, keep_largest_subgraph=True)[source]¶
Join a public-transport graph with a pedestrian graph into a single intermodal network.
The function relabels node ids to avoid collisions, finds PT platforms (including subway entries/exits), projects them onto the nearest walking edges within max_dist, and connects the two networks. When multiple platforms project to the same point on a walk edge, PT nodes are merged. For each platform–edge match, the walking edge is split at the projection point (or its endpoint is replaced by the platform node), and new directed walk edges are created with length/time attributes. Finally, both graphs are composed and (optionally) pruned to the largest strongly connected component.
- Parameters:
public_transport_g (
networkx.Graph) – PT graph with node attributes x, y, type, route and a graph CRS in graph[“crs”]. Platform-like nodes are those with type in {“platform”,”subway_entry_exit”,”subway_entry”,”subway_exit”}.walk_g (
networkx.Graph) – Pedestrian graph in the same CRS with edge geometry and graph attribute graph[“walk_speed”] (meters/min). If walk_speed is missing, a default of 83.33 m/min is used.max_dist (
float) – Max search radius in meters to snap platforms to walk edges.keep_largest_subgraph (
bool) – If True, keep only the largest strongly connected component.
- Returns:
- Intermodal MultiDiGraph:
nodes: union of PT and Walk nodes (platforms become vertices of the walk network);
edges: original PT + split/updated Walk edges with geometry, length_meter, time_min, type=”walk” (for inserted walking segments).
Graph attrs: graph[“type”]=”intermodal”; CRS is inherited from inputs.
- Return type:
(nx.Graph)
Notes
Node ids of PT and Walk parts are relabeled to disjoint ranges before composition, then relabeled densely (0..N-1) in the final graph.
Platforms projecting exactly to a walk edge endpoint trigger in-place node relabeling of that endpoint to the platform id (no edge splitting needed).
Duplicate projection points along the same walk edge are detected; PT platforms are merged and their incident PT edges are rewired onto the chosen representative.