def test_depth(): g = SimpleGraph() g.add_edge('a', 'b') g.add_edge('a', 'c') g.add_edge('b', 'd') g.add_edge('b', 'e') g.add_edge('e', 'f') g.add_edge('f', 'g') assert g.depth_first_traversal('a') == ['a', 'c', 'b', 'e', 'f', 'g', 'd']
def test_one_loop_depth(): g = SimpleGraph() g.add_edge('a', 'a') assert g.depth_first_traversal('a') == ['a']
def test_one_depth(): g = SimpleGraph() g.add_node('a') assert g.depth_first_traversal('a') == ['a']