def test_del_error(): """error raised when non-existant value deleted""" g = SimpleGraph() g.add_node('a') g.add_node('b') g.add_node('c') g.add_edge('a', 'c') g.add_edge('a', 'b') with pytest.raises(KeyError): g.del_node('p')
def test_del_nodes(): """nodes are deleted""" g = SimpleGraph() g.add_node('a') g.add_node('b') g.add_node('c') g.add_edge('a', 'c') g.add_edge('a', 'b') g.del_node('a') assert 'a' not in g.nodes() assert g.has_node('a') is False
def test_weighted_edges_with_node_delete(): g = SimpleGraph() g.add_edge('a', 'b', 5) g.add_edge('a', 'c', 2) g.del_node('c') assert g.dict_graph['a'] == {'b': 5}