def test_remove_missing_node_raises_directed(): # given g = DirectedGraph() g.add_node(1) g.add_node(2) g.add_node(3) # when with pytest.raises(DoesNotExistError): g.remove_node(4)
def test_remove_node_removes_edges_too_directed(): # given g = DirectedGraph() # when g.add_edge(1, 3) g.add_edge(3, 1) g.add_edge(5, 1) g.add_edge(1, 6) g.add_edge(1, 1) g.remove_node(1) assert (1, 3) not in g.edges assert (3, 1) not in g.edges assert (5, 1) not in g.edges assert len(g.edges) == 0