-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_remove_transitive_edges
executable file
·78 lines (63 loc) · 1.72 KB
/
test_remove_transitive_edges
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python
import unittest
from remove_transitive_edges import simplify
from graph import *
class TestGraphMethods(unittest.TestCase):
# A graph with no transitive edges should be returned as is
def test_rte_self(self):
edges = {
"A":{"B":1},
"B":{"C":1}
}
G = Graph(edges)
S = simplify(G)
self.assertTrue(S == G)
# A simple test with a transitive edge of length 1
def test_rte_simple(self):
edges = {
"A":{"B":1, "C":1},
"B":{"C":1}
}
G = Graph(edges)
edges = {
"A":{"B":1},
"B":{"C":1}
}
H = Graph(edges)
S = simplify(G)
self.assertTrue(S == H)
# A little more challenging case, where we have two transitive edges, one
# of length 1 and another of length 2
def test_rte_two(self):
edges = {
"A":{"B":1, "C":1, "D":1},
"B":{"C":1},
"C":{"D":1}
}
G = Graph(edges)
edges = {
"A":{"B":1},
"B":{"C":1},
"C":{"D":1}
}
H = Graph(edges)
S = simplify(G)
self.assertTrue(S == H)
# Another case that has two transitive edges
def test_rte_two(self):
edges = {
"A":{"B":1, "C":1},
"B":{"C":1, "D":1},
"C":{"D":1}
}
G = Graph(edges)
edges = {
"A":{"B":1},
"B":{"C":1},
"C":{"D":1}
}
H = Graph(edges)
S = simplify(G)
self.assertTrue(S == H)
if __name__ == '__main__':
unittest.main()