From 25844732f1b18a8bb9e9af207be352e1e3a6463c Mon Sep 17 00:00:00 2001 From: Joelkurien Date: Mon, 28 Oct 2024 14:43:31 +1100 Subject: [PATCH] Handled word length --- graphs/johnson_graph.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/graphs/johnson_graph.py b/graphs/johnson_graph.py index b96e22a3e..efa3e27f1 100644 --- a/graphs/johnson_graph.py +++ b/graphs/johnson_graph.py @@ -117,13 +117,11 @@ class JohnsonGraph: >>> g = JohnsonGraph() >>> g.add_vertices("A") >>> g.add_vertices("B") - >>> g.add_vertices("C") >>> g.add_edge("A", "B", 1) - >>> g.add_edge("B", "C", 2) - >>> g.add_edge("A", "C", 4) + >>> g.add_edge("B", "A", 2) >>> optimal_paths = g.johnson_algo() >>> optimal_paths - [{'A': 0, 'B': 1, 'C': 3}, {'A': None, 'B': 0, 'C': 2}, {'A': None, 'B': None, 'C': 0}] + [{'A': 0, 'B': 1}, {'A': 2, 'B': 0}] """ self.add_vertices("#") for vertex in self.graph: