From bf3c0c3de9b4f0244a1f51696592f066bec6f471 Mon Sep 17 00:00:00 2001 From: "Ajmera, Mahita SI/HZR-IDSA" Date: Thu, 17 Oct 2024 11:37:15 +0200 Subject: [PATCH] including print statement and output in doctest --- graphs/graphs_floyd_warshall.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/graphs/graphs_floyd_warshall.py b/graphs/graphs_floyd_warshall.py index 33a99fc88..824501403 100644 --- a/graphs/graphs_floyd_warshall.py +++ b/graphs/graphs_floyd_warshall.py @@ -6,7 +6,7 @@ weighted directed graph that can have negative edge weights. def _print_dist(dist, v): - print("\nThe shortest path matrix using Floyd Warshall algorithm\n") + print("The shortest path matrix using Floyd Warshall algorithm\n") for i in range(v): for j in range(v): if dist[i][j] != float("inf"): @@ -45,6 +45,11 @@ def floyd_warshall(graph, v): ... [9, 7, 0] ... ] >>> dist, _ = floyd_warshall(graph, 3) + The shortest path matrix using Floyd Warshall algorithm + + 0 3 INF + 2 0 INF + 9 7 0 >>> dist == expected True """ @@ -68,7 +73,7 @@ def floyd_warshall(graph, v): ): dist[i][j] = dist[i][k] + dist[k][j] - # _print_dist(dist, v) + _print_dist(dist, v) return dist, v