diff --git a/evrouting/gasstation/routing.py b/evrouting/gasstation/routing.py index fbea26dd06ae80eaa0e0bde8a2a5739759a1ddf1..0f421a70562bb1d1de74bec61f4c12e07d69b498 100644 --- a/evrouting/gasstation/routing.py +++ b/evrouting/gasstation/routing.py @@ -23,7 +23,11 @@ def insert_start_node(s: Node, graph_extended.add_node((s, initial_soc)) v: Node for v in gas_stations: - shortest_p: List[Node] = nx.shortest_path(graph_core, s, v, weight=DISTANCE_KEY) + try: + shortest_p: List[Node] = nx.shortest_path(graph_core, s, v, weight=DISTANCE_KEY) + except nx.NetworkXNoPath: + continue + w = f.path_consumption(graph_core, shortest_p) if w > initial_soc: continue @@ -65,7 +69,11 @@ def insert_final_node(t: Node, graph_extended.add_node((t, final_soc)) u: Node for u in gas_stations: - shortest_p: List[Node] = nx.shortest_path(graph_core, t, u, weight=DISTANCE_KEY) + try: + shortest_p: List[Node] = nx.shortest_path(graph_core, t, u, weight=DISTANCE_KEY) + except nx.NetworkXNoPath: + continue + w = f.path_consumption(graph_core, shortest_p) if w + final_soc > capacity: continue