use adjacency dictionary for graph equality
This commit is contained in:
@@ -6,7 +6,6 @@ import networkx
|
|||||||
|
|
||||||
import contrib.regionTrimmer as region_trimmer
|
import contrib.regionTrimmer as region_trimmer
|
||||||
|
|
||||||
|
|
||||||
class TestRegionTrimmer(unittest.TestCase):
|
class TestRegionTrimmer(unittest.TestCase):
|
||||||
def test_get_nodes(self):
|
def test_get_nodes(self):
|
||||||
coords = [(0, 0), (0, -1), (-1, 0), (-1, -1)]
|
coords = [(0, 0), (0, -1), (-1, 0), (-1, -1)]
|
||||||
@@ -46,13 +45,24 @@ class TestRegionTrimmer(unittest.TestCase):
|
|||||||
|
|
||||||
def test_generate_edges(self):
|
def test_generate_edges(self):
|
||||||
graph = networkx.Graph()
|
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)
|
graph = region_trimmer.generate_edges(graph)
|
||||||
expected = [((-1, 0), (-1, -1)),
|
self.assertEqual(
|
||||||
((0, -1), (-1, -1)),
|
graph.adj,
|
||||||
((0, 0), (-1, -1)),
|
{
|
||||||
((0, 0), (-1, 0)),
|
(0, -1): {(0, 0): {}, (-1, -1): {}},
|
||||||
((0, 0), (0, -1))]
|
(0, 0): {
|
||||||
|
(0, -1): {},
|
||||||
self.assertListEqual(sorted(list(graph.edges)), expected)
|
(-1, 0): {},
|
||||||
|
(-1, -1): {},
|
||||||
|
},
|
||||||
|
(-1, 0): {(0, 0): {}, (-1, -1): {}},
|
||||||
|
(-1, -1): {
|
||||||
|
(0, -1): {},
|
||||||
|
(0, 0): {},
|
||||||
|
(-1, 0): {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user