diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /python/altgraph/altgraph_tests/test_altgraph.py | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'python/altgraph/altgraph_tests/test_altgraph.py')
-rw-r--r-- | python/altgraph/altgraph_tests/test_altgraph.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/python/altgraph/altgraph_tests/test_altgraph.py b/python/altgraph/altgraph_tests/test_altgraph.py new file mode 100644 index 000000000..2ca6b251e --- /dev/null +++ b/python/altgraph/altgraph_tests/test_altgraph.py @@ -0,0 +1,45 @@ +#!/usr/bin/env py.test +import os +import sys + +from altgraph import Graph, GraphAlgo +import unittest + +class BasicTests (unittest.TestCase): + def setUp(self): + self.edges = [ + (1,2), (2,4), (1,3), (2,4), (3,4), (4,5), (6,5), (6,14), (14,15), + (6, 15), (5,7), (7, 8), (7,13), (12,8), (8,13), (11,12), (11,9), + (13,11), (9,13), (13,10) + ] + + # these are the edges + self.store = {} + self.g = Graph.Graph() + for head, tail in self.edges: + self.store[head] = self.store[tail] = None + self.g.add_edge(head, tail) + + def test_num_edges(self): + # check the parameters + self.assertEqual(self.g.number_of_nodes(), len(self.store)) + self.assertEqual(self.g.number_of_edges(), len(self.edges)) + + def test_forw_bfs(self): + # do a forward bfs + self.assertEqual( self.g.forw_bfs(1), + [1, 2, 3, 4, 5, 7, 8, 13, 11, 10, 12, 9]) + + + def test_get_hops(self): + # diplay the hops and hop numbers between nodes + self.assertEqual(self.g.get_hops(1, 8), + [(1, 0), (2, 1), (3, 1), (4, 2), (5, 3), (7, 4), (8, 5)]) + + def test_shortest_path(self): + self.assertEqual(GraphAlgo.shortest_path(self.g, 1, 12), + [1, 2, 4, 5, 7, 13, 11, 12]) + + +if __name__ == "__main__": # pragma: no cover + unittest.main() |