Example #1
0
    def test_pyramid(self):
        N = 15 # this is slow, due to conversion to anti-parallel digraphs
        G = gen_pyramid(N)

        nst.assert_almost_equal(nx.vanilla_push_relabel_maxflow(G, (0, 0), 't')[0], 1.)
        nst.assert_almost_equal(nx.relabel_to_front_maxflow(G, (0, 0), 't')[0], 1.)
        nst.assert_almost_equal(nx.highest_label_maxflow(G, (0, 0), 't')[0], 1.)
Example #2
0
    def test_pyramid(self):
        N = 10
        #        N = 100 # this gives a graph with 5051 nodes
        G = gen_pyramid(N)

        nst.assert_almost_equal(nx.vanilla_push_relabel_maxflow(G, (0, 0), "t")[0], 1.0)
        nst.assert_almost_equal(nx.relabel_to_front_maxflow(G, (0, 0), "t")[0], 1.0)
        nst.assert_almost_equal(nx.highest_label_maxflow(G, (0, 0), "t")[0], 1.0)
Example #3
0
 def test_complete_graph(self):
     N = 5
     G = nx.complete_graph(N)
     for (u, v) in G.edges():
         G[u][v]['capacity'] = 5
     
     nst.assert_equal(nx.vanilla_push_relabel_maxflow(G, 1, 2)[0], 5 * (N - 1))
     nst.assert_equal(nx.relabel_to_front_maxflow(G, 1, 2)[0], 5 * (N - 1))
     nst.assert_equal(nx.highest_label_maxflow(G, 1, 2)[0], 5 * (N - 1))
Example #4
0
def compare_dictionary_flows_vanilla_push_relabel(G, s, t, solnFlows, capacity='capacity'):
    flowValue, flowDict = nx.vanilla_push_relabel_maxflow(G, s, t, capacity)
    nst.assert_equal(flowDict, solnFlows)
Example #5
0
def compare_value_flows_vanilla_push_relabel(G, s, t, solnValue, capacity='capacity'):
    flowValue, flowDict = nx.vanilla_push_relabel_maxflow(G, s, t, capacity)
    nst.assert_equal(flowValue, solnValue)
    nst.assert_equal(nx.min_cut(G, s, t, capacity), solnValue)
    nst.assert_equal(nx.max_flow(G, s, t, capacity), solnValue)