def test_del_node(): from simple_graph import SimpleGraph new_graph = SimpleGraph() new_graph.add_edge('A', 'B', 25) new_graph.add_edge('B', 'A', 10) new_graph.del_node('A') assert new_graph.graph == {'B': {}}
def test_sg_del_node_error(): """Ensure del_node throws IndexError if called with node not in graph.""" from simple_graph import SimpleGraph test_sg = SimpleGraph() with pytest.raises(IndexError) as message: test_sg.del_node("node_a") assert "That node is not in the graph." in str(message)
def test_sg_del_node(): """Ensure correct node is deleted, and all its edges are removed.""" from simple_graph import SimpleGraph test_sg = SimpleGraph() test_sg.add_edge("a", "c") test_sg.add_edge("b", "c") test_sg.add_edge("c", "b") test_sg.del_node("c") assert "c" not in test_sg.edges()
def test_del_node_error(): from simple_graph import SimpleGraph new_graph = SimpleGraph() with pytest.raises(KeyError): new_graph.del_node('A')
def test_del_node_edge(): from simple_graph import SimpleGraph instance = SimpleGraph() instance.add_edge('waffles', 'waffles2') instance.del_node('waffles2') assert instance.graph_dict == {'waffles': {}}
def test_del_node(): from simple_graph import SimpleGraph instance = SimpleGraph() instance.add_node("waffles") instance.del_node('waffles') assert instance.graph_dict == {}