Information Processing Letters 110 (2010) 168–170
Contents lists available at ScienceDirect
Information Processing Letters www.elsevier.com/locate/ipl
On finding fundamental cut sets Sanjeev Saxena Dept. of Computer Science and Engineering, Indian Institute of Technology, Kanpur, India 208 016
a r t i c l e
i n f o
a b s t r a c t
Article history: Received 4 May 2009 Received in revised form 20 October 2009 Accepted 25 November 2009 Available online 27 November 2009 Communicated by B. Doerr
In this paper a linear time algorithm is proposed for preprocessing the edges of a graph. After preprocessing (in linear time), the fundamental cut set of any tree edge can be determined in time proportional to the size of that cut set. © 2009 Elsevier B.V. All rights reserved.
Keywords: Graph algorithms Fundamental cut sets Algorithms
1. Introduction If T is spanning tree of a graph G = ( V , E ), then deletion of any edge e of T will split T into two parts. The minimal set M ⊆ E − T of non-tree edges whose removal (along with e) splits the graph into two parts is called the fundamental cut set of e [6,4,2,7]. Finding cut sets have applications in analysis of networks, transportation networks, vulnerability of communication systems, etc. [4]. If f is a non-tree edge of T then addition of f to T will result in a cycle, called the fundamental cycle of f . Given a tree, rooting the tree is the only preprocessing required for finding the fundamental cycle of a non-tree edge, in time proportional to the length of the cycle. Once, a tree has been rooted and each node knows its parent, then given any non-tree edge (u , v ), the fundamental cycle of (u , v ) can be found by climbing up the tree simultaneously from u and v till we reach a previously reached vertex (this can be done by putting marks which will be later removed). The time taken by the process will be proportional to the length of the cycle. In this paper, we consider the problem of preprocessing the non-tree edges to answer fundamental cut set queries.
E-mail address:
[email protected]. 0020-0190/$ – see front matter doi:10.1016/j.ipl.2009.11.014
© 2009 Elsevier B.V.
All rights reserved.
If (u , v ) is a tree edge with u as the parent of v, denoted by u = p [ v ], then all non-tree edges exactly one of whose end point is a descendant of v and the other is not a descendant of v will be in the cut set of the edge (u , v ) (or equivalently ( v , p [ v ])). If we examine each edge in turn, the time taken to find a cut set will at least be proportional to the number of non-tree edges. It is also known [6] that a tree edge e is in the fundamental cycle of a non-tree edge g if and only if the non-tree edge g is in the fundamental cut set of e. Thus, we can determine all fundamental cut sets by determining all fundamental cycles. Instead of determining all fundamental cut sets, in this paper, a method is proposed which processes the non-tree edges, so as to determine only the required cut set in time proportional to the size of that cut set. The preprocessing of the non-tree edges takes linear time and space. Earlier, Thorup [11, Lemma 23] has shown that using Top trees, the edges in the fundamental cut set can be listed in O (log n) times the number of edges in the cut set. Size of all cut sets can be Ω(nm). Consider a graph with n nodes {1, 2, . . ., n}, in which the tree T consists of edges (i , i + 1). And m = n − 2 non-tree edges are (1, j ) for 2 < j n. The cut set of the ith edge (i , i + 1) will contain n − i non-tree edges (1, j ) for i + 1 j n. In particular, the cut set of the edge (n − 1, n) just has one non-tree edge (1, n).
S. Saxena / Information Processing Letters 110 (2010) 168–170
For another example, to a complete graph of n − 1 vertices add a new vertex n and two new edges (1, n) and (n − 1, n). Let the tree again consist of edges (i , i + 1). Then, for i n − 2, the cut set of the edge (i , i + 1) will have i (n − 1 − i ) non-tree edges (k, r ) with k i and i < r < n. Again, the size of all cut sets is Ω(mn) = Ω(n3 ), where as the cut set of the edge (n − 1, n) will again have just one non-tree edge (1, n). This motivates the result in this paper. 2. Algorithm We will first root the spanning tree T (at any vertex). As a result each vertex v (except the root) will know its parent p [ v ]. As all the tree edges are between a vertex and its parent, the problem is For any given vertex v ∈ V , we need to find the fundamental cut set of the edge joining v to its parent p [ v ]. Let us number the vertices of the tree in preorder [1] and let pre( v ) denote the preorder number of v and desc( v ) the number of descendants of vertex v with respect to the spanning tree T of G. We will use α ( v ) to denote the quantity pre( v ) + desc( v ) [3]. From the definition of preorder numbering, any descendant w of v will have a preorder number which will be greater than the preorder number of v but is not more than pre( v )+ desc( v ), or pre( v ) < pre( w ) α ( v ) [1, p. 55]. Any non-descendant of v will either have a preorder number which is either less than pre( v ) or greater than α ( v ). Then,
E 1 ( v ) = (a, b): 1 pre(a) < pre( v ), pre( v ) pre(b) α ( v ) and (a, b) ∈ E − T
is exactly the set of non-tree edges for which the first endpoint (one with smaller preorder number) has a preorder number less than pre( v ) and the second endpoint (one with the larger preorder number) is a descendant of v. Similarly,
E 2 ( v ) = (a, b): pre( v ) pre(a) α ( v ), pre(b) > α ( v ) and (a, b) ∈ E − T
is the set of non-tree edges for which the second endpoint has a preorder number greater than α ( v ) and the first endpoint is a descendant of v. All the edges in the set E 1 ( v ) ∪ E 2 ( v ) will be in the fundamental cut set of v, as these are exactly the set of all non-tree edges joining any descendant of v to a nondescendant. We are to report all edges in this set. To compute E 1 ( v ) and E 2 ( v ) in a “symmetrical” manner, for each non-tree edge (c , d) we will create another copy (d, c ). Now, we do not have to keep track of the relative ordering of preorder numbers. In other words, we only need to report those edges whose first endpoint c is in the range, which can be either the point b in E 1 ( v ) or the point a in E 2 ( v ), and the other endpoint d is not in the range.
169
As only one endpoint is in the range, no edge can be put in both E 1 ( v ) and E 2 ( v ), or there will be no “duplicates”. Let us interpret each edge (u , v ) as a point in the plane, with x-coordinate as pre(u ) and y-coordinate as pre( v ). Edge e will be in the cut set of ( v , p [ v ]) if and only if, the first point (the x-coordinate) is in the range (pre( v ), α ( v )) and the y-coordinate is either less than pre( v ) or more than α ( v ). Berkman et al. [5] have shown that an array A [1 : n] can be preprocessed in linear time to answer queries of the following type in constant time. For 1 i , j n find the smallest item in A [i ], A [i + 1], . . . , A [ j − 1], A [ j ] (which we will abbreviate to A [i : j ]). 2.1. Preprocessing First in O (n) time, the tree is rooted and the preorder number and the number of descendants of each node are found. Then, for each non-tree edge (u , v ) we create a copy ( v , u ), this will take O (m − n) time. We will interpret each edge (u , v ) as a point with x-coordinate pre(u ) and y-coordinate as pre( v ) in the plane. We take all the non-tree edges (both copies), viewed as points in the plane, and sort all the points on x-coordinates. As all points have integer coordinates, we can sort the points using bucket sort in linear time [1]. To avoid binary search we also create a look up table which will give the location of the first (and the last) point, in the sorted order, with x-coordinate u = pre(u ). Thus, if (u , v ) is the first point in the sorted list with the x-coordinate as u then we make First(u ) = pos(u , v ) where pos(u , v ) is the position of point (u , v ) in the sorted list. Similarly the array Last( ) is computed. Then we look at the sorted list of points and process (only) the y-coordinates for range minima and range maxima queries [5]. 2.2. Reporting cut sets Let us assume that we have to find the fundamental cut set of ( v , p [ v ]). We use the preorder number of v and the number of descendants to find α ( v ) = pre( v ) + desc( v ). Now, we “form” a query
pre( v ), α ( v ) .
Let i = First(pre( v )) be the index of the first point with x-coordinate pre( v ) and let j = Last(α ( v )) be the index of the last point with x-coordinate α ( v ). Clearly we want all those edges between the positions i and j provided the y-coordinate is either less than pre( v ) or more than α ( v ). For an overview of the algorithm, let us assume that we carry out the range minima and the range maxima queries on [i : j ]. And let k (respectively k ) be the index of the item with the minimum (respectively the maximum) y-coordinate of points between the locations i and j. If there is a point with y-coordinate less than pre( v ) then the smallest value yk (the y-coordinate of point at position k) must have a value less than pre( v ). Similarly, if
170
S. Saxena / Information Processing Letters 110 (2010) 168–170
there is a point with y-coordinate more than α ( v ) then the largest value yk will be more than α ( v ). In more detail, we use a method similar to that used to answer three-sided range queries [10,9,8], where we have to find all points with x-coordinate between i and j and y-coordinate greater than k. In rest of the algorithm, for simplicity, we will assume that each vertex is indexed by its preorder number. Thus, we need not distinguish between the numbers v and pre( v ). We can find the values k and k in O (1) time, after preprocessing [5], and if (say) yk
• i and k − 1, • k + 1 and j.
• i and k − 1, • k + 1 and j. Again as each step takes O (1) time, and in each step, except the last one, we are finding one point, the algorithm will take time linear in the size of the fundamental cut set. A procedure reportLarger can be defined in a similar manner. Acknowledgements I will like to thank the referees for a careful reading of the manuscript, and for their critical comments and suggestions. Thanks also to Surender Baswana for bringing Ref. [11] to my notice. References
As each step takes O (1) time, and in each step, except the last one, we are finding one point, the algorithm will take time linear in the size of the fundamental cut set. Formally, the algorithm is: reportSmaller(i , j , lowerLimit) { k = rangeMinima[i : j ] if yk > lowerLimit then return report point (xk , yk ) if i k − 1 reportSmaller(i , k − 1, lowerLimit) if j k + 1 reportSmaller(k + 1, j , lowerLimit) }
[1] A.V. Aho, J.E. Hopcroft, J.D. Ullman, The Design and Analysis of Computer Algorithms, Addison–Wesley, 1974. [2] R.K. Ahuja, T.L. Magnanti, J.B. Orlin, Network Flows, Theory Algorithms and Applications, Prentice-Hall, Englewood Cliffs, NJ, 1993. [3] S. Banerjee, S. Saxena, Parallel algorithms for finding the most vital edge in weighted graphs, J. Parallel Distrib. Comput. 46 (1) (October 10, 1997) 101–104. [4] A. Gibbons, Algorithmic Graph Theory, Cambridge University Press, 1985. [5] O. Berkman, B. Schieber, U. Vishkin, Optimal doubly logarithmic parallel algorithms based on finding all nearest smaller values, J. Algorithms 14 (1993) 344–370. [6] N. Deo, Graph Theory with Applications to Engineering and Computer Science, Prentice-Hall, 1974. [7] D.C. Kozen, The Design and Analysis of Algorithms, Springer, 1992.
The procedure is called with i = First(pre( v )), j = Last(α ( v )) and lowerLimit = pre( v ). We similarly find the points with y-coordinate more than α ( v ). If yk > α ( v ), then we first report the edge (xk , yk ) to be in the cut set and recursively find the points with y-coordinates more than tions
α ( v ) in between the posi-
[8] C. Makris, A.K. Tsakaldis, Algorithms for three-dimensional dominance searching in linear space, Inform. Process. Lett. 66 (1998) 277– 283. [9] S. Saxena, Dominance made simple, Inform. Process. Lett. 109 (2009) 419–421. [10] Q. Shi, J. JaJa, Fast algorithms for 3-D dominance reporting and counting, Internat. J. Found. Comput. Sci. 15 (2004) 673–684. [11] M. Thorup, Fully-dynamic min-cut, Combinatorica 27 (2007) 91–127.