示例#1
0
def test_cycles_simple():
    network = Network()
    network.add_node("A")
    network.add_node("B")
    network.add_edge("A", "B")
    network.add_edge("B", "A")
    assert chash(network.cycles()) == chash([("A", "B", "A")])
示例#2
0
def test_cycles_complex():
    network = Network()
    network.add_node("A")
    network.add_node("B")
    network.add_node("C")
    network.add_node("D")

    network.add_edge("A", "B")
    network.add_edge("B", "C")
    network.add_edge("C", "D")
    network.add_edge("D", "A")

    network.add_edge("D", "C")
    network.add_edge("C", "B")
    network.add_edge("B", "D")

    # with open("/home/tag/debug.dot", 'w') as fd:
    #     fd.write(network.dot())

    assert chash(network.cycles()) == chash([
        ('B', 'C', 'B'),
        ('C', 'D', 'C'),
        ('A', 'B', 'D', 'A')
    ])