Longest paths in Planar DAGs in Unambiguous Logspace

We show via two different algorithms that finding the length of the longest path in planar directed acyclic graph (DAG) is in unambiguous logspace UL, and also in the complement class co-UL. The result extends to toroidal DAGs as well.

Authors: Nutan Limaye, Meena Mahajan, Prajakta Nimbhorkar

Longest paths in Planar D A Gs in Unam biguous Logspace Nutan Lima y e and Meen a Maha jan and Pra jakta Nim bhork ar The Institute of Mathematical Science s, Chennai 600 113, India. { n utan,meena,pra jakta } @imsc.res.in Octob er 23, 2018 Abstract W e sho w via t wo differen t a lgorithms that finding the length of the longest path in plana r directed acyclic graph (D AG) is in unambiguous logspace UL , and also in the complement cla s s co- UL . The result extends to tor o idal D AGs as well. 1 In tro duction Consider the follo wing pr ob lems in graphs: Reach = { ( G, s, t ) | G con tains a path from s to t } Distance = { ( G, s, t, k ) | G con tains a path of lengt h ≤ k f rom s to t } Long-P ath = { ( G, s, t, k ) | G has a simple path of length ≥ k from s to t } These problems ha v e w idely differing complexities: some of the results b elo w are folklore, some are recent adv ances. Reach is NL -complete for general graph s and remains NL -hard ev en if the graphs are acyclic. It is L -complete for un directed graphs [Rei05], and is sandwiched b etw een L and UL ∩ co-UL for planar d irected graph s [BTV07]. Distance is NL -complete for general graphs, and remains NL -hard even if the graph s are acyclic, or if the graphs are undir ected, but it is in UL ∩ co-UL for planar directed graphs [TW07]. Long-P ath is NP -complete f or ge ner al graphs, since it includes Hamiltonian paths as a sp ecial case. It remains NP -hard for planar u ndirected graphs. It is NL -complete for directed acyclic grap h s. Ho w ev er its complexity f or p lanar directed acyclic graphs is, to the b est of our kn owledge, not y et studied. In this note we consider th is com bination of planarit y and acyclici ty for Long-P ath . Our main result is: Theorem 1 PD LP , the Long-P ath pr oblem f or planar dir e cte d acyclic gr aphs, is in UL ∩ co-UL . Th u s Long-P ath shares the c u r ren t b est-kno wn upp er b oun ds f or Reach and Distance for suc h graphs. W e also address th e question of when t h e three problems are indeed equ iv alen t on D AGs, and giv e partial b ound s (Th eorem 8,10). A recen t resu lt in [JT07] shows that for an im p ortan t sub class of planar D A Gs, namely series-parallel graphs , the three pr oblems are indeed equiv alen t and are all L -complete. Theorem 1 is in fact an unobserved corollary of th eir constru ction (see also [J T06]. An analogous result for planar D A Gs equating the thr ee problems w ould b e nice, but is n ot kno wn. F or graphs with em b eddings on the torus, [ADR05] sho ws that reac habilit y is n o h arder than planar reac hability . W e observe that Distance and Long-P ath are also n o h arder than the planar v ersions (Corollary 6). 1 2 Kno wn results, and Prepro cessing W e use the follo w ing results: Lemma 2 ([BTV07]) Reach in planar dir e cte d gr aphs is in UL ∩ co-UL . Lemma 3 ([T W07]) Distance in planar dir e cte d gr aphs is in UL ∩ co-UL . Lemma 4 ([JT 07]) Distance and Long-P ath in series-p ar al lel gr aphs ar e e quivalent. Lemma 5 ([ADR05]) R each (T orus) lo gsp ac e-many-one r e duc es to planar Reach . F or an y sub class C of g rap h s, let Reach ( C ), Distance ( C ), and Long-P ath ( C ) denote the r estric- tion of these problems to instances from C . F or directe d acyclic g raph s, ( G, s, t ) ∈ Reach ⇔ ( G, s, t, | V | ) ∈ Distance ⇔ ( G, s, t, 0) ∈ Long-P ath . S o Distance ( C ) and Long-P ath ( C ) are at least as hard as Reach ( C ) for any sub class C of directed acyclic graphs. Consider any directed acyclic instance ( G, s, t, k ) of D istance or Long-P ath . By (parallel) queries of the form ( G, s, u ) or ( G, u, t ) to Reach , w e can remo v e all vertic es that do not fi gure on some s -to- t path to obtain in L Reach a single-source ( s ) single-sink ( t ) graph G ′ , and all qu eries to Reach in vo lve only th e g raph G . S o no w onw ards w e only consider the case where w e w an t to find a long path b et w een the u nique source and the u nique sink. If the input graph G is not planar but can b e emb ed ded on a torus, then we use the construction of Lemma 5 . This giv es a planar graph G ′ with the fol lowing prop erties: There are l ∈ O ( n ) copies of G cut and stitc hed together, and hence there are l v ertices t 1 , . . . , t l and one sp ecial v ertex, sa y s 1 , suc h that ∃ ρ : s → ∗ G t ∧ | ρ | = l ⇔ ∃ i ∃ ρ i : s 1 → ∗ G ′ t i ∧ | ρ i | = l Hence Corollary 6 Distance ( T orus ) ≤ log m Distance ( Planar ) Long-P ath ( T or oidal DA Gs ) ≤ log m Long-P ath ( Planar DAGs ) 3 Algorithm using distance computation Our first algorithm for Long- Path in planar D A Gs uses a simple extension of Lemma 4. Lemma 7 Distance and Long-P ath in planar dir e cte d acyclic g r aphs ar e e quivalent mo dulo planar r e achability. This actually follo ws from [JT 07] itself; though they claim th eir result only f or ser ies-parallel graphs, it wo rks for single-source single-sink acyclic graph s as w ell, where s and t in the inpu t instance are th e source and sink resp ectiv ely . It d oesn’t even seem to u se planarit y . T o mak e th is clear, we present b elo w in Theorem 8 their pro of simplified by sp ecialising to unw eigh ted graphs, and stated with minim um conditions. Lemma 7 is an ob vious corollary . 2 Theorem 8 L et C b e any sub c lass of dir e cte d acyclic gr aphs. Ther e is a f unction f , c omputable in L with or acle ac c ess to Reach ( C ) , that r e duc es D istance ( C ) to Long-P ath ( C ) and Long-P ath ( C ) to Di stance ( C ) . Pro of: Let G = ( V , E ) b e a directed acyclic graph with a un ique source s an d a unique sink t . Ev ery v ertex of G l ies on some s → ∗ t path. ( G is un we ighted, so all edges hav e w eigh t 1.) Let M b e the n um b er of edges in G . Construct a new graph G ′ = ( V ′ , E ′ ) as follo ws: F or eac h u ∈ V , defi n e P u = { x ∈ V | x → ∗ G u } . S in ce s is the unique sour ce, ∀ u , s ∈ P u . Also define E u = {h x, y i | x ∈ P u , y 6∈ P u } . S ince G is ac yclic, ∀h x, y i ∈ E , h x, y i ∈ E x . Let ρ b e any s → ∗ t path. F or ev ery v ertex u ∈ V , | ρ ∩ E u | = 1. Why? Note that s ∈ P u , t 6∈ P u , and along the path ρ , we tr an s it from b eing in P u to b eing outside P u exactly once. Let this transition o ccur on edge h x, y i . Then h x, y i ∈ E u , and no ot h er edge of ρ ca n b e in E u . T o obtain G ′ , w e replace eac h edge e = h u, v i b y a path o f length l uv determined as follo ws: l uv = 2   X x ∈ V : e ∈ E x out-degree( x )   − 1 = 2   X x ∈ V : u ∈ P x ,v 6∈ P x out-degree( x )   − 1 Since G is acyclic , the v ertex u itself alwa ys qualifies in the ab o v e sum, and so l uv is p ositiv e. No w the crucial claim: eac h s → ∗ t path ρ in G , of length | ρ | in terms of num b er of edges, is transformed by the abov e to a path in G ′ of length exactly 2 | E | − | ρ | . Th is is b ecause the lengt h of the transformed path is X uv ∈ ρ l uv = X uv ∈ ρ   2   X x ∈ V : u ∈ P x ,v 6∈ P x out-degree( x )   − 1   = 2   X uv ∈ ρ X x ∈ V : u ∈ P x ,v 6∈ P x out-degree( x )   − | ρ | = 2 X x ∈ V   out-degree( x ) X e ∈ ρ ∩ E x 1   − | ρ | = 2 X x ∈ V out-degree( x ) · | ρ ∩ E x | ! − | ρ | = 2 X x ∈ V out-degree( x ) − | ρ | = 2 | E | − | ρ | It th us follo ws that t h e longest (shortest) path in G is mapp ed to the shortest (longest, resp ec- tiv ely) path in G ′ . In fact, if the s → ∗ t paths are ord ered m onotonica lly w ith resp ect to length, then the ab o ve transformation precisely rev erses this ordering. Hence the reduction function f maps ( G, s, t, k ) to ( G ′ , s, t, 2 | E | − k ). The next crucial observ ation: G ′ can b e obtained fr om G in logspace w ith oracle access to Reach , wh ere all q u eries inv olv e only th e graph G . This is b ecause obtaining G ′ merely inv olv es finding the sets P u , E u . Theorem 1 follo ws from Theorem 8 and Lemma 3. 3 4 Algorithm using inductiv e coun ting There is another metho d to obtain Theorem 1, bypassing Theorem 8 b ut u s ing Lemmas 2,3 . W e sk etc h it here b ecause it is instructiv e to see ho w doub le inductiv e count ing can b e used, and also b ecause it sa ys so methin g more g eneral as we ll: it places Long-P ath in ( UL ∩ co-UL ) ⊕ Reach (C ) for an y family C of acyclic max-unique graphs (Theorem 10). The initial steps are similar to those used in [TW07] to plac e p lanar Distance in UL ∩ co-UL . 1. Given a graph ˆ G , make it single-source s ingle-sink G as describ ed in the p repro cessing step. Reduce the degree of eac h verte x to 3. (T o r educe the degree of no des, in [ADR05] a vertex of degree d is replaced b y a cycle of length d . Sin ce we cannot afford to in tro duce cycles, w e use the trick of [CD06 ]; insert in coming and outgoing tr ees at eac h v ertex.) This constru ction maps edges to paths, a n d we can iden tify a unique new edge as ”resp onsible” for eac h orig inal edge. W e mark su ch edges. Em b ed G in to a grid using the [ADR05] reac habilit y-preserving construction. The output of this step is a grid graph G ′ , with the edges of G (original edges) marked in G ′ and is obtained in logspace. If the original graph G had n v ertices, the new grid graph is of dimensions n 2 × n 2 . 2. T he graph G ′ is then sub ject to a weig hting sc heme building up on t h at of [BTV07], and can b e describ ed as follo ws: ev ery horizon tal edge e gets weigh t n 4 + (mark( e ) × n 8 ), and ev ery v ertical edge e gets w eigh t n 4 + (mark( e ) × n 8 ) + (up(e) × col(e)), where mark( e ) is one if the edge e is marked; zero otherwise, col( e ) equals the column num b er in wh ic h the edge e app ears, and up( e ) is +1 if t h e ed ge e is u p wa rd s, − 1 o therw ise. T h is is t h e graph G ′′ . 3. T he last step in [TW07] is to u se the double counting tec hn iqu e of [RA97] on the min-unique graph G ′′ . Th e idea h ere is to use the indu ctiv e counting coun ter c k that k eeps trac k of num b er of v ertices within distance k , and to u se a cumula tive p aths counte r s k that kee p s trac k of the shortest paths of the no des so coun ted. The first coun ter allo ws c hec king th e complement of reac hability , the second allo ws doing so unambiguously . As men tioned in [TW07], a third coun ter m k trac king cumulativ e marked edges can b e add ed, allo wing distance computation uniquely . Can w e directly use this strategy for long paths as w ell? The argument of [T W07] concerning S tep 2 is restricted to shortest paths; ho wev er, one can observ e something more general ab out the ab o v e weigh ting sc heme. Observ at ion 9 F or any length l , al l the st p aths of length l in G wil l b e map p e d to p aths of weight gr e ater than ( l × n 8 ) and less than (( l + 1) × n 8 ) in G ′′ , and the maximum weight and the minimum weight p ath s in this r ange wil l b e unique. Thus G ′′ is b oth min-un iqu e and max-un ique : f or e ach p air u, v , if ther e is a p ath fr om u to v , then the shortest and the longest p aths ar e unique. Observ ation 9 al r eady guaran tees a max-unique graph. Step 3 ab ov e can not b e us ed as it is. F or computing the shortest path, we can initialise c 0 = 1 and Σ 0 = 0. If the same semantics is to b e used for computing th e longest path, then c 0 should b e the n um b er of v ertices havi n g length of the longe st path from s at least 0, and should be initialised to n . How ev er Σ 0 should then con tain the total lengths of all the longest paths, whic h 4 is an unknown quan tit y . T o han d le this, we redefin e Σ k to b e s u m of lengths of the longest paths for those v ertices wh ose longest p ath to t is of length at m ost k . This allo ws a pro cedure similar to [RA97] to work correctly , bu t no w it is n o longer unambiguous. T o make it unambiguous, we in tro duce more n ondeterminism into the [RA97] p ro cedure. W e guess the sum of lengths of a ll the u → ∗ t longest paths a priori and tally it in the end with the final s k . The detailed pro cedures are giv en b elo w, whic h imply the follo wing: Theorem 10 L et G b e a dir e cte d acyclic gr aph with a unique sour c e s , a unique sink t , such that G is max-uni que. (F or e ach p air u, v , if ther e is a p ath f r om u to v , then the longest uv p ath is unique.) Then the length of the longest st p ath c an b e c ompute d in UL ∩ co-UL . The pro of follo ws from Claims 11, 12, 13 and 1 4 . Notatio n : D ( v ) = Length of the lo n gest path from v to t . S k = { v | D ( v ) ≥ k } , c k = | S k | , Σ k = X v ∈ V \ S k D ( v ) , T = X v ∈ V D ( v ) Algorithm 1 M ain Input: G, s, t Guess nondeterministically M = P v ∈ V D ( v ). n ≤ M ≤ n 2 . c 0 ← n, Σ 0 ← 0 , k ← 0 while c k 6 = 0 do k ← k + 1 Up date ( c k and Σ k ) end while if Σ k 6 = M then Halt and reject else Accept end if Algorithm 2 U p date : Pro cedure for up dating c k and Σ k Input: G, s, t, c k − 1 , Σ k − 1 c k ← c k − 1 , Σ k ← Σ k − 1 for all v ∈ V do if T est ( G, k − 1 , c k − 1 , Σ k − 1 , v )=tru e then if for all out-neigh b our s x of v , T est ( G, k − 1 , c k − 1 , Σ k − 1 , x )=false then c k ← c k − 1 , Σ k ← Σ k + k − 1 end if end if end for Claim 11 If the g uesse d value of M is c orr e ct (i.e. M = T ), then algorithm T est , given th e c orr e ct values of c k and Σ k as input, r ep ort s a de cision on exactly one p ath. 5 Algorithm 3 T est : An unambiguous pro cedure t o determin e if D ( v ) ≥ k Input: G, k , c k , Σ k , v count = n, s um = 0 , path.to.v = tr ue, sum ′ = 0 for all x ∈ V do Guess nondeterministically if D ( x ) ≥ k if Guess is n o t hen Guess a path of le n gth l < k fr om x to t . { If this fails then reject and halt. } count ← count − 1 sum ← sum + l if x = v then path.to.v =false end if else Guess a path of le n gth l ′ ≥ k from x to t . { If this fails then reject and halt. } sum ′ ← sum ′ + l ′ end if end for if count = c k and sum = Σ k and sum ′ + sum = M then return path.to.v else Reject and halt. end if Pro of: The p rocedu re T est , on eac h run R , guesses an x → ∗ t path R x for eac h v ertex x . Dep end ing on its guess for D ( x ) ≥ k , it adds the length of R x to either sum or su m’. Finally these ha ve to add up to M for T est to rep ort a decision. When M = T , M is ind eed the sum of all D ( x ). This can matc h sum +sum’ exactly when all the guessed paths R x are longest. Since G is max-unique, this happ ens o n exactly one run. Claim 12 F or any guesse d value o f M , given the c orr e ct values of c k and Σ k as input, al l p aths of algorithm T est that do not le ad to r eje ction always r eturn the c orr e ct de cision. Pro of: As describ ed in th e preceding pro of, eac h run of T est guesses a path R x for eac h x . It may guess a path of le n gth shorter than D ( x ), but not longer. Sin ce count is d ecremen ted only wh en it guesses that D ( x ) < k , and for other guesses some w itnessing p ath of le n gth a t least k is found, at the end the v alue of count is at most as large as c k . Supp ose on some run T est returns a decision. T hen on this run count = c k . S upp ose further that the decision is wrong. Case 1: D ( v ) < k , but T est rep orts that it is larger. This cannot happ en, sin ce T est has to find a witnessing path of length at least k . Case 2: D ( v ) ≥ k , but T est rep orts t h at it is smaller. Then this run o f T est do es not ac count for v in count . S o at the end of the run, co unt < c k , a con tradiction. Claim 13 If the q ueries ( D ( v ) ≥ k ) ar e answer e d c orr e ctly by T est , then given c k − 1 and Σ k − 1 , the values of c k and Σ k ar e up date d c orr e ctly b y algorithm Up date . 6 Pro of: Up date starts by assuming that S k = S k − 1 and so c k = c k − 1 . Note that S k ⊆ S k − 1 , so Up date only has to detec t when to remo v e vertices from its curren t S k . F or eac h v , Up da te c hec ks whether D ( v ) ≥ k − 1 and D ( u ) < k − 1 for all out-neigh b our s u of v . If this h olds, then the longest p ath from v to t is of length exactly k − 1 and v / ∈ S k . Thus the pro cedure decremen ts c k b y 1 and incremen ts Σ k b y k − 1. So if all the queries are answ ered correctly by T est , then wh at Up date do es is correct. Claim 14 The algorithm Mai n is c orr e ct and unambiguous. Pro of: Main s tarts with the correct v alues of c 0 and Σ 0 . F rom claims 12 and 13, the correctness of Main is immediate. In p articular, the final v alue of Σ k is alw a ys correct. If M = T , then by C laim 11, pro cedure T est alwa ys return s a decision, unambiguously . Thus exactly one p ath of Main (amongst those where M = T wa s guessed) leads to a decision, and this decision is correct. If M > T , then no ru n of T est , at any stage k , can trace paths adding up to M . So T est , and hence Up date , and Main ha v e n o accepting r un. If M < T , consid er the run s on which T est and U p date p ro ceed to finally compute Σ k . S ince Main is correct, w e kno w that Σ k = T . No w the c hec k M = Σ k fails and Main reject s and halts. References [ADR05] Er ic Allender, Samir Datta, and Sambuddha Roy . The d irected p lanar reac habilit y prob - lem. In Pr o c. 25th annual Confer enc e on F oundations of Softwar e T e chnolo gy and The o- r e tic al Computer Scienc e (FSTTCS) , pages 238–24 9., 2005. [BTV07] Ch ris Bourke , Raghunath T ewa ri, and N V Vino dc hand ran. Directed p lanar reac ha- bilit y is in unambiguous logspace. In to app e ar in Pr o c e e dings of IEEE Confer enc e on Computation al Complexity CCC , p ages –, 2007. [CD06] T an m o y Chakrab ort y and S amir Datta. On e-input-face MPCVP is hard for L, but in LogDCFL. In Pr o c. of 26th FST TCS Confer enc e, LNCS vol. 4337 , pages 57–68 , 2006. [JT06] Andreas Jak oby an d Till T an tau. Computing shortest paths in series-parallel graphs in logarithmic space. In Complexity of Bo ole an F unctions , Dagstuhl Seminar Pr oceedings, 2006. h ttp://drops.d agstuhl.de/opus/v olltexte /2006/618. [JT07] Andreas Jak ob y and Till T antau. Logspace algorithms for computin g sh ortest and longest paths in series-parallel graphs. In FSTTCS , page to app ear, 200 7. s ee also [JT06]. [RA97] Klaus R einh ardt and Eric Allender. Making nondeterminism u n am biguous. In IEE E Symp osium on F oundations of Computer Sci enc e , pages 244–253 , 1997. [Rei05] Omer Reingold. Undirected st -connectivit y in logspace. In Pr o c. 37th STOC , pages 376–3 85, 2005. [TW07] Thomas T hierauf and F abian W agner. The isomo r p hism problem for planar 3 -connected graphs is in unam biguous logspace. T ec h nical Rep ort TR07 -068, ECCC, 2007. to app ear in ST A CS 2008. 7

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment