From 32888788f288ce3ff21ed2f7d5f5dc774dfb3de2 Mon Sep 17 00:00:00 2001
From: "niehues.mark@gmail.com" <niehues.mark@gmail.com>
Date: Wed, 29 Apr 2020 17:55:58 +0200
Subject: [PATCH] minor fix

---
 evrouting/gasstation/routing.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/evrouting/gasstation/routing.py b/evrouting/gasstation/routing.py
index fbea26d..0f421a7 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
-- 
GitLab