Beispiel #1
0
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)
Beispiel #2
0
def test_remove_node_removes_edges_too_undirected():
    # given
    g = UndirectedGraph()

    # when
    g.add_edge(1, 3)
    g.add_edge(3, 1)
    g.add_edge(5, 1)
    g.add_edge(1, 6)
    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