From efa846d92382e0530ccce3557ce819e84d2cbb54 Mon Sep 17 00:00:00 2001 From: MarvinTorres Date: Tue, 28 Jul 2020 21:12:32 -0400 Subject: [PATCH] Changed maximum misses variable to minimum hits - This is to reflect changes from #62 --- graph.py | 10 +++++----- main.py | 4 ++-- tests/unit/test_results.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/graph.py b/graph.py index 0b2ba497..96987635 100644 --- a/graph.py +++ b/graph.py @@ -127,20 +127,20 @@ def shortest_paths(self, source, destination, parameter=None): return paths def constrained_flexible_paths(self, source, destination, - maximum_misses=None, **metrics): + minimum_hits=None, **metrics): """Calculate the constrained shortest paths with flexibility.""" base = metrics.get("base", {}) flexible = metrics.get("flexible", {}) default_edge_list = list(self._filter_edges( self.graph.edges(data=True), **base)) length = len(flexible) - if maximum_misses is None: - maximum_misses = length - maximum_misses = min(length, max(0, maximum_misses)) + if minimum_hits is None: + minimum_hits = length + minimum_hits = min(length, max(0, minimum_hits)) results = [] paths = [] i = 0 - while (paths == [] and i in range(0, maximum_misses+1)): + while (paths == [] and i in range(0, minimum_hits+1)): for combo in combinations(flexible.items(), length-i): additional = dict(combo) paths = self._constrained_shortest_paths( diff --git a/main.py b/main.py index b012f5e1..85ac18c2 100644 --- a/main.py +++ b/main.py @@ -98,10 +98,10 @@ def shortest_constrained_path(self): destination = data.get('destination') base_metrics = data.get('base_metrics', {}) fle_metrics = data.get('flexible_metrics', {}) - maximum_misses = data.get('maximum_misses') + minimum_hits = data.get('minimum_flexible_hits') try: paths = self.graph.constrained_flexible_paths(source, destination, - maximum_misses, + minimum_hits, base=base_metrics, flexible=fle_metrics) return jsonify(paths) diff --git a/tests/unit/test_results.py b/tests/unit/test_results.py index 15498677..efe0176e 100644 --- a/tests/unit/test_results.py +++ b/tests/unit/test_results.py @@ -25,11 +25,11 @@ def get_path(self, source, destination): results = self.graph.shortest_paths(source, destination) return results - def get_path_constrained(self, source, destination, maximum_misses=None, + def get_path_constrained(self, source, destination, minimum_hits=None, **metrics): """Return the constrained shortest path""" return self.graph.constrained_flexible_paths(source, destination, - maximum_misses, + minimum_hits, **metrics) @staticmethod