コード例 #1
0
def test_multigraph():
    G = nx.cycle_graph(4)
    M = nx.MultiGraph(G.edges())
    M.add_edges_from(G.edges())
    M.remove_edge(1, 2)
    A, B = nx.kernighan_lin_bisection(M)
    assert_partition_equal([A, B], [{0, 1}, {2, 3}])
コード例 #2
0
def test_multigraph():
    G = nx.cycle_graph(4)
    M = nx.MultiGraph(G.edges())
    M.add_edges_from(G.edges())
    M.remove_edge(1, 2)
    A, B = nx.kernighan_lin_bisection(M)
    assert_partition_equal([A, B], [{0, 1}, {2, 3}])
コード例 #3
0
def test_too_many_blocks():
    G = nx.barbell_graph(3, 0)
    partition = ({0, 1}, {2}, {3, 4, 5})
    nx.kernighan_lin_bisection(G, partition)
コード例 #4
0
def test_non_disjoint_partition():
    G = nx.barbell_graph(3, 0)
    partition = ({0, 1, 2}, {2, 3, 4, 5})
    nx.kernighan_lin_bisection(G, partition)
コード例 #5
0
def test_partition():
    G = nx.barbell_graph(3, 0)
    C = nx.kernighan_lin_bisection(G)
    assert_partition_equal(C, [{0, 1, 2}, {3, 4, 5}])
コード例 #6
0
def test_too_many_blocks():
    G = nx.barbell_graph(3, 0)
    partition = ({0, 1}, {2}, {3, 4, 5})
    nx.kernighan_lin_bisection(G, partition)
コード例 #7
0
def test_non_disjoint_partition():
    G = nx.barbell_graph(3, 0)
    partition = ({0, 1, 2}, {2, 3, 4, 5})
    nx.kernighan_lin_bisection(G, partition)
コード例 #8
0
def test_partition():
    G = nx.barbell_graph(3, 0)
    C = nx.kernighan_lin_bisection(G)
    assert_partition_equal(C, [{0, 1, 2}, {3, 4, 5}])
コード例 #9
0
def kernighan_lin(G):
    kl = nx.kernighan_lin_bisection(G,partition=2)
    print(kl)