Skip to content

[FEATURE]get_path_length_to_station returns hop count, not actual distance #594

@joda9

Description

@joda9

Is your feature request related to a problem? Please describe.

get_path_length_to_station() in edisgo/tools/tools.py uses len(path) - 1 to calculate the distance from each bus to the station. This returns the number of edges (hops) in the shortest path, not the actual cable distance in km. As a result, a bus behind 2 long cables (e.g. 2 × 10 km) appears "closer" than one behind 5 short cables (e.g. 5 × 100 m), which is misleading when you need to identify the electrically most remote bus.

Describe the solution you'd like

Use nx.shortest_path_length(graph, source, target, weight="length") instead of counting nodes in the path. The graph edges already carry a length attribute (populated from lines_df), so the data is there — it just isn't being used. For LV buses, the MV cable distance to the respective LV station should be added on top of the LV path length.

Describe alternatives you've considered

  • Using impedance (R + X from line parameters) as the weight instead of physical length, which would better reflect electrical distance. However, this would require additional data and length is a good enough proxy for most use cases.
  • A separate function rather than changing the existing one, to avoid breaking downstream code that relies on hop counts.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions