Beispiel #1
0
def test_biconnected_components2():
    G=nx.Graph()
    G.add_cycle('ABC')
    G.add_cycle('CDE')
    G.add_cycle('FIJHG')
    G.add_cycle('GIJ')
    G.add_edge('E','G')
    comps = list(biconnected.biconnected_component_edges(G))
    answer = [
        [tuple('GF'),tuple('FI'),tuple('IG'),tuple('IJ'),tuple('JG'),tuple('JH'),tuple('HG')],
        [tuple('EG')],
        [tuple('CD'),tuple('DE'),tuple('CE')],
        [tuple('AB'),tuple('BC'),tuple('AC')]
        ]
    assert_components_equal(comps,answer)
Beispiel #2
0
def test_biconnected_components1():
    # nxgraph example from
    # http://www.ibluemojo.com/school/articul_algorithm.html 
    edges=[(0,1),
           (0,5),
           (0,6),
           (0,14),
           (1,5),
           (1,6),
           (1,14),
           (2,4),
           (2,10),
           (3,4),
           (3,15),
           (4,6),
           (4,7),
           (4,10),
           (5,14),
           (6,14),
           (7,9),
           (8,9),
           (8,12),
           (8,13),
           (10,15),
           (11,12),
           (11,13),
           (12,13)]   
    G=nx.Graph(edges)
    pts = set(biconnected.articulation_points(G))
    assert_equal(pts,set([4,6,7,8,9]))
    comps = list(biconnected.biconnected_component_edges(G))
    answer = [
        [(3,4),(15,3),(10,15),(10,4),(2,10),(4,2)],
        [(13,12),(13,8),(11,13),(12,11),(8,12)],
        [(9,8)],
        [(7,9)],
        [(4,7)],
        [(6,4)],
        [(14,0),(5,1),(5,0),(14,5),(14,1),(6,14),(6,0),(1,6),(0,1)],
        ]
    assert_components_equal(comps,answer)
Beispiel #3
0
def test_biconnected_components2():
    G = nx.Graph()
    G.add_cycle('ABC')
    G.add_cycle('CDE')
    G.add_cycle('FIJHG')
    G.add_cycle('GIJ')
    G.add_edge('E', 'G')
    comps = list(biconnected.biconnected_component_edges(G))
    answer = [[
        tuple('GF'),
        tuple('FI'),
        tuple('IG'),
        tuple('IJ'),
        tuple('JG'),
        tuple('JH'),
        tuple('HG')
    ], [tuple('EG')], [tuple('CD'), tuple('DE'),
                       tuple('CE')], [tuple('AB'),
                                      tuple('BC'),
                                      tuple('AC')]]
    assert_components_equal(comps, answer)
Beispiel #4
0
def test_biconnected_components1():
    # graph example from
    # http://www.ibluemojo.com/school/articul_algorithm.html
    edges = [(0, 1), (0, 5), (0, 6), (0, 14), (1, 5), (1, 6), (1, 14), (2, 4),
             (2, 10), (3, 4), (3, 15), (4, 6), (4, 7), (4, 10), (5, 14),
             (6, 14), (7, 9), (8, 9), (8, 12), (8, 13), (10, 15), (11, 12),
             (11, 13), (12, 13)]
    G = nx.Graph(edges)
    pts = set(biconnected.articulation_points(G))
    assert_equal(pts, set([4, 6, 7, 8, 9]))
    comps = list(biconnected.biconnected_component_edges(G))
    answer = [
        [(3, 4), (15, 3), (10, 15), (10, 4), (2, 10), (4, 2)],
        [(13, 12), (13, 8), (11, 13), (12, 11), (8, 12)],
        [(9, 8)],
        [(7, 9)],
        [(4, 7)],
        [(6, 4)],
        [(14, 0), (5, 1), (5, 0), (14, 5), (14, 1), (6, 14), (6, 0), (1, 6),
         (0, 1)],
    ]
    assert_components_equal(comps, answer)