iduedu.single_source_dijkstra¶
- iduedu.single_source_dijkstra(urban_graph, source_node, *, target_nodes=None, weight='time_min', cutoff=None, reverse=False, output='both', path_storage='eager', dtype=<class 'numpy.float32'>, distance_format='frame')[source]¶
Search from one node; return distances, paths, or both from one traversal.
- Parameters:
urban_graph (
UrbanGraph) – Urban graph to search.source_node (
Any) – Source graph node id.target_nodes (
Optional[Iterable[Any]]) – Requested target ids, or None for all reachable nodes. Explicit targets retain their order, including unreachable targets.weight (
Literal['length_meter','time_min']) – Non-negative edge cost; time_min uses minutes, length_meter meters.cutoff (
float|None) – Inclusive maximum total cost. None means no limit.reverse (
bool) – Search the reversed directed graph; routes are returned in the original graph direction, from a target towards the source.output (
Literal['distances','paths','both']) – distances, paths, or both (a ShortestPathResult).path_storage (
Literal['eager','lazy']) – eager creates paths immediately; lazy requires output=both and reconstructs routes through result.get_path(target).dtype (
dtype) – Returned distance dtype. Kernel arithmetic remains float32.distance_format (
Literal['frame','dense','sparse']) –"frame"(default) returns a pandas Series for distances. Withoutput="distances"or"both","dense"uses a one-dimensional NumPy array in target order withnp.inffor unreachable or out-of-cutoff nodes. Withtarget_nodes=None, it covers all nodes innodes_gdforder. With"both", the path Series follows the same order and keeps the node labels."sparse"is available only for matrix results.
- Return type:
- Returns:
A sparse Series, a one-dimensional distance array, or a ShortestPathResult. Missing costs and paths are inf and None, respectively.