From 65f0d0c8044aaa3b2e4a86603bb49d530da10267 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 02:57:01 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- graphs/johnson_graph.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/graphs/johnson_graph.py b/graphs/johnson_graph.py index 0f5441a15..99f187376 100644 --- a/graphs/johnson_graph.py +++ b/graphs/johnson_graph.py @@ -60,7 +60,10 @@ class JohnsonGraph: for vertex_a in self.graph: for vertex_a, vertex_b, weight in self.edges: - if distances[vertex_a] != sys.maxsize - 1 and distances[vertex_a] + weight < distances[vertex_b]: + if ( + distances[vertex_a] != sys.maxsize - 1 + and distances[vertex_a] + weight < distances[vertex_b] + ): distances[vertex_b] = distances[vertex_a] + weight return distances @@ -82,13 +85,25 @@ class JohnsonGraph: for i in range(len(self.edges)): vertex_a, vertex_b, weight = self.edges[i] - self.edges[i] = (vertex_a, vertex_b, weight + hash_path[vertex_a] - hash_path[vertex_b]) + self.edges[i] = ( + vertex_a, + vertex_b, + weight + hash_path[vertex_a] - hash_path[vertex_b], + ) self.graph.pop("#") - self.edges = [(vertex1, vertex2, node_weight) for vertex1, vertex2, node_weight in self.edges if vertex1 != "#"] + self.edges = [ + (vertex1, vertex2, node_weight) + for vertex1, vertex2, node_weight in self.edges + if vertex1 != "#" + ] for vertex in self.graph: - self.graph[vertex] = [(vertex2, node_weight) for vertex1, vertex2, node_weight in self.edges if vertex1 == vertex] + self.graph[vertex] = [ + (vertex2, node_weight) + for vertex1, vertex2, node_weight in self.edges + if vertex1 == vertex + ] distances = [] for vertex1 in self.graph: