From 8a9933e4decb3b6a57b47b6409474bd476920c24 Mon Sep 17 00:00:00 2001
From: Hong-Phuc Bui <hong-phuc.bui@htwsaar.de>
Date: Fri, 27 Sep 2024 01:22:49 +0200
Subject: [PATCH] demo show image
---
stundenplan/tests/pygraph/shortestpath_tests.py | 53 ++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 42 insertions(+), 11 deletions(-)
diff --git a/stundenplan/tests/pygraph/shortestpath_tests.py b/stundenplan/tests/pygraph/shortestpath_tests.py
index 6b9b2de..dc914a1 100644
--- a/stundenplan/tests/pygraph/shortestpath_tests.py
+++ b/stundenplan/tests/pygraph/shortestpath_tests.py
@@ -1,26 +1,57 @@
import unittest
from pygraph.graphdemo import Graph
-from pygraph.shortestpath import bfs
+from pygraph.shortestpath import bfs, bfs_dict, find_path, find_path_gpt
class ShortestPathTestCase(unittest.TestCase):
def test_bfs(self):
g = Graph()
g.add_edges(0, [1, 2])
- g.add_edges(1, [0, 3, 4])
- g.add_edges(2, [0, 4, 6, 7])
- g.add_edges(3, [1])
- g.add_edges(4, [1, 2, 5])
- g.add_edges(5, [4])
- g.add_edges(6, [2])
- g.add_edges(7, [2])
- #print(g)
- # self.assertEqual(True, False) # add assertion here
-
+ g.add_edges(1, [3, 4])
+ g.add_edges(2, [4, 6, 7])
+ g.add_edges(4, [5])
+ print(g)
+ print("#")
tree = bfs(g, 0)
print(tree)
+ def test_bfs_dict(self):
+ g = Graph()
+ g.add_edges(0, [1, 2])
+ g.add_edges(1, [3, 4])
+ g.add_edges(2, [4, 6, 7])
+ g.add_edges(4, [5])
+ print(g)
+ tree = bfs_dict(g, 6)
+ print("Tree from Vertex 6")
+ print(tree)
+
+ def test_find_path(self):
+ g = Graph()
+ g.add_edges(0, [1, 2])
+ g.add_edges(1, [3, 4])
+ g.add_edges(2, [4, 6, 7])
+ g.add_edges(4, [5])
+ print(g)
+ (u, v) = (6, 5)
+ path = find_path(g, 6, 5)
+ print(f"path from {u} to {v}")
+ print(path)
+
+ def test_find_path_gpt(self):
+ g = Graph()
+ g.add_edges(0, [1, 2])
+ g.add_edges(1, [3, 4])
+ g.add_edges(2, [4, 6, 7])
+ g.add_edges(4, [5])
+ print(g)
+ (u, v) = (6, 5)
+ path = find_path_gpt(g, 6, 5)
+ print(f"path from {u} to {v}")
+ print(path)
+
+
if __name__ == '__main__':
unittest.main()
--
Gitblit v1.10.0