def test_shortest_augmenting_path_two_phase(self): k = 5 p = 1000 G = nx.DiGraph() for i in range(k): G.add_edge('s', (i, 0), capacity=1) G.add_path(((i, j) for j in range(p)), capacity=1) G.add_edge((i, p - 1), 't', capacity=1) assert_equal( nx.shortest_augmenting_path_value(G, 's', 't', two_phase=True), k) assert_equal( nx.shortest_augmenting_path_value(G, 's', 't', two_phase=False), k)
def test_shortest_augmenting_path_two_phase(self): k = 5 p = 1000 G = nx.DiGraph() for i in range(k): G.add_edge('s', (i, 0), capacity=1) G.add_path(((i, j) for j in range(p)), capacity=1) G.add_edge((i, p - 1), 't', capacity=1) assert_equal(nx.shortest_augmenting_path_value( G, 's', 't', two_phase=True), k) assert_equal(nx.shortest_augmenting_path_value( G, 's', 't', two_phase=False), k)
def test_gl1(self): G = read_graph('gl1') s = 1 t = len(G) validate_flows(G, s, t, 156545, *nx.ford_fulkerson(G, s, t)) validate_flows(G, s, t, 156545, nx.preflow_push_value(G, s, t), nx.preflow_push_flow(G, s, t)) validate_flows( G, s, t, 156545, nx.shortest_augmenting_path_value(G, s, t, two_phase=False), nx.shortest_augmenting_path_flow(G, s, t, two_phase=False)) validate_flows(G, s, t, 156545, nx.shortest_augmenting_path_value(G, s, t, two_phase=True), nx.shortest_augmenting_path_flow(G, s, t, two_phase=True))
def test_wlm3(self): G = read_graph('wlm3') s = 1 t = len(G) validate_flows(G, s, t, 11875108, *nx.ford_fulkerson(G, s, t)) validate_flows(G, s, t, 11875108, nx.preflow_push_value(G, s, t), nx.preflow_push_flow(G, s, t)) validate_flows( G, s, t, 11875108, nx.shortest_augmenting_path_value(G, s, t, two_phase=False), nx.shortest_augmenting_path_flow(G, s, t, two_phase=False)) validate_flows( G, s, t, 11875108, nx.shortest_augmenting_path_value(G, s, t, two_phase=True), nx.shortest_augmenting_path_flow(G, s, t, two_phase=True))