# Minimum Weight Cycle Liam Roditty Bar-Ilan University Based on: Approximating the girth, (SODA`11) with Roei Tov (BIU) Minimum Weight Cycles and Triangles:

## Presentation on theme: "Minimum Weight Cycle Liam Roditty Bar-Ilan University Based on: Approximating the girth, (SODA`11) with Roei Tov (BIU) Minimum Weight Cycles and Triangles:"— Presentation transcript:

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)  E d[v,u] + w(u,v) vu

The Trivial Algorithm Undirected graphs: – Dijkstra/BFS from every vertex of the graph – Pick the minimum cycle detected Example (unweighted): vu 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 log nM) 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 log nM). 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).

“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 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:

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 log nM) (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)

Itai & Rodeh’s Additive 1- Approximataion s 0 1 2 3 xyz 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). w Unweighted undirected.

Itai & Rodeh’s Additive 1- Approximataion s 0 1 2 3 xyz Itai & Rodeh: Stop with the first cycle discovered. Running time O(n²). Assume x is out from the queue after z and before y. w Lucky scan (x,y) and stop. Output: Min-Cycle Unlucky scan (x,w) and stop. Output: Min-Cycle+1 Unweighted undirected.

Lingas & Lundell 2-Approximataion s 0 1 2 3 xyz 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. w Weighted [1,M] undirected. 1 1 1 1 1 1 1 1 1 1 100

Dijkstra(G,s) Q←{s} While Q is not empty do u ← Extract-Min(Q) Relax(u) Reminder: Dijkstra’s algorithm Weighted [1,M] undirected. Relax(u) foreach (u,v)  E if d[s,v]>d[s,u]+w(u,v) d[s,v] ← d[s,u]+w(u,v)

Bounded Dijkstra(G,s,t) Q←{s} While Q is not empty do u ← Extract-Min(Q) Controlled-Relax(u,t) Lingas & Lundell 2-Approximataion Weighted [1,M] undirected. Controlled-Relax(u,t) (u,v) ← Extract-Min(Q u ) While d[u]+w(u,v) ≤ t do RelaxOrStop(u,v) (u,v) ← Extract-Min(Q u ) RelaxOrStop(u,v) if d[v]   then Repot a cycle and stop else Relax(u,v) s u 1 3 X1X1 X2X2 X3X3 d[X 1 ] =  d[X 2 ] =92 4 d[X 3 ] =70 50 d[X 1 ] = 51 STOP: Min-Cycle≤145 t=100

Lingas & Lundell 2-Approximataion Weighted [1,M] undirected. s 50 1 ? t=100 Bounded Dijkstra with t=100 might find the red cycle and not the blue one.

Lingas & Lundell 2-Approximataion Weighted [1,M] undirected. The algorithm: Binary search the interval [1,nM] for the smallest value of t for which Bounded Dijkstra reports a cycle. t * =Min-Cycle Always reports ½t * May report 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))

Our 4/3-Approximataion Weighted [1,M] undirected. Let Min-Cycle=t * and Max-Edge(Min-Cycle)=w *. Let t  t *. We present two algorithms: Alg1: Reports a cycle of weight at most t * + w *. Alg2: Given w l and w u such that w *  [ w l, w u ] reports a cycle of weight at most max{2t * - 2w l, t * + w u - w l }. Notice! max{2t * - 2w l, t * + w u - w l } is 2t * - 2w l as long as w u ≤ t * - w l w*w* Alg 1 t * + w * ≤1⅓t * w*w* Alg 2 [ ⅓ t *, ⅔t * ] 2t * - 2w * ≤1⅓t * t*t* ⅓t*⅓t* ⅔t*⅔t* w*w* Alg 2 [ ⅔t *, t * ] t * + t * - ⅔t * ≤1⅓t *

Our 4/3-Approximataion: Alg1 (t* + w*) Weighted [1,M] undirected. 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 (v i,v i+1 ) such that: s vivi v i+1 d[s,v i ]≤ ½ t d[s,v i+1 ]≤ ½ t

Our 4/3-Approximataion: Alg1 (t* + w*) Weighted [1,M] undirected. For a given s there is a mid point in on the cycle s =t*/2

Our 4/3-Approximataion: Alg1 (t* + w*) Weighted [1,M] undirected. s t*/2= =t*/2 For a given s there is a mid point in on the cycle

Our 4/3-Approximataion: Alg1 (t* + w*) Weighted [1,M] undirected. The edge (v i,v i+1 ) is the middle edge. s vivi v i+1 We have: 1. d C [s,v i ] ≤ ½ t 2. d C [v i+1,s] ≤ ½ t 1. d[s,v i ] ≤ ½ t 2. d[s,v i+1 ] ≤½ t

Our 4/3-Approximataion: Alg1 (t* + w*) Weighted [1,M] undirected. 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) RelaxOrStop(u,v) (u,v) ← Extract-Min(Q u ) R← R  {(u,v)} Phase 1 Phase 2

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← R  {(u,v)} … Our 4/3-Approximataion: Alg1 (t* + w*) Weighted [1,M] undirected. Phase 1: Bounded Dijkstra(G,s,t) Q←{s} While Q is not empty do u ← Extract-Min(Q) Controlled-Relax(u,t) s ½t u0u0 v0v0 w u1u1 u2u2 v1v1 v2v2 R = {(u 0,v 0 ), (u 1,v 1 ), (u 2,v 2 ) } R = {(u 0,v 0 )}

Our 4/3-Approximataion: Alg1 (t* + w*) Weighted [1,M] undirected. Phase 2: Approx-Min-Cycle(G,s,t) … While R is not empty do (u,v) ← Extract-Min(R) RelaxOrStop(u,v) (u,v) ← Extract-Min(Q u ) R← R  {(u,v)} s ½t½t u0u0 v0v0 w u1u1 u2u2 v1v1 v2v2 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 ) } R = {(u 0,v 0 ), (u 1,v 2 ) } R = {(u 0,v 0 )}

Our 4/3-Approximataion: Alg1 (t* + w*) Weighted [1,M] undirected. 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). A bound on the weight: Approx-Min-Cycle(G,s,t) R ←ф Q←{s} While Q is not empty do u ← Extract-Min(Q) Controlled-Relax(u,½t) (1) R←{(u,v)} Phase 1: … While R is not empty do (u,v) ← Extract-Min(R) RelaxOrStop(u,v)(2) (u,v) ← Extract-Min(Q u ) R←{(u,v)} Phase 2: 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.

Our 4/3-Approximataion: Alg1 (t* + w*) Weighted [1,M] undirected. Hard case (line 2): If we stopped at phase 2 before the middle edge (v i,v i+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,v i ]+w *,d[s,v i+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,v i ]+w *,d[s,v i+1 ]+w * } ≤ d[s,v i ]+2w * +d[s,v i+1 ] ≤ t * +w * s vivi v i+1 ½t*  ≤½t* ≤w * s h g Phase 1

Our 4/3-Approximataion: Alg1 (t* + w*) Weighted [1,M] undirected. Running time: 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). R = {(u 0,v 0 ), (u 1,v 1 ), (u 2,v 2 ) } s ½t½t u0u0 v0v0 w u1u1 u2u2 v1v1 v2v2

Our 4/3-Approximataion: Alg1 (t* + w*) Weighted [1,M] undirected. 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.

Our 4/3-Approximataion: Alg2 ( max{2t * - 2w l, t * + w u - w l } ). Weighted [1,M] undirected. Approx-Min-Cycle(G,s,t,w l,w u ) d[s] = 0 Controlled-Relax(s,w u ) While Q is not empty do u ← Extract-Min(Q) Controlled-Relax(u,t-w l ) Sketch: Analysis: More complicated. Some intuition: when a cycle is reported it is because we reach some vertex u twice. The bound is either 2t * - 2w l or t * + w u - w l. s=v i v i+1 =w * w *  [w l,w u ]

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 log nM). (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. Theorem: Given an undirected graph G with weights [1,M] there is an O(n² log n log nM) 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. Min-Cycle to Min-Triangle

Simple (and important) observation: Assume that we run just the first phase of Alg1 (t * +w * ) for a given t. We either compute all distances of length at most ½t from s or report a cycle of weight at most t. Weighted [1,M] undirected. Min-Cycle to Min-Triangle 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) RelaxOrStop(u,v) (u,v) ← Extract-Min(Q u ) R←{(u,v)} Approx-Min-Cycle(G,s,t) Q←{s} While Q is not empty do u ← Extract-Min(Q) Controlled-Relax(u,½t)

First stage: Binary search for the first t such that Approx-Min-Cycle(G,2t) does not report on a cycle and Approx-Min-Cycle(G,2t+2) reports. Weighted [1,M] undirected. Min-Cycle to Min-Triangle t+1 Report a cycle ≤2t+2 t No cycle is reported. All distances up to t are computed Need to show: If the Min-Cycle ≤ 2t+1 we can find it.

vjvj vivi v i+1 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 v i,v i+1, and v j  C such that: d C [v j,v i ]+w(v i,v i+1 )>t and d C [v i+1,v j ]+w(v i,v i+1 )>t Weighted [1,M] undirected. Min-Cycle to Min-Triangle ≤ 2t+1

vjvj vivi v i+1 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 v i,v i+1, and v j  C such that: d C [v j,v i ]+w(v i,v i+1 )>t and d C [v i+1,v j ]+w(v i,v i+1 )>t Weighted [1,M] undirected. Min-Cycle to Min-Triangle ≤ 2t+1 d C [v j,v i ] ≤ t d C [v i+1,v j ] ≤ t As this is a Min-Cycle d[v j,v i ] = d C [v j,v i ] d [v i+1,v j ]=d C [v i+1,v j ] and we have computed these distances !

Create a new graph G’: Weighted [1,M] undirected. Min-Cycle to Min-Triangle vjvj vivi v i+1 v2iv2i v1jv1j v 2 i+1 (V 1,ø) (V 2,E) Distances 

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 Ω(nM) (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. Weighted [1,M] undirected. Min-Cycle to Min-Triangle x1x1 y2y2 z2z2 y (V 1,ø) (V 2,E) Distances  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! x y z

We avoid the bad case and remain with the good case Weighted [1,M] undirected. Min-Cycle to Min-Triangle vjvj vivi v i+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!

Our 4/3-Approximataion: Alg1 (t* + w*) Weighted [1,M] undirected. Proof: Let (v i,v i+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 vivi v i+1 v2v2 v3v3 1. d C [s,v i ] ≤ ½ t 2. d C [s,v i+1 ]> ½ t We search for two vertices that satisfy: 1. d[s,v i ] ≤ d C [s,v i ] ≤ ½ t 2. d[s,v i+1 ] ≤½ t

Our 4/3-Approximataion: Alg1 (t* + w*) Weighted [1,M] undirected. 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. s=v 1 vivi v i+1 v2v2 v3v3 This means that: 1. d C [s,v ℓ-1 ] ≤ ½ t 2. d C [s,v ℓ ] ≤ ½ t A contradiction as w* ≤ ½ t vℓvℓ v ℓ-1 > ½ t

Download ppt "Minimum Weight Cycle Liam Roditty Bar-Ilan University Based on: Approximating the girth, (SODA`11) with Roei Tov (BIU) Minimum Weight Cycles and Triangles:"

Similar presentations