def test_remove_missing_node_raises_undirected(): # given g = UndirectedGraph() g.add_node(1) g.add_node(2) g.add_node(3) # when with pytest.raises(DoesNotExistError): g.remove_node(4)
def test_add_node_already_graph_does_nothing(): # given g = UndirectedGraph() # when g.add_edge(1, 3) g.add_edge(3, 1) g.add_edge(5, 1) g.add_node(3) assert len(g.neighbors(3)) == 1 assert len(g.nodes) == 3
def test_undirected_add_node_and_list(): # given g = UndirectedGraph() # when g.add_node(1) g.add_node("a") g.add_node(42) # then assert set(g.nodes) == {1, 42, "a"}