pyorps.graph.api.graph_api

PYORPS: An Open-Source Tool for Automated Power Line Routing

Reference: [1] Hofmann, M., Stetz, T., Kammer, F., Repo, S.: ‘PYORPS: An Open-Source Tool for

Automated Power Line Routing’, CIRED 2025 - 28th Conference and Exhibition on Electricity Distribution, 16 - 19 June 2025, Geneva, Switzerland

Classes

GraphAPI(raster_data, steps[, ignore_max])

Base class for all graph APIs defining the minimal required interface.

class pyorps.graph.api.graph_api.GraphAPI(raster_data, steps, ignore_max=True)[source]

Bases: ABC

Base class for all graph APIs defining the minimal required interface.

Initialize the base graph API with raster data and neighborhood steps.

Parameters:
  • raster_data (ndarray[int]) – 2D numpy array representing the raster costs

  • steps (ndarray[int]) – Array defining the neighborhood connections

  • ignore_max (bool | None) – Ignore edges whose weights are greater or equal to the maximum

  • data (value in the raster)

__init__(raster_data, steps, ignore_max=True)[source]

Initialize the base graph API with raster data and neighborhood steps.

Parameters:
  • raster_data (ndarray[int]) – 2D numpy array representing the raster costs

  • steps (ndarray[int]) – Array defining the neighborhood connections

  • ignore_max (bool | None) – Ignore edges whose weights are greater or equal to the maximum

  • data (value in the raster)

abstractmethod shortest_path(source_indices, target_indices, algorithm='dijkstra', **kwargs)[source]

Find the shortest path(s) between source and target indices.

Parameters:
  • source_indices (int | list[int] | ndarray[int] | tuple[int, int]) – Source node indices

  • target_indices (int | list[int] | ndarray[int] | tuple[int, int]) – Target node indices

  • algorithm (str) – Algorithm name (e.g., “dijkstra”, “astar”)

  • **kwargs

    pairwisebool

    If True, compute pairwise shortest paths between source_indices and target_indices. Only allowed if len(source_indices) == len(target_indices)

    heuristiccallable, optional

    A function that takes two node indices (u, target) and returns an estimate of the distance between them. Only used when algorithm=”astar”.

Returns:

list of path indices for each source-target pair

Return type:

list[int | int32 | int64 | uint32 | uint64] | ndarray[int] | list[list[int | int32 | int64 | uint32 | uint64] | ndarray[int]]