2020
2121def MaxFlow ():
2222 """MaxFlow simple interface example."""
23- print 'MaxFlow on a simple network.'
23+ print ( 'MaxFlow on a simple network.' )
2424 tails = [0 , 0 , 0 , 0 , 1 , 2 , 3 , 3 , 4 ]
2525 heads = [1 , 2 , 3 , 4 , 3 , 4 , 4 , 5 , 5 ]
2626 capacities = [5 , 8 , 5 , 3 , 4 , 5 , 6 , 6 , 4 ]
@@ -29,17 +29,17 @@ def MaxFlow():
2929 for i in range (0 , len (tails )):
3030 max_flow .AddArcWithCapacity (tails [i ], heads [i ], capacities [i ])
3131 if max_flow .Solve (0 , 5 ) == max_flow .OPTIMAL :
32- print 'Total flow' , max_flow .OptimalFlow (), '/' , expected_total_flow
32+ print ( 'Total flow' , max_flow .OptimalFlow (), '/' , expected_total_flow )
3333 for i in range (max_flow .NumArcs ()):
34- print 'From source %d to target %d: %d / %d' % (
34+ print ( 'From source %d to target %d: %d / %d' % (
3535 max_flow .Tail (i ),
3636 max_flow .Head (i ),
3737 max_flow .Flow (i ),
38- max_flow .Capacity (i ))
39- print 'Source side min-cut:' , max_flow .GetSourceSideMinCut ()
40- print 'Sink side min-cut:' , max_flow .GetSinkSideMinCut ()
38+ max_flow .Capacity (i )))
39+ print ( 'Source side min-cut:' , max_flow .GetSourceSideMinCut () )
40+ print ( 'Sink side min-cut:' , max_flow .GetSinkSideMinCut () )
4141 else :
42- print 'There was an issue with the max flow input.'
42+ print ( 'There was an issue with the max flow input.' )
4343
4444
4545def MinCostFlow ():
@@ -48,7 +48,7 @@ def MinCostFlow():
4848 Note that this example is actually a linear sum assignment example and will
4949 be more efficiently solved with the pywrapgraph.LinearSumAssignement class.
5050 """
51- print 'MinCostFlow on 4x4 matrix.'
51+ print ( 'MinCostFlow on 4x4 matrix.' )
5252 num_sources = 4
5353 num_targets = 4
5454 costs = [[90 , 75 , 75 , 80 ],
@@ -66,15 +66,15 @@ def MinCostFlow():
6666 min_cost_flow .SetNodeSupply (num_sources + node , - 1 )
6767 status = min_cost_flow .Solve ()
6868 if status == min_cost_flow .OPTIMAL :
69- print 'Total flow' , min_cost_flow .OptimalCost (), '/' , expected_cost
69+ print ( 'Total flow' , min_cost_flow .OptimalCost (), '/' , expected_cost )
7070 for i in range (0 , min_cost_flow .NumArcs ()):
7171 if min_cost_flow .Flow (i ) > 0 :
72- print 'From source %d to target %d: cost %d' % (
72+ print ( 'From source %d to target %d: cost %d' % (
7373 min_cost_flow .Tail (i ),
7474 min_cost_flow .Head (i ) - num_sources ,
75- min_cost_flow .UnitCost (i ))
75+ min_cost_flow .UnitCost (i )))
7676 else :
77- print 'There was an issue with the min cost flow input.'
77+ print ( 'There was an issue with the min cost flow input.' )
7878
7979
8080def main ():
0 commit comments