From 199292b52ad6e5f38953a94fdc4579b81f0d4757 Mon Sep 17 00:00:00 2001
From: "niehues.mark@gmail.com" <niehues.mark@gmail.com>
Date: Mon, 30 Mar 2020 19:24:26 +0200
Subject: [PATCH] wip exception

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

diff --git a/evrouting/gasstation/routing.py b/evrouting/gasstation/routing.py
index 4849b2f..c40aa1c 100644
--- a/evrouting/gasstation/routing.py
+++ b/evrouting/gasstation/routing.py
@@ -195,6 +195,16 @@ def shortest_path(G: nx.Graph, charging_stations: Set[Node], s: Node, t: Node,
     :param U: Capacity
     :return:
     """
+    # Check if t is reachable from s
+    # Todo: Test!
+    _path = dijkstra(G, s, t, weight=CONSUMPTION_KEY)
+    _w = fold_path(G, _path, weight=CONSUMPTION_KEY)
+    if _w < initial_soc:
+        return {
+            'trip_time': fold_path(G, _path, weight=DISTANCE_KEY),
+            'path': [(s, 0), (t, 0)]
+        }
+
     contracted_graph: nx.Graph = contract_graph(G, charging_stations, capacity)
     extended_graph = state_graph(contracted_graph, capacity)
 
-- 
GitLab