Skip to content

Commit b7e9e86

Browse files
committed
use adjacency dictionary for graph equality
1 parent 6b533da commit b7e9e86

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

test/test_regionTrimmer.py

+20-10
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import contrib.regionTrimmer as region_trimmer
88

9-
109
class TestRegionTrimmer(unittest.TestCase):
1110
def test_get_nodes(self):
1211
coords = [(0, 0), (0, -1), (-1, 0), (-1, -1)]
@@ -46,13 +45,24 @@ def test_get_graph_center_by_bounds(self):
4645

4746
def test_generate_edges(self):
4847
graph = networkx.Graph()
49-
graph.add_nodes_from([(0, 0), (0, -1), (-1, 0), (-1, -1)])
50-
48+
graph.add_nodes_from(
49+
[(0, 0), (0, -1), (-1, 0), (-1, -1)]
50+
)
5151
graph = region_trimmer.generate_edges(graph)
52-
expected = [((-1, 0), (-1, -1)),
53-
((0, -1), (-1, -1)),
54-
((0, 0), (-1, -1)),
55-
((0, 0), (-1, 0)),
56-
((0, 0), (0, -1))]
57-
58-
self.assertListEqual(sorted(list(graph.edges)), expected)
52+
self.assertEqual(
53+
graph.adj,
54+
{
55+
(0, -1): {(0, 0): {}, (-1, -1): {}},
56+
(0, 0): {
57+
(0, -1): {},
58+
(-1, 0): {},
59+
(-1, -1): {},
60+
},
61+
(-1, 0): {(0, 0): {}, (-1, -1): {}},
62+
(-1, -1): {
63+
(0, -1): {},
64+
(0, 0): {},
65+
(-1, 0): {},
66+
},
67+
},
68+
)

0 commit comments

Comments
 (0)