diff --git a/evrouting/gasstation/routing.py b/evrouting/gasstation/routing.py index c38a0bba8e18d823c9ffe1981393aab4d3acd782..1e3edbd6357cbf628ce3ff53f5f5125d569e1973 100644 --- a/evrouting/gasstation/routing.py +++ b/evrouting/gasstation/routing.py @@ -62,7 +62,7 @@ def contract_graph(G: nx.Graph, charging_stations: Set[Node], capacity: SoC, for cs in list(charging_stations): H.add_node(cs, **G.nodes[cs]) # Iterate unvisited charging stations - for n_cs in [n for n in charging_stations if (n, cs) not in H.edges]: + for n_cs in [n for n in charging_stations if (n, cs) not in H.edges and n != cs]: min_path: Path = dist(G, cs, n_cs) consumption: SoC = fold_path(G, min_path, weight=CONSUMPTION_KEY) if consumption <= capacity: