pyorps.graph.api.rustworkx_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

RustworkxAPI(raster_data, steps[, ...])

Initialize the graph library API.

class pyorps.graph.api.rustworkx_api.RustworkxAPI(raster_data, steps, ignore_max=True, from_nodes=None, to_nodes=None, cost=None, **kwargs)[source]

Bases: GraphLibraryAPI

Initialize the graph library API.

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

  • 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)

  • from_nodes (ndarray | None) – Source node indices for edges

  • to_nodes (ndarray | None) – Target node indices for edges

  • cost (ndarray | None) – Edge weights

create_graph(from_nodes, to_nodes, cost=None, **kwargs)[source]

Creates a graph object using rustworkx.

Parameters:
  • from_nodes (list[int | int32 | int64 | uint32 | uint64] | ndarray[int]) – The starting node indices from the edge data

  • to_nodes (list[int | int32 | int64 | uint32 | uint64] | ndarray[int]) – The ending node indices from the edge data

  • cost (ndarray[int] | None) – The weight of the edge data

  • kwargs – Additional parameters for the underlying graph library

Returns:

The graph object

Return type:

rustworkx.PyGraph

get_number_of_nodes()[source]

Returns the number of nodes in the graph.

Returns:

The number of nodes

Return type:

int

get_number_of_edges()[source]

Returns the number of edges in the graph.

Returns:

The number of edges

Return type:

int

get_nodes()[source]

This method returns the nodes in the graph as a list or numpy array of node indices.

Returns:

List or array of node indices of the nodes in the graph

Return type:

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

remove_isolates()[source]

If the graph object was initialized with the maximum number of nodes, this function helps to reduce the occupied memory by removing nodes without any edge (degree == 0).

Returns:

None

Return type:

None