iduedu.od_matrix

iduedu.od_matrix(urban_graph, *, gdf_origins=None, gdf_destinations=None, origins_nodes=None, destination_nodes=None, graph_node_column='graph_node_id', weight='time_min', dtype=<class 'numpy.float32'>, threshold=None, max_workers=None)[source]

Compute an origin-destination shortest-path matrix on an UrbanGraph.

Origins and destinations can be supplied either as graph node ids or as tables of objects. Tables with graph_node_column use those node ids directly; otherwise GeoDataFrame geometries are matched to nearest graph nodes. The helper builds or reuses the graph adjacency matrix for the selected weight.

Parameters:
  • urban_graph (UrbanGraph) – Urban graph with node and edge tables.

  • gdf_origins (DataFrame | None) – Table of origin objects.

  • gdf_destinations (DataFrame | None) – Table of destination objects.

  • origins_nodes (Optional[Iterable[Any]]) – Origin graph node ids.

  • destination_nodes (Optional[Iterable[Any]]) – Destination graph node ids.

  • graph_node_column (str) – Node id column used in origin and destination tables.

  • weight (Literal['length_meter', 'time_min']) – Edge weight column, usually "time_min" or "length_meter".

  • dtype (dtype) – Floating dtype for returned sparse values.

  • threshold (float | None) – Optional maximum path cost. Pairs without a path or beyond the threshold are represented as np.inf.

  • max_workers (int | None) – Optional number of numba worker threads.

Return type:

DataFrame

Returns:

Sparse DataFrame. When object tables are passed, rows and columns follow their indexes; when node lists are passed, rows and columns follow those node lists.

Raises:
  • TypeError – If the graph type or max_workers is invalid.

  • ValueError – If inputs are empty, the threshold is negative or requested nodes are absent from the graph.