Finding cycles using rectangular matrix multiplication and dynamic

  • Slides: 29
Download presentation
Finding cycles using rectangular matrix multiplication and dynamic programming Raphael Yuster Haifa Univ. -

Finding cycles using rectangular matrix multiplication and dynamic programming Raphael Yuster Haifa Univ. - Oranim Uri Zwick Tel Aviv University 1

Matrix multiplication = Complexity Authors n 3 n 2. 81 folklore Strassen (1969) n

Matrix multiplication = Complexity Authors n 3 n 2. 81 folklore Strassen (1969) n 2. 38 Coppersmith, Winograd (1990) n ? ? ? 2

Rectangular Matrix multiplication a c b = a b a c b c c

Rectangular Matrix multiplication a c b = a b a c b c c a = b M(a, b, c) = M(b, c, a) = M(c, a, b) =. . . 3

Rectangular Matrix multiplication b a c c = a There also improved specially designed

Rectangular Matrix multiplication b a c c = a There also improved specially designed rectangular matrix multiplication algorithms 4

Chain Matrix Product • Let Ai be an ni ni+1 matrix. • Compute A

Chain Matrix Product • Let Ai be an ni ni+1 matrix. • Compute A 1 A 2…Ak. • Matrix multiplication is associative, so all association orders give the same result, but may have vastly different cost. • Easy to solve using dynamic programming. 5

Chain Matrix Product (cont. ) Let P(i, j) be the cost of computing Ai…Aj.

Chain Matrix Product (cont. ) Let P(i, j) be the cost of computing Ai…Aj. Complexity of naïve solution is O(k 3). For M(a, b, c)=abc, there is a much more complicated O(k log k) algorithm. 6

Finding triangles A triangle A graph Does the graph contain a triangle? Yes! 7

Finding triangles A triangle A graph Does the graph contain a triangle? Yes! 7

Algorithms for finding triangles Let A be the adjacency matrix of a graph G.

Algorithms for finding triangles Let A be the adjacency matrix of a graph G. Then, G contains a triangle iff A 2 AT≠ 0. Running time Authors mn folklore n < n 2. 38 folklore m 3/2 Itai-Rodeh ’ 78 m 2 /( -1) < m 1. 41 AYZ ’ 97 8

Finding triangles in O(m 2 /( -1)) time [AYZ ’ 97] Let be a

Finding triangles in O(m 2 /( -1)) time [AYZ ’ 97] Let be a parameter. = m( +1) /( -1). High degree vertices: vertices of degree . Low degree vertices: vertices of degree < . There at most 2 m/ high degree vertices = 9

Finding longer cycles A graph G contains a Ck iff Ak-1 AT≠ 0 ?

Finding longer cycles A graph G contains a Ck iff Ak-1 AT≠ 0 ? We want simple cycles! 10

Color coding [AYZ ’ 95] Assign each vertex v a random number c(v) from

Color coding [AYZ ’ 95] Assign each vertex v a random number c(v) from {0, 1, . . . , k-1}. Remove all edges (u, v) for which c(v)≠c(u)+1 (mod k). All cycles of length k in the graph are now simple. If a graph contains a Ck then with a probability of at least k - k it still contains a Ck after this process. An improved version works with probability 2 - O(k). Can be derandomized at a logarithmic cost. 11

Finding C 2 k in O(m 2 -1/k) time [AYZ ’ 97] Let be

Finding C 2 k in O(m 2 -1/k) time [AYZ ’ 97] Let be a parameter. = m 1/k. High degree vertices: vertices of degree . Low degree vertices: vertices of degree < . There at most 2 m/ high degree vertices = Finding paths of length k Finding a cycle passing through a high degree vertex 12

Algorithms for finding a Ck Running time Authors mn n < n 2. 38

Algorithms for finding a Ck Running time Authors mn n < n 2. 38 m 2 -1/ k/2 Monien ’ 85 AYZ ’ 97 [AYZ ’ 97]: “We have not been able to use fast matrix multiplication to obtain faster algorithms for finding Ck, for k 4, in sparse graphs. ” 13

Finding even cycles even faster [YZ ’ 97] In undirected graphs, a C 2

Finding even cycles even faster [YZ ’ 97] In undirected graphs, a C 2 k, for any fixed k, can be found in O(n 2) time! We are still working on: Finding odd cycles עוד יותר מהר 14

Algorithms for finding a C 4 Running time Authors mn n < n 2.

Algorithms for finding a C 4 Running time Authors mn n < n 2. 38 m 3/2 Monien ’ 85 m 2 -2/ n 1/ Eisenbrand, Grandoni ’ 03 m(4 -1)/(2 +1)<m 1. 48 YZ ’ 03 AYZ ’ 95 AYZ ’ 97 15

Finding C 4’s in 2 -2/ 1/ O(m n ) time [Eisendbrand, Grandoni ’

Finding C 4’s in 2 -2/ 1/ O(m n ) time [Eisendbrand, Grandoni ’ 03] Let be a parameter. . High degree vertices: vertices of degree . Low degree vertices: vertices of degree < . There at most 2 m/ high degree vertices 16

Finding C 4’s in O(m 2 -2/ n 1/ ) time [EG ’ 03]

Finding C 4’s in O(m 2 -2/ n 1/ ) time [EG ’ 03] 17

Finding C 4’s in (4 -1)/(2 +1) O(m ) time [YZ ’ 03] Let

Finding C 4’s in (4 -1)/(2 +1) O(m ) time [YZ ’ 03] Let be a parameter. High degree vertices: ≤ deg(v) Medium degree vertices: 1/2 ≤ deg(v) < Low degree vertices: deg(v) < 1/2 There at most 2 m/ high degree vertices. There at most 2 m/ 1/2 medium degree vertices. 18

Finding C 4’s in O(m(4 -1)/(2 +1)) time [YZ ’ 03] 19

Finding C 4’s in O(m(4 -1)/(2 +1)) time [YZ ’ 03] 19

 • Where do we go from here? • Why just three degree classes?

• Where do we go from here? • Why just three degree classes? • How many cases will we have for C 5, C 6, …? 20

The general case • Partition the vertices into log n degree classes: Vi={ v

The general case • Partition the vertices into log n degree classes: Vi={ v V | 2 i ≤ deg(v) ≤ 2 i+1 } • Number of cycle classes is only (log n)k. • What is the most efficient way of handling each class? 21

Handling a given cycle class Choose i and j. Find all paths of length

Handling a given cycle class Choose i and j. Find all paths of length j-i that pass through vertices of degrees di , …, dj. Find all paths of length k-(j-i) that pass through vertices of degrees dj , …, di. Check whether the graph contains a cycle from the class. 22

Finding paths Degree: Size of class: We get a chain matrix product problem! We

Finding paths Degree: Size of class: We get a chain matrix product problem! We can use the sparsity of the matrices. 23

Finding paths (cont. ) It is convenient to express everything as a power of

Finding paths (cont. ) It is convenient to express everything as a power of m. Degree: Size of class: 24

Finding cycles Theorem: There is an time algorithm for finding Ck’s in directed graphs.

Finding cycles Theorem: There is an time algorithm for finding Ck’s in directed graphs. 25

Finding C 5’s Theorem: Requires a non-constant number of degree classes. The worst-case running

Finding C 5’s Theorem: Requires a non-constant number of degree classes. The worst-case running time in obtained for regular graphs. 26

Finding C 6’s Conjecture: If the conjecture is true, then c 6<1. 65. 27

Finding C 6’s Conjecture: If the conjecture is true, then c 6<1. 65. 27

Finding odd cycles Conjecture: for odd k 3. The conjecture holds for k=3, 5.

Finding odd cycles Conjecture: for odd k 3. The conjecture holds for k=3, 5. 28

Open problems • Is it possible to extend the technique presented to obtained improved

Open problems • Is it possible to extend the technique presented to obtained improved algorithms? • Find a feasible way for rigorously computing c 6, c 7, etc. • Other applications? 29