Exemple #1
0
def test_del_edge():
    g = WeightedGraph()
    g.add_edge(u"A", u"C")
    g.del_edge(u"A", u"C")
    assert (u"A", u"C") not in g.edges()
    assert u"A" in g.nodes()
    assert u"C" in g.nodes()
    assert g.edgeWeights.pop((u"A", u"C"), False) == False
Exemple #2
0
def test_del_node():
    g = WeightedGraph()
    g.add_edge(u"A", u"C")
    g.del_node(u"A")
    assert u"A" not in g.nodes()
    assert (u"A", u"C") not in g.edges()
Exemple #3
0
def test_add_edge_two_new_nodes():
    g = WeightedGraph()
    g.add_edge(u"A", u"C")
    assert u"A" in g.nodes()
    assert u"C" in g.nodes()
    assert (u"A", u"C") in g.edges()
Exemple #4
0
def test_nodes_empty():
    g = WeightedGraph()
    assert g.nodes() == set()
Exemple #5
0
def test_add_node():
    g = WeightedGraph()
    g.add_node("A")
    assert "A" in g.nodes()