iduedu.shortest_path¶
- iduedu.shortest_path(urban_graph, source_node, target_node, *, weight='time_min', cutoff=None, method='bidirectional')[source]¶
Return the cost and the node route of one shortest path from source_node to target_node.
- Parameters:
urban_graph (
UrbanGraph) – Urban graph to search.source_node (
Any) – Graph id of the start node.target_node (
Any) – Graph id of the end node.weight (
Literal['length_meter','time_min']) – Edge cost column: time_min (minutes) or length_meter (meters).cutoff (
float|None) – Inclusive maximum cost, or None for no limit.method (
Literal['bidirectional','astar','alt','dijkstra']) –bidirectional(default) searches from both ends at once and stops where they meet.astarsearches from the start towards the straight-line direction of the end; it needs point geometries of the nodes.altis A* with an estimate from the costs to and from a few landmark nodes; their tables are built on the first call and kept with the graph, so it pays off for many queries on one graph.dijkstrais a one-sided search that stops at the end. All return a shortest path; they differ in speed only, and a tie between paths of equal cost may be resolved differently.
- Returns:
the cost in the units of
weightand the node ids from source_node to target_node, or(inf, [])when the end is not reached within cutoff.- Return type:
(cost, path)