Exemple #1
0
def test_biconnected_eppstein():
    # tests from http://www.ics.uci.edu/~eppstein/PADS/Biconnectivity.py
    G1 = nx.Graph({
        0: [1,2,5],
        1: [0,5],
        2: [0,3,4],
        3: [2,4,5,6],
        4: [2,3,5,6],
        5: [0,1,3,4],
        6: [3,4]})
    G2 = nx.Graph({
        0: [2,5],
        1: [3,8],
        2: [0,3,5],
        3: [1,2,6,8],
        4: [7],
        5: [0,2],
        6: [3,8],
        7: [4],
        8: [1,3,6]})
    assert_true(biconnected.is_biconnected(G1))
    assert_false(biconnected.is_biconnected(G2))
    answer_G2 = [set([1, 3, 6, 8]), set([0, 2, 5]), set([2, 3]), set([4, 7])]
    bcc = list(biconnected.biconnected_components(G2))
    bcc.sort(key=len, reverse=True)
    assert_equal(bcc, answer_G2)
Exemple #2
0
def test_biconnected_eppstein():
    # tests from http://www.ics.uci.edu/~eppstein/PADS/Biconnectivity.py
    G1 = nx.Graph({
        0: [1, 2, 5],
        1: [0, 5],
        2: [0, 3, 4],
        3: [2, 4, 5, 6],
        4: [2, 3, 5, 6],
        5: [0, 1, 3, 4],
        6: [3, 4]
    })
    G2 = nx.Graph({
        0: [2, 5],
        1: [3, 8],
        2: [0, 3, 5],
        3: [1, 2, 6, 8],
        4: [7],
        5: [0, 2],
        6: [3, 8],
        7: [4],
        8: [1, 3, 6]
    })
    assert_true(biconnected.is_biconnected(G1))
    assert_false(biconnected.is_biconnected(G2))
    answer_G2 = [set([1, 3, 6, 8]), set([0, 2, 5]), set([2, 3]), set([4, 7])]
    bcc = list(biconnected.biconnected_components(G2))
    bcc.sort(key=len, reverse=True)
    assert_equal(bcc, answer_G2)
Exemple #3
0
def test_empty_is_biconnected():
    G=nx.empty_graph(5)
    assert_false(biconnected.is_biconnected(G))
    G.add_edge(0,1)
    assert_false(biconnected.is_biconnected(G))
Exemple #4
0
def test_is_biconnected():
    G=nx.cycle_graph(3)
    assert_true(biconnected.is_biconnected(G))
    G.add_cycle([1,3,4])
    assert_false(biconnected.is_biconnected(G))
Exemple #5
0
def test_empty_is_biconnected():
    G = nx.empty_graph(5)
    assert_false(biconnected.is_biconnected(G))
    G.add_edge(0, 1)
    assert_false(biconnected.is_biconnected(G))
Exemple #6
0
def test_is_biconnected():
    G = nx.cycle_graph(3)
    assert_true(biconnected.is_biconnected(G))
    G.add_cycle([1, 3, 4])
    assert_false(biconnected.is_biconnected(G))