A fast parallel algorithm for minimum-cost small integral flows

# A fast parallel algorithm for minimum-cost small integral flows

## Abstract

We present a new approach to the minimum-cost integral flow problem for small values of the flow. It reduces the problem to the tests of simple multi-variable polynomials over a finite field of characteristic two for non-identity with zero. In effect, we show that a minimum-cost flow of value in a network with vertices, a sink and a source, integral edge capacities and positive integral edge costs polynomially bounded in can be found by a randomized PRAM, with errors of exponentially small probability in running in time and using processors. Thus, in particular, for the minimum-cost flow of value we obtain an algorithm.

## 1 Introduction

The maximum network flow problem is a well known fundamental problem in algorithms and optimization with plenty of important applications [1, 7, 8, 16]. It is known to be -complete even in its integral version provided that the edge capacities are exponentially large in the size of the network [13]. The minimum-cost flow problem is a well known important generalization of the maximum flow problem [1, 8, 10, 16]. The objective is to compute a maximum flow of minimum cost in a directed graph where each edge is assigned a cost. For a flow in a directed graph the cost of is simply

The prospects for designing a fast and processor efficient parallel algorithm, in particular an NC algorithm [19], for maximum integral flow or minimum-cost integral flow are small. The fastest known parallel implementations of general maximum flow and/or minimum-cost flow algorithms achieve solely a moderate speed up and still run in time, where is a positive constant, see [2, 12].

The situation changes when the edge capacities or the supply of flow as well as edge costs are substantially bounded. For example, if the edge capacities and edge costs are bounded by a polynomials in both problems admit RNC algorithms. Then, the maximum integer flow problem admits even an algorithm [17, 18, 20] while the minimum-cost integer flow problem admits an algorithm [18]. At the heart of the aforementioned RNC solutions is the randomized method of detecting a perfect matching by randomly testing Edmonds’ multi-variable polynomials for non-identity with zero [6, 14, 17, 20].

When the flow supply is relatively small, e.g., logarithmic in the size of the network or a poly-logarithmic one, then just an NC implementation of the basic phase in the standard Ford-Fulkerson method [1, 7, 8, 9, 16] yields an NC algorithm ( when the supply is logarithmic) for maximum integer flow that can be extended to an NC algorithm for minimum-cost integer flow (when edge costs are polynomially bounded). The number of processors used corresponds to that required by a shortest path computation.

In this paper, we present a new approach to the minimum-cost integral flow problem for a small value of the flow. We directly associate a simple polynomial over a finite field with the corresponding problem of the existence of mutually vertex disjoint paths of bounded total length, connecting two sets of terminals in a directed graph. By using the idea of monomial cancellation, the latter problem reduces to testing the polynomial over a finite field of characteristic two for non-identity with zero. We combine the DeMillo-Lipton-Schwartz-Zippel lemma [5, 21] on probabilistic verification of polynomial identities with parallel dynamic programming to perform the test efficiently in parallel. Additionally, we use the isolation lemma to construct the minimum-cost flow [17, 20].

In effect, we infer that a minimum-cost flow of value in a network with vertices, a sink and a source, integral edge capacities and positive integral edge costs polynomially bounded in can be found by a randomized PRAM, with errors of exponentially small probability in , running in time and using processors. Thus, in particular, for the minimum-cost flow of value we obtain an algorithm.

Related work. For the RNC algorithms for the related problem of minimum-cost perfect matching see [14, 17, 20]. For the comparison of time and substantial processor complexities of prior RNC algorithms for the minimum-cost flow see page 7 in [18]. The fastest of the reported algorithms is not an one even when the flow supply and thus the edge capacities are logarithmic in the size of the network. The idea of associating a polynomial over a finite field to the sought structure has been already used by Edmonds to detect matching [6] and then in several papers presenting RNC algorithms for perfect matching construction [14, 17, 20]. It appears in several recent papers that also exploit the idea of monomial cancellation [3, 4, 15, 22].

Organization. In the next section, we comment briefly on the basic notation and the model of parallel computation used in the paper. In Section 3, we derive our fast randomized parallel method for detecting the existence of mutually vertex disjoint paths of bounded total length connecting two sets of terminals in a directed graph. In Section 4, we generalize the method to include edge costs which enables us to replace the total length bound with the total cost one. In section 5, we show a straightforward reduction of the minimum-cost integer flow problem parametrized by the flow value to the corresponding disjoint paths problem which enables us to derive our main result on detecting minimum-cost small flows in parallel.

## 2 Terminology

For a natural number we let denote the set of natural numbers in the interval The cardinality of a set will be denoted by

We assume the standard definitions of flow and flow value in a network (directed graph) with integral edge capacities, a distinguished source vertex and a distinguished sink vertex (e.g., see [7]) .

For the definitions of parallel random access machines (PRAM), the classes NC and RNC and the corresponding notions of NC and RNC algorithms, the reader is referred to [19].

The characteristic of a ring or a field is the minimum number of in a sum that yields A finite field with elements is often denoted by

## 3 Connecting vertex-disjoint paths

It is well known that the maximum integral network flow problem with bounded edge capacities corresponds to a disjoint path problem (cf. [7]). In Section 5, we provide an efficient parallel reduction of the minimum-cost integral flow problem parametrized by the flow value to a parametrized disjoint path problem. This section is devoted to a derivation of a fast randomized parallel method for the decision version of the parametrized path problem.

Let be a network in a form of a directed graph with vertices, among them a distinguished set of source vertices and a disjoint distinguished set of sink vertices.

A walk in is a sequence of vertices of such that for is in are in is in The length of the walk is In other words, a walk is just a (not necessarily simple) path starting from a vertex in , having intermediate vertices in and ending at a vertex in

A proper set of walks in is a set of walks of total length , each with a distinct start vertex in and a distinct end vertex in

A signature of a proper set of walks is the pair that is smallest in lexicographic order such that the two walks that start at and respectively intersect, and the first intersection vertex of these two walks is the first intersection vertex of the walk starting from with any walk in

Note that walks in are pairwise vertex disjoint iff the signature of is not defined.

We define the transformation on as follows. If has the signature then switches the suffix of the walk starting at with that of the walk starting at at the first intersection vertex of these two walks. See Fig. 1. Otherwise, if the signature of is not defined then is an identity on

Observe that if the signature of is defined then has the same signature as and The first observation is immediate. To show the second one it is sufficient to note that holds iff transforms the two walks which yield the signature of onto themselves. The latter is however impossible since they have different start vertices and different end vertices. Note also that the walks in have the same total length as those in

It follows that is an involution on sets of proper walks of total length i.e., holds for any proper set of walks of total length .

For the network and let be the family of all proper sets of walks of total length in Assign a distinct variable to each edge in For a walk let be the monomial, where has multiplicity equal to the number of occurrences of in Next, let denote the polynomial

###### Lemma 1

For the network and there is a proper set of mutually vertex-disjoint walks of total length in iff is not identical to zero over a field of characteristic two.

###### Proof

can be partitioned into the family of sets of walks such that and the family of sets of walks such that The polynomial is identical to zero over a field of characteristic two since for each the monomials and contain equal multiplicities of the same variables and so and can be paired. On the other hand, since each set of walks in consist of mutually vertex-disjoint walks, the monomials in the polynomial are in one-to one correspondence with and thus are unique provided that the walks in are simple paths. Now, it is sufficient to observe that mutually vertex-disjoint walks can be always trivially pruned to corresponding mutually vertex-disjoint simple paths.

To warm up, we prove the following lemma on sequential evaluation of

###### Lemma 2

can be evaluated for a given assignment of values over a field of characteristic two in time.

###### Proof

For we consider the family of all sets consisting of walks connecting distinct sources in with the distinct sinks in so that the total length of the walks is exactly Next, we define the polynomial as Note that and

On the other hand, for and we consider the set of walks of length in that start at and end at Let be the polynomial

We have the following recurrence for a nonempty subset of and

 Qp(B)=∑y∈B∑q∈[|B|(n−1)−|B|+1]Qp−q(B∖{y})Qq(x|B|,y).

Next, we have also the following recurrence for and

 Qq(x,z)=∑u∈V∖(X∪Y)&(u,z)∈EQq−1(x,u)x(u,z).

We have also if and otherwise Consequently, we can evaluate all the polynomials by the second recurrence in time.

Now, by using the first recurrence and setting to in the field, we can evaluate all the polynomials in the increasing order of the cardinalities of in time.

By and we conclude that can be evaluated in time.

We can partially parallelize the sequential evaluation of in order to obtain the following lemma.

###### Lemma 3

can be evaluated for a given assignment of values over a field of characteristic two in time by a CREW PRAM using processors.

###### Proof

We generalize the definition of the set and the corresponding polynomial to include arbitrary start vertex , requiring as previously. Then, we can evaluate for and for by the following standard doubling recurrence for

 Qq(x,z)=∑y∈V∖(X∪Y)Q⌈q/2⌉(x,y)Q⌊q/2⌋(y,z)

At the bottom of the recursion, we have if otherwise It follows that all for , and can be evaluated in a bottom-up manner in time by a CREW PRAM using processors.

Recall the first recurrence from the proof of Lemma 2. When the polynomials for and are evaluated, we can evaluate in turn the polynomials , where in phases in the increasing order of the cardinalities of by this recurrence. It can be done in time by a CREW PRAM using processors.

By and we conclude that can be evaluated in time by a CREW PRAM using processors.

The following lemma on polynomial identities verification has been shown independently by DeMillo and Lipton, Schwartz, and Zippel.

###### Lemma 4

[5, 21] Let be a nonzero polynomial of degree over a field of size Then, for …, chosen independently and uniformly at random from the field, the probability that is not equal to zero is at least

Note that the polynomial is of degree not larger than We can use Lemma 4 with a field of characteristic two to obtain a randomized test of the polynomial for not being identical to zero with one side errors. For sufficiently large constant the one side errors are of probability not larger than a constant smaller than By performing such independent tests, the probability of one side errors can be decreased to exponentially small in one.

By Lemma 3, the series of the tests can be performed in time by a PRAM using processors. By Lemma 1, these tests verify if there is a proper set of mutually vertex-disjoint walks of total length in the network . The latter in turn is equivalent to the existence of mutually vertex-disjoint paths of total length connecting with in by the definition of a proper set of walks in Hence, observing that each walk can be trivially pruned to a simple directed path with the same endpoints, we obtain our main result.

###### Theorem 3.1

The problem of whether or not there is a set of mutually vertex-disjoint simple directed paths of total length connecting with in the network can be decided by a randomized CREW PRAM, with one-sided errors of exponentially small probability in running in time and using processors.

## 4 Vertex-disjoint connecting paths of bounded cost

In this section, we shall consider a more general situation where there are a positive integer and a cost function assigning to each of the edges in the network a cost The cost of a walk or a path is simply the sum of the costs of the edges forming it (the cost of an edge is counted the number of times it appears on the walk or path). We would like to detect a proper set of walks in that achieves the minimum cost.

For this reason, we consider the following generalization of the polynomial For let be the set of all proper sets of walks in the edge-costed network that have total cost not greater than Next, for a walk in as previously, let be the monomial which is the product of over the occurrences of edges on The polynomial is defined by

By using the proof method of Lemma 1, we obtain the following counterpart of this lemma for .

###### Lemma 5

For the edge-costed network , there is a proper set of mutually vertex-disjoint walks of total cost in iff is not identical to zero over a field of characteristic two.

Next, we obtain the following counterpart of Lemma 3 for .

###### Lemma 6

can be evaluated for a given assignment of values over a field of characteristic two in time by a PRAM using processors.

###### Proof

The proof reduces to that of Lemma 3. We replace each directed edge of cost in the network by a directed path of length introducing additional vertices. With each edge on such a path, we associate a variable. We assign to the variable associated with the first edge on the path replacing and just of the field to the variables associated with the remaining edges on the path.

The resulting network is of size Let be the family of all proper sets of walks of total cost in the network . We can evaluate the polynomial in parallel analogously as in the proof of Lemma 3. It remains to observe that the value of under the assignment is equal to that of under the aforementioned assignment. ∎

Now, we are ready to derive our main result in this section.

###### Theorem 4.1

The minimum cost of a set of mutually vertex-disjoint simple directed paths connecting with in the network with edge costs in can be computed by a randomized CREW PRAM, with errors of exponentially small probability in running in time and using processors.

###### Proof

The minimum cost of the sought set of vertex-disjoint paths is in Hence, by Lemma 5, it is sufficient to test the polynomials for non-identity with zero for all in parallel. By applying Lemmata 4 and 6 in a manner analogous to the proof of Theorem 3.1, we conclude that it can be done by a randomized CREW PRAM, with one-sided errors of exponentially small in probability, running in time and using
processors. ∎

## 5 Finding vertex-disjoint connecting paths

A straightforward approach of extending our randomized parallel method for deciding if there is a proper set of mutually vertex-disjoint walks (of a bounded total cost) between two sets of vertices of cardinality to include the finding variant could be roughly as follows. In parallel, for each -tuple of respective neighbors of the start vertices in replace the set of start vertices by the -tuple and apply our method recursively to the resulting network. If the test is positive, the first edges on the walks are known, and we can iterate the method. The problem with this approach is that its recursive depth is proportional to the maximum length of a walk in the resulting set of mutually vertex-disjoint walks between and

Also, it is not clear how one could implement a straightforward divide-and-conquer approach of guessing intermediate vertices in order to find a set of mutually-vertex disjoint walks of a given cost efficiently in parallel.

We need more advanced methods to obtain a very fast parallelization of the finding variant. We shall modify the edge cost in the network in order to use the so called isolation lemma in a manner analogous to the RNC method of finding a perfect matching given in [20].

###### Lemma 7

(The isolation lemma [20]). Let be a family of subsets of a set with elements and let be a non-negative integer. Suppose that each element of the set is independently assigned a weight uniformly at random from , and the weight of a subset in is defined as Then, the probability that there is a unique set in of minimum weight is at least

###### Corollary 1

For each of the edges in the network modify its cost to where the weight is drawn uniformly at random from . Then, the probability that there is a unique minimum-cost set of mutually vertex-disjoint paths connecting with in the edge weighted network is at least

###### Proof

To use the isolation lemma, let the underlying set to consist of all edges in the network Next, note that a set of mutually vertex-disjoint paths connecting with achieving a minimum cost consists of simple paths and thus it can be identified with the set of edges on the paths. Let be the family of all sets of mutually vertex-disjoint simple paths connecting with in the network By the setting of new costs solely those sets in that achieved the minimum cost, say under the original costs can achieve a minimum cost under the new costs So, we can set to the aforementioned sub-family of , and define the weight of a set of paths in as the sum of the weights of the edges on the paths in this set in order to use the isolation lemma. By the isolation lemma, there is a unique set in that achieves the minimum weight with the probability at least The corollary follows since each set in has the cost equal to

Throughout the rest of this section, we shall assume that each of the edges in the network is assigned the cost as in Corollary 1 and that

Suppose that we know the minimum cost of a set of mutually vertex-disjoint paths connecting with in the network with the edge costs indicated, and such a minimum-cost set is unique. Then, it is sufficient to show that we can test quickly in parallel if the network with an arbitrary edge removed still contains a set of mutually vertex-disjoint paths connecting with that achieves the minimum cost. By performing the test for each edge of in parallel, we can determine the set of edges forming the unique minimum-cost set of mutually vertex-disjoint paths connecting with .

To carry out these tests, we need to generalize the polynomial to a polynomial , where is an edge in and is a cost constraint from . Let be the family of all proper sets of walks in the network with the edge removed that have total at most (In the total cost of a set of walks, we count the cost of an edge the number of times equal to the sum of the multiplicities of the edge in the walks.)

As in the definition of assign a distinct variable to each edge in and for a walk let be the monomial, where has multiplicity equal to the number of occurrences of in The polynomial is defined by

By using the proof method of Lemma 1, we obtain the following counterpart of this lemma for .

###### Lemma 8

For the edge-costed network with edges, edge and there is a proper set of mutually vertex-disjoint walks of total cost in the network with the edge removed iff is not identical to zero over a field of characteristic two.

Next, we obtain the counterpart of Lemma 3 for following the proof of Lemma 6.

###### Lemma 9

can be evaluated for a given assignment of values over a field of characteristic two in time by a PRAM using processors.

Now, we are ready to derive our main result in this section.

###### Theorem 5.1

There is a randomized PRAM returning almost certainly (i.e., with probability at least , where ) a minimum-cost set of mutually vertex-disjoint paths connecting with in the network with the original edge costs in (iff such a set exists) in time using processors.

###### Proof

We set to, say, and specify the new edge costs in the network drawing the weights uniformly at random from as in Corollary 1. Next, for each we proceed in parallel as follows. For each edge of the network , we test the polynomial for the non-identity with zero by using Lemma 4 and Lemma 9 (we can perform a linear in number of such tests in parallel in order to decrease the probability of the one-sided error to an exponentially small one). Next, we verify if the edges that passed the test positively yield a set of mutually vertex-disjoint paths connecting with . For example, it can be done by checking for each endpoint of the edges outside if it is shared by exactly two of the edges, and then computing and examining the transitive closure of the graph induced by the edges (see [19]). If so, we save the resulting set of paths of total (new) cost By Corollary 1, there is a for which the above procedure will find such a set of paths that achieves the minimum (original) cost with probability at least

## 6 Minimum-cost logarithmic integral flow is in Rnc2

The following lemma is a straightforward generalization of a folklore reduction of maximum integral flow to a corresponding disjoint connecting path problem (for instance cf. [7]) to include minimum-cost integral flow. We shall call a flow proper, if it ships each flow unit along a simple path from the source to the sink.

###### Lemma 10

The problem of whether or not there is a proper integral flow of value and cost from a distinguished source vertex to a distinguished sink vertex in a directed network with vertices. integral edge capacities and edge costs in can be (many-one) reduced to that of whether or not there is set of mutually vertex-disjoint simple directed paths of total cost , where connecting two distinguished sets of vertices in a directed network on vertices in time by a CREW PRAM using processors.

###### Proof

Let be the directed network with integral edge capacities, edges costs in and the distinguished source vertex and sink vertex Since we are interested in a flow of value , we can assume w.l.o.g that all edge capacities do not exceed

We form a directed network on the basis of the network as follows.

Let Next, let be the set of edges in incoming into , and let be the set of edges in leaving For each and we create the vertex Analogously, for each and we create the vertex Furthermore, we direct an edge from each vertex to each vertex . To each such an edge, we assign the cost Also, for each edge of we direct an edge from to for To each such an edge, we assign the cost See Fig. 2.

Let be the set of vertices of the form , and let denote the set of vertices of the form Create an additional set of vertices and from each vertex in direct an edge to each vertex in . Symmetrically, create another additional set of vertices and from each vertex in direct an edge to each vertex in

It is easy to observe that there is a proper integral flow of value and cost from to in the network iff there is a set of mutually vertex-disjoint simple paths of total cost connecting with in the network such that

Now it is sufficient to note that the construction of , and on the basis of easily implemented by a CREW PRAM in -time using processors, where is the number of vertices in

By combining Theorem 3.1 with Lemma 10, we obtain our first main result.

###### Theorem 6.1

The minimum cost of a flow of value in a network with vertices, a sink and a source, integral edge capacities and positive integral edge costs in can be found by a randomized PRAM, with errors of exponentially small probability in running in time and using processors.

By combining in turn Theorem 5.1 with the finding variant of Lemma 10 using exactly the same reduction, we obtain our second main result.

###### Theorem 6.2

There is a randomized PRAM algorithm returning almost certainly a minimum-cost flow of value (iff a flow of value exists) in a network with vertices, a sink and a source, integral edge capacities and edge costs in in time using processors.

###### Corollary 2

The problem of finding a minimum-cost flow of value in a network with vertices, a sink and a source, and integral edge capacities bounded polynomially in admits an algorithm.

## 7 Final remarks

We have resented a new approach to the minimum-cost integral flow problem. In particular, it yields an algorithm when the flow supply is (at most) logarithmic in the size of the network.

All our results can be extended to include undirected networks by a straightforward reduction.

### References

1. R.K. Ahuja, T.L. Magnanti, and J.B. Orlin. Network Flows: Theory, Algorithms, and Applications. Prentice-Hall, Inc., 1993.
2. R.J. Anderson and J.C. Setubal. On the Parallel Implementation of Goldberg’s Maximum Flow Algorithm. Proc. Annual ACM Symposium on Parallel Algorithms and Architectures (SPAA), pp. 168-177, 1992.
3. A. Björklund. Determinant sums for undirected Hamiltonicity. Proc. 51th IEEE Symposium on Foundations of Computer Science (FOCS), pp. 173-182, 2010.
4. A. Björklund, T. Husfeldt and N. Taslaman. Shortest Cycle Through Specified Elements. Proc. Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), 2012.
5. R.A. DeMillo and R.J. Lipton. A probabilistic remark on algebraic program testing. Information Processing Letters 7, pp. 193-195, 1978.
6. J. Edmonds. Systems of distinct representatives and linear algebra. J. Res. Nat. Bur. Standards Sect. Vol. 71B, No. 4, pp. 241-245, 1967.
7. S. Even. Graph Algorithms. Computer Science Press Inc. 1979.
8. J. Edmonds and R.M. Karp. Theoretical improvements in algorithmic efficiency for network flow problems. Journal of the ACM 19(2), pp. 248â264, 1972.
9. L.R. Ford jr. and D.R. Fulkerson. Maximal flow through a network. Can. J. Math 8, pp. 399-404.
10. D.R. Fulkerson. An out-of-Kilter method for minimal cost flow problems. SIAM J. Appl. Math. 9, pp. 18-27.
11. Z. Galil and V. Pan. Improved processor bounds for algebraic and combinatorial problems in RNC. Proc. 26th IEEE Symposium on Foundations of Computer Science (FOCS), pp. 490-495, 1985.
12. A. Goldberg. Parallel Algorithms for Network Flow Problems. In Synthesis of Parallel Algorithms, editor J.H. Reif., Morgan-Kauffman, 1993.
13. L.M. Goldschlager, R.A. Shaw and J. Staples. The Maximum Flow Problem is Log Space Complete for P. Theoretical Computer Science 21(1), pp. 105-111, 1982.
14. R. Karp, E. Upfal, and A. Wigderson. Constructing a perfect matching is in random NC. Combinatorica 6(1), pp. 35-48, 1986.
15. I. Koutis. Faster algebraic algorithms for path and packing problems. Proc. 35th Annual International Colloquium on Automata, Languages and Programming (ICALP), Lecture Notes in Computer Science 5555, pp. 653-664, 2009.
16. E.L. Lawler. Combinatorial optimization: Networks and matroids. Holt, Rinehart and Winston, New York, NY.
17. K. Mulmuley, U.V. Vazirani and V.V. Vazirani. Matching is as Easy as Matrix Inversion. Combinatorica 7(1), pp. 105-113, 1987.
18. J.B. Orlin and C. Stein. Parallel Algorithms for the Assignment and Minimum-Cost Flow Problems. Operations Research Letters, 14, pp. 181-186, 1993.
19. J.H. Reif (editor). Synthesis of Parallel Algorithms. Morgan-Kauffman, 1993.
20. V.V. Vazirani. Parallel Graph Matching. In Synthesis of Parallel Algorithms, editor J.H. Reif., Morgan-Kauffman, 1993.
21. J.T. Schwartz. Fast probabilistic algorithms for verification of polynomial identities. Journal of the ACM 27(4), pp. 701-717, 1980.
22. R. Williams. Finding paths of length in Information Processing Letters 109, pp. 301-338, 2009.
248409