Skip to content

Commit

Permalink
Merge pull request #1089 from PetholzA/feature/20062023_python_tests_…
Browse files Browse the repository at this point in the history
…reachability

python test: adds test in test_reachability.py
  • Loading branch information
fabratu committed Jul 5, 2023
2 parents d61f1b5 + 10c801f commit 2942994
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions networkit/test/test_reachability.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down

0 comments on commit 2942994

Please sign in to comment.