iduedu.ShortestPathResult

class iduedu.ShortestPathResult(distances, path_store, *, path_storage='eager', nearest_sources=None)[source]

Distances and paths from the same Dijkstra searches.

distances is a sparse pandas Series or DataFrame, a NumPy array, or a SciPy CSR array, depending on distance_format. Array positions match the pandas path table, with one distance per row for one-dimensional arrays. Accessing paths creates and caches the path table. With path_storage="lazy", use get_path to reconstruct individual routes without materializing that table or rerunning Dijkstra. Results retain a snapshot of node ids and predecessors, so later graph edits do not change the saved routes.

For single-source and nearest-source results, call get_path(target). For matrices and pairwise results, call get_path(origin, destination) using the result labels (object labels when object tables were supplied). Duplicate labels require positional access through get_path_at.

Parameters:

path_store (_PathStore)

distances

Shortest costs in the selected weight units.

nearest_sources

A pandas Series of winning graph node ids for a nearest-source search, in distance order for every format. Unreachable targets have a None owner. Other searches set this to None.

Methods

get_path

Return one route by labels, or None if it is unreachable or beyond cutoff.

get_path_at

Return a route by zero-based table positions (also supports duplicate labels).

property paths: Series | DataFrame

Materialize and cache the sparse path table, without another search.

property paths_materialized: bool

Whether the complete path table has been created.

get_path(origin, destination=None)[source]

Return one route by labels, or None if it is unreachable or beyond cutoff.

Return type:

list[Any] | None

Parameters:
  • origin (Any)

  • destination (Any)

get_path_at(row, column=0)[source]

Return a route by zero-based table positions (also supports duplicate labels).

Return type:

list[Any] | None

Parameters: