Minimum Weight Cycle Liam Roditty BarIlan University Based
Minimum Weight Cycle Liam Roditty Bar-Ilan University Based on: • Approximating the girth, (SODA`11) with Roei Tov (BIU) • Minimum Weight Cycles and Triangles: Equivalences and Algorithms, with Virginia V. Williams (UC Berkeley)
Problem Definition Given a graph G=(V, E) find the Minimum Weight Cycle (Min-Cycle) in the graph. Variants: • Undirected / Directed • Unweighted / Weighted • Exact / Approximation • With or without Fast Matrix Multiplication (FMM)
The Trivial Algorithm • Directed graphs: – Compute All-Pairs of Shortest Paths (APSP). – Min-Cycle = min(u, v) Ed[v, u] + w(u, v) v u
The Trivial Algorithm • Undirected graphs: – Dijkstra/BFS from every vertex of the graph – Pick the minimum cycle detected Example (unweighted): v u s In both cases the running time is Õ(n³).
Previous Work (1) Itai & Rodeh (SICOMP 1978) considered only unweighted graphs: • Min-Cycle in undirected graphs in O(nω) time. • Min-Cycle in directed graphs in O(nωlog n) time. • Approximation in undirected graphs in O(n²) time. – Return a min-cycle or a cycle whose length is larger by one from the minimum.
Previous Work (2) Yuster & Zwick (SIDMA 1997) presented an algorithm that finds the shortest even cycle in unweighted undirected graphs in O(n²) time.
Previous Work (3) Lingas & Lundell (IPL 2009) presented two approximation algorithms for undirected graphs: • For unweighted graphs an Õ(n 3/2) algorithm that returns a 2. 666…-approximation. • For weighted graphs with integral edge weights [1, M] an O(n² log n. M) algorithm that returns a 2 -approximation.
Previous Work (4) V. Williams & Williams (FOCS 2010) showed that if a Min-Cycle in an undirected graph with weights [1, M] can be found in O(n 3 -δ log M) for some δ>0 then it is possible to compute APSP in a directed graph with weights [-M, M] in O(n 3 -δ’ log M) for some δ’>0.
Results (SODA'11) • For undirected graphs with weights from [1, M] a 4/3 -approximation algorithm with a running time of O(n² log n. M). • For undirected graphs with real edge weights a (4/3+ε)-approximation with a running time of Õ(1/ε n²). • An algorithm with (4/3 -ε)-approximation can multiply two Boolean matrices. (Using V. W & W ideas).
New Results • For undirected and directed graphs with weights from [1, M] we show that the Min-Cycle problem can be efficiently reduced to finding a minimum weight triangle in graphs with weights [1, Θ(M)]. • This implies an Õ(Mnω) algorithm for Min-Cycle problem both in undirected and directed graphs. We resolve the open problem raised by Itai & Rodeh: “A related problem is finding a minimum weighted circuit in a weighted graph. It is unclear to us whether our methods can be modified to answer this problem too. ” SICOMP 1978
New Results Notice! APSP in directed graphs can be computed in O(M 0. 681 n 2. 575) time (Zwick JACM`02). APSP in undirected graphs can be computed in Õ(Mnω) time (Shoshan & Zwick FOCS`99). We show that Min-Cycle in directed graphs can be solved in Õ(Mnω) time!
In this talk • For undirected graphs with weights from [1, M] a 4/3 -approximation algorithm with a running time of O(n² log n. M) (SODA’ 11) • For undirected graphs with weights from [1, M] we show that the Min-Cycle problem can be efficiently reduced to finding a minimum weight triangle in graph with weights [1, Θ(M)]. (New result)
Unweighted undirected. Itai & Rodeh’s Additive 1 -Approximataion s 0 1 x y z w 2 3 The trivial algorithm: All edges of x are scanned in an arbitrary order. and in particular (x, y). A Min-Cycle is detected. Running time: O(m). We repeat it from every vertex. Total running time is O(mn).
Unweighted undirected. Itai & Rodeh’s Additive 1 -Approximataion s 0 1 x y z w 2 3 Itai & Rodeh: Stop with the first cycle discovered. Running time O(n²). Assume x is out from the queue after z and before y. Lucky scan (x, y) and stop. Output: Min-Cycle Unlucky scan (x, w) and stop. Output: Min-Cycle+1
Weighted [1, M] undirected. Lingas & Lundell 2 -Approximataion s 1 1 x 100 1 1 y 0 1 1 1 w 1 z 2 1 3 The same approach as IR with Dijkstra instead of BFS will not work. Lingas & Lundell: Run Dijkstra with a bounding parameter t, that is, grow a shortest paths tree up to depth t and report the first cycle detected.
Weighted [1, M] undirected. Reminder: Dijkstra’s algorithm Relax(u) Dijkstra(G, s) Q←{s} (u, v) E foreach While if d[s, v]>d[s, u]+w(u, v) Q is not empty do u ←d[s, v] Extract-Min(Q) ← d[s, u]+w(u, v) Relax(u)
Weighted [1, M] undirected. Lingas & Lundell 2 -Approximataion Relax. Or. Stop(u, v) Bounded Controlled-Relax(u, t) Dijkstra(G, s, t) Q←{s} (u, v) if d[v]← Extract-Min(Q then u) While Repot Q d[u]+w(u, v) isanot cycle empty and ≤ t stop do else. Relax. Or. Stop(u, v) u ← Extract-Min(Q) Controlled-Relax(u, t) (u, v) Relax(u, v) ← Extract-Min(Qu) s 50 t=100 u 1 X 1 d[X 1] = 51 4 3 X 2 X 3 d[X 3] =70 d[X 2] =92 STOP: Min-Cycle≤ 145
Weighted [1, M] undirected. ? Lingas & Lundell 2 -Approximataion s 50 50 t=100 1 50 50 Bounded Dijkstra with t=100 might find the red cycle and not the blue one.
Weighted [1, M] undirected. Lingas & Lundell 2 -Approximataion The algorithm: Binary search the interval [1, n. M] for the smallest value of t for which Bounded Dijkstra reports a cycle. Always reports May report ½t* t*=Min-Cycle Taking the smallest value of t for which a cycle is reported ensures that t≤t* and a 2 -approximation. Running time: O(n² log n (log n+log M))
Weighted [1, M] undirected. Our 4/3 -Approximataion Let Min-Cycle=t* and Max-Edge(Min-Cycle)=w*. Let t t*. We present two algorithms: Alg 1: Reports a cycle of weight at most t* + w*. Alg 2: Given wl and wu such that w* [ wl , wu ] reports a cycle of weight at most max{2 t* - 2 wl , t* + wu - wl }. 1. Notice! max{2 t* - 2 wl , t* + wu - wl } is 2 t* - 2 wl as long as wu ≤ t* wl w* Alg 1 t* + w* ≤ 1⅓t* w* Alg 2 [⅓t* , ⅔t*] 2 t* - 2 w* ≤ 1⅓t* ⅔t* w* Alg 2 [⅔t*, t*] t* + t*- ⅔t* ≤ 1⅓t* t*
Weighted [1, M] undirected. Our 4/3 -Approximataion: Alg 1 (t* + w*) Middle Edge Lemma: Let C={v 1, v 2, …vℓ} be a cycle of weight t and let s C. Then there exists an edge (vi, vi+1) such that: s d[s, vi]≤½t d[s, vi+1]≤½t vi vi+1
Weighted [1, M] undirected. Our 4/3 -Approximataion: Alg 1 (t* + w*) For a given s there is a mid point in on the cycle s =t*/2
Weighted [1, M] undirected. Our 4/3 -Approximataion: Alg 1 (t* + w*) For a given s there is a mid point in on the cycle s t*/2= =t*/2
Weighted [1, M] undirected. Our 4/3 -Approximataion: Alg 1 (t* + w*) The edge (vi, vi+1) is the middle edge. s We have: 1. d. C[s, vi]≤½t 2. d. C[vi+1, s]≤½t 1. d[s, vi]≤½t 2. d[s, vi+1]≤½t vi+1 vi
Weighted [1, M] undirected. Our 4/3 -Approximataion: Alg 1 (t* + w*) And now, the algorithm! Approx-Min-Cycle(G, s, t) R ←ф Q←{s} While Q is not empty do u ← Extract-Min(Q) Controlled-Relax(u, ½t) Let (u, v) be the smallest edge of u that was not relaxed R←{(u, v)} While R is not empty do (u, v) ← Extract-Min(R) Relax. Or. Stop(u, v) ← Extract-Min(Qu) Phase 1 Phase 2
Weighted [1, M] undirected. Our 4/3 -Approximataion: Alg 1 (t* + w*) Phase 1: R = {(u 0, v 0)} ), Approx-Min-Cycle(G, s, t) Bounded Dijkstra(G, s, t) R ←ф Q←{s} While Q is not empty do u ←Extract-Min(Q) u← Controlled-Relax(u, t) Controlled-Relax(u, ½t) u 0 (u 1, v 1) , Let (u(u, v) 2, v 2)be} the smallest edge of u that was not relaxed R← R {(u, v)} … s u 1 u 2 ½t v 0 w v 1 v 2
Weighted [1, M] undirected. Our 4/3 -Approximataion: Alg 1 (t* + w*) Phase 2: R = {(u 0, v 0) , (u 1, v 1) , (u 2, v 2) } R = {(u 0, v 0) , (u 1, v 2) , (u 2, v 2) } Approx-Min-Cycle(G, s, t) R = {(u 0, v 0) , … While R is not empty Rdo = {(u 0, v 0)} (u, v) ← Extract-Min(R) Relax. Or. Stop(u, v)s (u, v) ← Extract-Min(Qu) u 0 {(u, v)}u 1 u 2 R← R (u 1, v 2) } ½t v 0 w v 1 v 2
Weighted [1, M] undirected. Our 4/3 -Approximataion: Alg 1 (t* + w*) We need to prove that: • We report a cycle of weight t*+w* (Weight bound). • The running time from a given vertex is Õ(n) (Running time). 1. A bound on the weight: Phase 1: Phase 2: … Approx-Min-Cycle(G, s, t) R ←ф R is not empty do While Q←{s} (u, v) ← Extract-Min(R) While Relax. Or. Stop(u, v) Q is not empty do (2) u ← Extract-Min(Q) (u, v) ← Extract-Min(Qu) Controlled-Relax(u, ½t) (1) R←{(u, v)} A cycle can be reported either in line (1) or (2). Easy case (line 1): We stopped in line (1). The weight of the reported cycle is at most t. Hard case (line 2): Next slide.
Weighted [1, M] undirected. Our 4/3 -Approximataion: Alg 1 (t* + w*) Hard case (line 2): If we stopped at phase 2 before the middle edge (vi, vi+1) of s got out then any edge (x, y) that was popped out from R satisfies: d[s, x]+w(x, y) ≤ min {d[s, vi]+w*, d[s, vi+1]+w*} In particular, if we stopped with the edge (h, g) then: d[s, h]+w(h, g)+d[s, g] ≤ 2 min {d[s, vi]+w*, d[s, vi+1]+w*} ≤ d[s, vi]+2 w*+d[s, vi+1] ≤ t* +w* s s ½t* h ≤½t* Phase 1 g vi ≤w* vi+1
Weighted [1, M] undirected. Our 4/3 -Approximataion: Alg 1 (t* + w*) Running time: R = {(u 0, v 0) , (u 1, v 1) , (u 2, v 2) } s u 0 u 1 u 2 ½t v 0 w v 1 v 2 The first time that a vertex beyond the ½t threshold is added to R for the second time we stop and report a cycle. Hence, we can charge any edge of R to its endpoint beyond the ½t threshold and the running time is Õ(n).
Weighted [1, M] undirected. Our 4/3 -Approximataion: Alg 1 (t* + w*) Summary: • We have shown that given t t* in Õ(n²) time it is possible to return a cycle of weight t* + w* • This algorithm is a natural generalization of the additive 1 -approximation of Itai and Rodeh for unweighted graphs. • Recall that this is just one ingredient of our algorithm.
Weighted [1, M] undirected. Our 4/3 -Approximataion: Alg 2 (max{2 t - 2 w , t + w * l * u - w l } ). Sketch: Approx-Min-Cycle(G, s, t, wl, wu) d[s] = 0 Controlled-Relax(s, wu) While Q is not empty do u ← Extract-Min(Q) Controlled-Relax(u, t-wl) s=vi =w* w* [wl, wu] vi+1 Analysis: More complicated. Some intuition: when a cycle is reported it is because we reach some vertex u twice. The bound is either 2 t* - 2 wl or t* + wu - wl.
In this talk • For undirected graphs with weights from [1, M] a 4/3 -approximation algorithm with a running time of O(n² log n. M). (SODA’ 11) • For undirected graphs with weights from [1, M] we show that the Min-Cycle problem can be efficiently reduced to finding a minimum weight triangle in graph with weights [1, Θ(M)]. (New result)
Weighted [1, M] undirected. Min-Cycle to Min-Triangle Theorem: Given an undirected graph G with weights [1, M] there is an O(n² log n. M) time algorithm that either find a Min-Cycle in G or compute log n graphs: G’ 1 , G’ 2 , G’ 3 , . . . G’log n With Θ(n) nodes and edge weights [1, O(M)] such that: The minimum weight triangle among all G’i graphs has the same weight as the Min-Cycle of G.
Weighted [1, M] undirected. Min-Cycle to Min-Triangle Simple (and important) observation: Assume that we run just the first phase of Alg 1 (t*+w*) for a given t. Approx-Min-Cycle(G, s, t) R ←ф Q←{s} Q is not empty do While Q Extract-Min(Q) is not empty do u← u ← Extract-Min(Q) Controlled-Relax(u, ½t) We either compute all. Controlled-Relax(u, ½t) distances of length at most ½t from s or report a Let (u, v) be the smallest edge cycle of weight at most t. of u that was not relaxed R←{(u, v)} While R is not empty do (u, v) ← Extract-Min(R) Relax. Or. Stop(u, v) ← Extract-Min(Qu) R←{(u, v)}
Weighted [1, M] undirected. Min-Cycle to Min-Triangle First stage: Binary search for the first t such that Approx-Min-Cycle(G, 2 t) does not report on a cycle and Approx-Min-Cycle(G, 2 t+2) reports. Report a cycle ≤ 2 t+2 t t+1 No cycle is reported. All distances up to t are computed Need to show: If the Min-Cycle ≤ 2 t+1 we can find it.
Weighted [1, M] undirected. Min-Cycle to Min-Triangle Main Lemma: Let C={v 1, v 2, … , vℓ} and assume that Approx-Min-Cycle(G, t) does not report a cycle then there are three distinct vertices vi, vi+1, and vj C such that: d. C[vj, vi]+w(vi, vi+1)>t and d. C[vi+1, vj]+w(vi, vi+1)>t vj ≤ 2 t+1 vi vi+1
Weighted [1, M] undirected. Min-Cycle to Min-Triangle Main Lemma: Let C={v 1, v 2, … , vℓ} and assume that Approx-Min-Cycle(G, t) does not report a cycle then there are three distinct vertices vi, vi+1, and vj C such that: d. C[vj, vi]+w(vi, vi+1)>t and d. C[vi+1, vj]+w(vi, vi+1)>t vj d. C[vj, vi] ≤ t d. C[vi+1, vj] ≤ t As this is a Min-Cycle d[vj, vi] = d. C[vj, vi] d [vi+1, vj]=d. C[vi+1, vj] and we have computed these distances ! ≤ 2 t+1 vi vi+1
Weighted [1, M] undirected. Min-Cycle to Min-Triangle Create a new graph G’: (V 1, ø) Distances (V 2, E) vj vi v 1 j vi+1 v 2 i+1
Weighted [1, M] undirected. Min-Cycle to Min-Triangle There are two problems with G’. • We may create a triangle that corresponds to a path rather than a cycle • The weights in G’ may be Ω(n. M) (not covered in the talk)
Weighted [1, M] undirected. Min-Cycle to Min-Triangle Fixing the first problem: The last vertex on the path to z is y. We use color coding (Alon, Yuster and Zwick JACM`95 ). We use two colors. x x 1 (V 1, ø) Distances (V 2, E) y y 2 z 2 y z We add an edge (x 1, z 2) only if the last vertex before z is red y cannot be red and blue at the same time!
Weighted [1, M] undirected. Min-Cycle to Min-Triangle We avoid the bad case and remain with the good case vj vi vi+1
Summary • We have settled many variants of a fundamental open problem in algorithmic graph theory. • But, what about approximation in directed graphs? Can we get O(n 3 -δ) for some δ>0 and constant approximation? Or maybe we can show a “lower” bound.
Thank you!
Weighted [1, M] undirected. Our 4/3 -Approximataion: Alg 1 (t* + w*) Proof: Let (vi , vi+1) be an edge of C with weight strictly more than ½t. In this case the claim holds for every vertex using this edge. Thus, we can assume that w*≤½t. s=v 1 We search for two vertices that satisfy: 1. d. C[s, vi]≤½t 2. d. C[s, vi+1]>½t 1. d[s, vi]≤d. C[s, vi]≤½t 2. d[s, vi+1]≤½t v 2 v 3 vi vi+1
Weighted [1, M] undirected. Our 4/3 -Approximataion: Alg 1 (t* + w*) s=v 1 This means that: 1. d. C[s, vℓ-1] ≤ ½t 2. d. C[s, vℓ] ≤ ½t v 2 >½ t Proof (cont): To complete the proof we need to show that these vertices exist. Assume on the contrary that we have not found two such vertices in the process. vℓ v 3 vℓ-1 A contradiction as w* ≤ ½t vi vi+1
- Slides: 46