Information Processing Letters 38 (1991) 117-121 North-Holland
17 May 1991
rare David Fernbdez-Baca
r
* and Mark A. Williams * *
Department of Computer Science, Iowa State University, Ames, IA 5001 I, USA Communicated by T. Lengauer Received 19 October 1990 Revised 12 February 1991 Keywords: Analysis of algorithms, combinatorial problems, design of algorithms, graphs, matroids
I. Introduction
Several researchers have proposed models for succinctly representing graphs and other structures [1,4,6,8,10,11]. In all of these models, it is possible to encode a large structure using a description whose size is polylogarithmic in the size of the structure, thus allowing considerable savings of storage space. It is natural to ask whether one can speed up the processing of a graph by working with a succinct description of the graph rather than with the graph itself. The answer is often negative in that even polynomially-solvable problems become intractable when inputs are succinctly described (see, e.g., [1,4,1 I]). The hierarchical graph model of Lengauer [6,8] is a notable exception. There is apparently no correlation between hierarchical and nonhierarchical complexities of graph problems. Certain polynomially-solvable problems remain polynomially-solvable in the hierarchical model [6,8], while others become PSPACE-complete [7]. A more fruitful approach might be to look for families of graph problems whose hierarchical versions are polynomially solvable. In this paper we characterize two such families. Both are problems of finding the cost of an optimum base of a matroid whose circuits are
* Supported in part by NSF Grant CCR-8909626. * * Supported by an IBM Graduate Fellowship. Current address: IBM Corporation, Poughkeepsie, NY 12601, USA. 0020-0190/91/$03.50
the subgraphs homeomorphic from some member of a finite set of graphs [9]. Our results generalize Lengauer’s work on minimum spanning forests [6]. This paper is organized as follows. In Section 2, we review hierarchical graphs and matroids. In Section 3, we describe a hierarchical algorithm for computing optimum bases of certain matroids defined on graphs. In Section 4, we introduce the two families of matroids alluded to earlier, and present polynomial-time algorithms for determining costs of their optimum bases.
2. Preliminaries
All graphs are assumed to be undirected and have zero or more distinguished vertices, called pins. A pendant vertex is a vertex of degree one. Two edges are in series if they share a degree-two vertex. A loop is isolated if its endpoint has degree two. 2. I. Hierarchical graphs [6,8] Let H be a graph and L = [(a,, b,), . . . , (ar, br)] a list of pairs where a,, . . . , a, are distinct vertices of H, and b,, . . . , b, are the pins of G. L is called a gluing list, and H and L are compatible with G. The graph J = H o,_G, the result of gluing G onto H using L, is obtained either as the disjoint union of G and H, if L is
9 ‘ence Publishers B.V. (North-Holland) 0 1991 - Elsevier xt,
117
Volume 38, Number 3
INFORMATION PROCESSING LETTERS
empty, or, if L is not empty, by identifying a, and b, for 1 4 i < r. The pins of J are those of H. The environment of graph G, denoted Env(G), is the set of all graph and gluing list pairs (H, L) such that H and L are compatible with G. We shall be dealing with graphs built from multiple copies of other graphs. In order to generate distinct symbols for subgraphs, edges, and vertices from these copies, we use the following concatenation operation. Let s and t be strings. Denote by s q t the concatenation of s and t where the division between s and t is not lost. For For a graph G a set Al s=A= {sma: aEA}. whose pins are P c V(G), s = G is a graph with edge set s •BE(G) and vertex set P U s 0
A hierarchical graph r = (G,, . . . , G,,) is a finite list of graphs called cells. For each i, V(Gi) is partitioned into pins, terminals, and nonterminals. G, has pi pins whose names are the integers 1, . . . , p,. N, denotes the set of nonterminals of Gi. Each nonterminal of Gi has a name of the form t, where I is an integer, and t, its type, is a symbol in the set {G,, . . . , Gi_, }. A nonterminal I q G, has pi incident edges, each labeled with the name of a unique pin of Gj. Edges between nonterminals are not permitted. For 1 < i < n, c = (G , , . . . , G, ) is a hierarchical graph whose expansion, X(c), is constructed as follows: Set X(c) = G,. For each nonterminal u = 1 G, of Gi such that O(l) ,‘a’, u( p,) are the vertices of 6, adjacent to u, and where, for 1 < m
X(T,):=(X(r,)-u)o,hX(r,),
17 May 1991
S, called independent sets, that satisfy the following axioms [l]: (1) lebE 1, (2) if AEI and BcA, then BEZ, and (3) for any A G S, all maximally independent subsets of A have the same cardinality. Maximally independent subsets of S are bases of M, minimally dependent subsets are circuits of M. Let W be the set of bases of M. Then, the set W*={S-A: A~W}isthesetofbasesofthe dual matroid M* of M. The circuits of M* are called cocircuits of M. Let A E S. M f A, the restriction of M to A, is a matroid with domain A whose independent sets are the subsets of A that belong to I. M - A, the result of deleting A from M, is the matroid M t (S - A). M/A, the result of contracting A from M, is a matroid with domain S - A. For WE S A, W is an independent set of M/A if and only if W’JB~IforsomebaseBofMtA. Assume that jV has an integer or real-valued cost function c defined on its domain. We can find a minimum cost base of A4 by using a variant, presented by Lawler [5], of the greedy algorithm. The procedure, which we call L-Greedy, starts with B :=fl and carries out either of the following steps, in any order, until neither step applies: Delete.
Contract.
Select a circuit of M and let e be an element of highest cost in the circuit. Set M:= M-e. Select a cocircuit of M and let e be the element of lowest cost in the cocircuit. Set M := M/e and B := B U e.
where
Note that every edge (vertex) of X(c) has a unique name. Denote X(r,) by X(T). In the worst case, X(r) is of size exponential in the size of I’. 2.2. Matroids A matroid M = (S, I) is a finite set of elements S, called the domain, and a family I of subsets of 118
Theorem 2.1. The set B computed by L-Greedy is an optimum base of M. Furthermore, for any optimum base F of M, there is a valid execution sequence of L-Greedy such that B = F. Corollary 2.2. For any matroid M = (S, I ), any eES, andany WES-e: (i) if e is a highest cost member of some circuit of M, then W is an optimum base of M - e if and only if W is an optimum base of M, (ii) if e is a lowest cost member of some cocircuit
Volume 38, Number 3
INFORMATION PROCESSING LETTERS
of M, then W is an optimum base of M/e if and on/y if W U e is an optimum base of M.
efinition 3.1. Let (G, A) be any pair, and let G’ be obtained from some subgraph J of G by contracting C E E(J). The pairs (G, A) and (G’, A U
3. A greedy algorithm for hierarchical graphs Let JI be a class of matroids defined on the edge sets of graphs. For a particular graph G, let J?(G) be the matroid of .M associated with G. Here we present algorithm H-Greedy, which, given I’, returns an optimum base of M( X( r)). H-Greedy manipulates pairs of the form (G, E), where G is a graph and E is a set of edges disjoint from E(G). For a pair (G, E), let s=(G, E) = (s q G, s I E). The graph and edge set of a pair R will be denoted by R.G and R-E, respectively. Let Env(R) be the set of all (S, L) such that (S.G, L) E Env( KG). Pair composition is defined as follows: R Q=(R.GQ.G,
R.EuS.E).
The algorithm deletes (contracts) edges e satisfying condition HGl (HG2) given below: HGl: HG2:
.M(G- e) =&?(G) - e and e is a highest cost element in some circuit of d(G). Env(G) = Env(G/e) and, for every (H, L) E Env(G),
and e is a lowest cost element in some cocircuit X E E(G) of A( H QG). H-Greedy uses a function B, called the burner [6], that takes a pair (G, E) and returns a pair B((G, E)) = (Gb, E U C). The burner starts with Gb := G and C := 0 and does either Gb := Gb - e, where e satisfies HGl, or Gb := Gb/e, where e satisfies HG2. These steps are done in any order and every time an edge is contracted it is added to C. The algorithm is free to stop at any time after circuits cease to exist. Afterwards, all isolated terminals are deleted from Gb. H-Greedy constructs a sequence of pairs T;, T;,..., T,h, where T/’ = B((G,, 0)). For i > 1, construct Tb by setting c := (G, - A$,fl); then, Gj E Ni, setting c := f 0 1 finally, doing qb := B(c).
17 May 1991
C) are similar, denoted
(G, A) - (G’, A u C), if and only if: (1) Env(G) = Env(G’), and (2) for every ( H, L ) E Env( G) and every W E E(H 0LG’), W is an optimum base of d( H oLG’) if and only if W u C is an optimum base of M( H o,G). Lemma 3.2. For any pair R, B( R ) - R. Proof. Let R = (G, E) and (H, L) E Env(G). P’y Corollary 2.2, it suffices to prove that if e is deleted (contracted) from J?(G) by the burner, then e would be deleted (contracted) from A( H o,_G) by some execution of L-Greedy. This is easily verified from the definitions of HGl and HG2. q The foilowing result establishes the correctness of H-Greedy: Theorem 3.3. Let T,h = (G,h, Cn). Then E(G,!‘) U Cn is an optimum base of A?( X(r)). Proof. A straightforward induction using Lemma 3.2 shows that for each i, Tb - T, where T = (X(q), fl)_ This fact and Definition 3.1 imply the theorem. •I
4. Matroidal families The efficiency of H-Greedy depends in part on how quickly edges satisfying HGl and HG2 can be found. We now present two families of matroids for which this is easy. A nonempty family of graphs 9 is called a matroidal family if, for any graph G, the subgraphs of G isomorphic to members of 9 are the circuits of a matroid on E(G). A matroidal family 9 is homeomorphic if it is closed under homeomorphism [9]. A bicycle is a graph homeomorphic from one of the graphs given in Fig. 1. 119
INFORMATION
Volume 38, Number 3
o-0
00
Fig. 1.
PROCESSING LETTERS
CD
Definition 4.1 [9]. A graph contains k independent cycles (k independent bicycles) if the deletion of k edges is necessary and sufficient to produce a graph containing no cycles (bicycles). A graph is k-cycle-minimal (k-bicycle-minimal) if it contains k independent cycles (bicycles), but no proper subgraph of it does. Let ‘& (5&J denote the set of all k-cycle-minimal (k-bicycle-minimal) graphs. Matthews [9] proved that the only homeomorphic matroidal families of finite graphs are the families +$ and ak, for each positive integer k. For a graph G and an integer k > 0, let &(G) (5&(G)) denote the matroid on E(G) whose circuits are the subgraphs of G isomorphic to a member of %$ (a,J. Then, V,(G) is the wellknown cycle matroid [ 121 of G and @r(G) is the bicircular matroid [3,9] of G. The following lemmas, whose proofs are omitted, can be derived from Definition 4.1 and standard facts from matroid theory. Lemma 4.2. If At denotes S& or (ipk, then *for any graph G and any e E E(G), A(G - e) =.M(G) e. Lemma 4.3. Let G be a graph and e E E(G). If e has a pendant vertex or is in series with an edge f, then %$(G/e) = %$(G)/e and B,JG/e) = S?k(G)/e. In addition, if e is an isolated loop of G, then @(G/e) = gk(G)/e. These lemmas suggest the following implementation of H-Greedy for gk and 5&. The burner can find and delete edges satisfying HGl by first computing an optimum base of d(G) and then removing all edges not in the base. This can be done in polynomial time using the greedy algorithm. For the special cases of V, and a,, optimum bases can be found in almost linear time [2] and linear time [3], respectively. By Lemma 4.3, an edge e satisfies HG2 if: (1) e has a terminal pendant vertex, 120
17 May 1991
(2) e is in series with-f, where c(e) S: c(f) and e and f share a terminal vertex, (3) & is the class ak and e is an isolated loop whose endpoint is a terminal. The contraction of all such edges and the deletion of isolated terminal vertices can be done in linear time by using depth-first search. Thus, for each k > 0, polynomial-time burners exist for %$ and gk. A simple modification of H-Greedy yields an algorithm that computes the cost of an optimum base of gk ( X( I’)) or 5$( X(r)). The main difference with H-Greedy lies in the burner, which instead of recording all of the contracted edges, keeps track only of their total cost. Thus, the cost-finding algorithm and its burner manipulate pairs consisting of a graph and a number. Pairs are composed by gluing the graphs and adding the numbers. The algorithm creates a sequence Tf,. . . , T$’ of pairs, where qb = (G!, wi). Theorem 3.3 implies that c( E(G,!‘)) + w,, is the cost of an optimum base of A( X( r)). If the input to B is a graph G with p pins, then, as in [6], we can show that G6 has size 0( p + k). Thus, G! has size 0( k + pi). Since k is a constant, GF has size 0( pi). Therefore, the time required to construct qh is polynomial in the size of Gi. We now have the following theorem: Theorem 4.4.
The cost of an optimum base of gk ( X(T)) or S$ ( X(I’)) can be computed in time polynomial in the size of T.
It is also straightforward to modify H-Greedy to list the elements in an optimum base of gk ( X(r)) or V$( X(r)) using work-space linear in the size of r. The technique is an extension of a procedure for generating minimum-cost spanning trees described by Lengauer [6]. We omit the details.
eferences [l] J.L. Bentley, T. Ottmann and P. Widmayer, The complexity of manipulating hierarchically defined sets of rectangles, Ado. in Compr. Res. 1 (1983) 127-158.
Volume 38, Number 3
INFORMATION
[2] H.N. Gabow, Z. Galil, T. Spencer and R.E. Tarjan, Efficient algorithms for finding minimum spanning trees in undirected and directed graphs, Combinatoricu 6 (2) (1986) 109-122. [3] H.N. Gabow and R.E. Tarjan, A linear-time algorithm for finding a minimum spanning pseudoforest, Inform. Process. Lett. 27 (5) (1988) 259-263. [4] H. GaIperin and A. Widgerson, Succinct representations of graphs, Inform. and Control 56 (1983) 183-198. [5] E.L. Lawler, Combinatorial Optimization: Networks and Mutroids (Holt, Rinehart C Winston, New York, 1976). [6] T. Lengauer, Efficient algorithms for finding minimum spanning forests of hierarchically defined graphs, J. Algorithms 8 (1987) 260-284. [7] T. Lengauer and K. Wagner, The correlation between the complexities of the non-hierarchical and hierarchical versions of graph properties, in: F.J. Brandenburg et al., eds.,
PROCESSING LETTERS
[8]
[9] [lo]
[ll]
[12]
17 May 1991
Proc. STACS 87, Lecture Notes in Computer Science 247 (1987) 100-113. T. Lengauer and E. Wanke, Efficient solution of connectivity problems on hierarchically defined graphs, SIAM J. Comput. 17 (1989) 1063-1080. L.R. Matthews, Infinite subgraphs as matroid circuits, J. Combin. Theory, Ser. B 27 (1979) 260-273. J.B. Orlin, Some problems on dynamic/periodic graphs, Progress in Combinatorial Optimization (Academic Press Canada, Toronto, 1984). K.W. Wagner, The complexity of combinatorial problems with succinct input representation, Actu Inform. 23 (1986) 325-356. D.J.A. Welsh, Mutroid Theory, London Mathematical Society Monographs 8 (Academic Press, New York/London, 1976).
121