Exemplo n.º 1
0
def test_directed_edge_connectivity():
    G = nx.cycle_graph(10,create_using=nx.DiGraph()) # only one direction
    D = nx.cycle_graph(10).to_directed() # 2 reciprocal edges
    assert_equal(1, nx.edge_connectivity(G))
    assert_equal(1, nx.local_edge_connectivity(G,1,4))
    assert_equal(1, nx.edge_connectivity(G,1,4))
    assert_equal(2, nx.edge_connectivity(D))
    assert_equal(2, nx.local_edge_connectivity(D,1,4))
    assert_equal(2, nx.edge_connectivity(D,1,4))
Exemplo n.º 2
0
def test_directed_edge_connectivity():
    G = nx.cycle_graph(10, create_using=nx.DiGraph())  # only one direction
    D = nx.cycle_graph(10).to_directed()  # 2 reciprocal edges
    assert_equal(1, nx.edge_connectivity(G))
    assert_equal(1, nx.local_edge_connectivity(G, 1, 4))
    assert_equal(1, nx.edge_connectivity(G, 1, 4))
    assert_equal(2, nx.edge_connectivity(D))
    assert_equal(2, nx.local_edge_connectivity(D, 1, 4))
    assert_equal(2, nx.edge_connectivity(D, 1, 4))
Exemplo n.º 3
0
def select_removal_candidate(graph):
    """
    :type graph: networkx.classes.graph.Graph
    :rtype: tuple
    """
    for u, v in graph.edges_iter():
        if nx.local_edge_connectivity(graph, u, v) > 1:
            return u, v
    return None
Exemplo n.º 4
0
def test_brandes_erlebach():
    # Figure 1 chapter 7: Connectivity
    # http://www.informatik.uni-augsburg.de/thi/personen/kammer/Graph_Connectivity.pdf
    G = nx.Graph()
    G.add_edges_from([(1,2),(1,3),(1,4),(1,5),(2,3),(2,6),(3,4),
                    (3,6),(4,6),(4,7),(5,7),(6,8),(6,9),(7,8),
                    (7,10),(8,11),(9,10),(9,11),(10,11)])
    assert_equal(3,nx.local_edge_connectivity(G,1,11))
    assert_equal(3,nx.edge_connectivity(G,1,11))
    assert_equal(2,nx.local_node_connectivity(G,1,11))
    assert_equal(2,nx.node_connectivity(G,1,11))
    assert_equal(2,nx.edge_connectivity(G)) # node 5 has degree 2
    assert_equal(2,nx.node_connectivity(G))
Exemplo n.º 5
0
def test_brandes_erlebach():
    # Figure 1 chapter 7: Connectivity
    # http://www.informatik.uni-augsburg.de/thi/personen/kammer/Graph_Connectivity.pdf
    G = nx.Graph()
    G.add_edges_from([(1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 6), (3, 4),
                      (3, 6), (4, 6), (4, 7), (5, 7), (6, 8), (6, 9), (7, 8),
                      (7, 10), (8, 11), (9, 10), (9, 11), (10, 11)])
    assert_equal(3, nx.local_edge_connectivity(G, 1, 11))
    assert_equal(3, nx.edge_connectivity(G, 1, 11))
    assert_equal(2, nx.local_node_connectivity(G, 1, 11))
    assert_equal(2, nx.node_connectivity(G, 1, 11))
    assert_equal(2, nx.edge_connectivity(G))  # node 5 has degree 2
    assert_equal(2, nx.node_connectivity(G))