use adjacency dictionary for graph equality

This commit is contained in:
Ben Steadman 2019-03-30 16:49:17 +00:00
parent 6b533dad04
commit b7e9e868ce
1 changed files with 20 additions and 10 deletions

View File

@ -6,7 +6,6 @@ import networkx
import contrib.regionTrimmer as region_trimmer
class TestRegionTrimmer(unittest.TestCase):
def test_get_nodes(self):
coords = [(0, 0), (0, -1), (-1, 0), (-1, -1)]
@ -46,13 +45,24 @@ class TestRegionTrimmer(unittest.TestCase):
def test_generate_edges(self):
graph = networkx.Graph()
graph.add_nodes_from([(0, 0), (0, -1), (-1, 0), (-1, -1)])
graph.add_nodes_from(
[(0, 0), (0, -1), (-1, 0), (-1, -1)]
)
graph = region_trimmer.generate_edges(graph)
expected = [((-1, 0), (-1, -1)),
((0, -1), (-1, -1)),
((0, 0), (-1, -1)),
((0, 0), (-1, 0)),
((0, 0), (0, -1))]
self.assertListEqual(sorted(list(graph.edges)), expected)
self.assertEqual(
graph.adj,
{
(0, -1): {(0, 0): {}, (-1, -1): {}},
(0, 0): {
(0, -1): {},
(-1, 0): {},
(-1, -1): {},
},
(-1, 0): {(0, 0): {}, (-1, -1): {}},
(-1, -1): {
(0, -1): {},
(0, 0): {},
(-1, 0): {},
},
},
)