| 85 | |
| 86 | class TestGraph(unittest.TestCase): |
| 87 | def test_directed_graph(self): |
| 88 | g = hl.Graph() |
| 89 | g.add_node("a") |
| 90 | g.add_node("b") |
| 91 | g.add_node("c") |
| 92 | g.add_edge("a", "b") |
| 93 | g.add_edge("b", "c") |
| 94 | |
| 95 | self.assertEqual(g.incoming("b")[0], "a") |
| 96 | self.assertEqual(g.outgoing("b")[0], "c") |
| 97 | g.replace(["b"], "x") |
| 98 | self.assertEqual(sorted(list(g.nodes.values())), sorted(["a", "c", "x"])) |
| 99 | self.assertEqual(g.incoming("x")[0], "a") |
| 100 | self.assertEqual(g.outgoing("x")[0], "c") |
| 101 | |
| 102 | |
| 103 | class TestPatterns(unittest.TestCase): |