From 10c801fb6531d3da6f61f1eb1424cc5068c5f0b9 Mon Sep 17 00:00:00 2001 From: petholza Date: Tue, 20 Jun 2023 10:25:55 +0200 Subject: [PATCH] python test: adds test in test_reachability.py --- networkit/test/test_reachability.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/networkit/test/test_reachability.py b/networkit/test/test_reachability.py index 7908e53a9b..e7ff3f4f45 100755 --- a/networkit/test/test_reachability.py +++ b/networkit/test/test_reachability.py @@ -5,6 +5,33 @@ class TestReachability(unittest.TestCase): + def testAllSimplePaths(self): + G = nk.Graph(8, directed=True) + G.addEdge(0,1) + G.addEdge(2,3) + G.addEdge(0,5) + G.addEdge(1,3) + G.addEdge(4,5) + G.addEdge(5,6) + G.addEdge(6,7) + G.addEdge(3,6) + + asp = nk.reachability.AllSimplePaths(G, 0, 7).run() + self.assertEqual(asp.numberOfSimplePaths(), 2) + self.assertIn([0, 1, 3, 6, 7], asp.getAllSimplePaths()) + self.assertIn([0, 5, 6, 7], asp.getAllSimplePaths()) + + def testAllSimplePathsForIterator(self): + G = nk.Graph(4, directed=True) + G.addEdge(0,1) + G.addEdge(2,3) + G.addEdge(0,2) + G.addEdge(1,3) + + asp = nk.reachability.AllSimplePaths(G, 0, 3).run() + asp.forAllSimplePaths(lambda x : [0,1,2,3]) + self.assertEqual(asp.numberOfSimplePaths(), 2) + def testReachableNodes(self): for directed in [False, True]: for exact in [False, True]: