THE BIG IDEAS OF MULTIPLICATION AND DIVISION. WHAT IS MULTIPLICATION? WHEN DO WE USE MULTIPLICATION?
Finding cycles using rectangular matrix multiplication and dynamic programming
description
Transcript of Finding cycles using rectangular matrix multiplication and dynamic programming
![Page 1: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/1.jpg)
1
Finding cycles using Finding cycles using rectangular matrix multiplication rectangular matrix multiplication
and dynamic programmingand dynamic programming
Raphael Yuster Raphael Yuster Haifa Univ.Haifa Univ. -- OranimOranim
Uri Zwick Uri Zwick Tel Aviv UniversityTel Aviv University
![Page 2: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/2.jpg)
2
Matrix multiplication
= ij ik kjc a bi ja i jb
ComplexityAuthors
n3folklore
n2.81Strassen (1969)
n2.38Coppersmith, Winograd (1990)
n???
![Page 3: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/3.jpg)
3
Rectangular Matrix multiplication
=
ab
c
abc
c
b c
a a
b
=
M(a,b,c) = M(b,c,a) = M(c,a,b)... =
![Page 4: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/4.jpg)
4
Rectangular Matrix multiplication
a
bc
c
= a
2If , then ( , , )a c
b a c M a b c b ab cb b
3( , , )
min{ , , }
abcM a b c
a b c
There are also improved specially designed rectangular matrix multiplication algorithms
![Page 5: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/5.jpg)
5
Chain Matrix Product
• Let Ai be an ni ni+1 matrix.
• Compute A1A2…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.
![Page 6: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/6.jpg)
6
Chain Matrix Product (cont.)
Let P(i,j) be the cost of computing Ai…Aj.
1 2( , 1) ( , , )i i iP i i M n n n
( , ) min ( , ) ( , ) ( , , )i r ji r jP i j P i r P r j M n n n
Complexity of naïve solution is O(k3).
For M(a,b,c)=abc, there is a much more complicated O(k log k) algorithm .
![Page 7: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/7.jpg)
7
Finding triangles
A triangle
A graph
Does the graph contain a triangle? Yes!
![Page 8: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/8.jpg)
8
Algorithms for finding triangles
Let A be the adjacency matrix of a graph G.
Then, G contains a triangle iff A2AT≠0.
Running timeAuthors
mnfolklore
n < n2.38folklore
m3/2Itai-Rodeh ’78
m2 /(+1) < m1.41AYZ ’97
![Page 9: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/9.jpg)
9
Finding triangles in O(m2 /(+1)) time [AYZ ’97]
Let be a parameter. . High degree vertices: vertices of degree .Low degree vertices: vertices of degree < .
There are at most 2m/ high degree vertices
2m m=
= m(-1) /(+1)
![Page 10: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/10.jpg)
10
Finding longer cycles
A graph G contains a Ck iff Ak-1AT≠0 ?
We want simple cycles!
![Page 11: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/11.jpg)
11
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.
![Page 12: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/12.jpg)
12
Finding C2k in O(m2-1/k) time [AYZ ’97]
Let be a parameter. . High degree vertices: vertices of degree .Low degree vertices: vertices of degree < .There are at most 2m/ high degree vertices
= m1/k
Finding paths of length k
1km
mm
Finding a cycle passing through a high degree
vertex
=
![Page 13: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/13.jpg)
13
Algorithms for finding a Ck
Running timeAuthors
mnMonien ’85
n < n2.38AYZ ’95
m2-1/k/2AYZ ’97
[AYZ ’97]:“We have not been able to use fast matrix
multiplication to obtain faster algorithms for finding Ck, for k4, in sparse graphs.”
![Page 14: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/14.jpg)
14
Finding even cycles even faster [YZ ’97]
In undirected graphs, a C2k, for any fixed k, can be found in O(n2) time!
We are still working on:Finding odd cycles עוד יותר מהר
![Page 15: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/15.jpg)
15
Algorithms for finding a C4
Running timeAuthors
mnMonien ’85
n < n2.38AYZ ’95
m3/2AYZ ’97
m 2-2/ n1/Eisenbrand,
Grandoni ’03
m(4-1)/(2+1)<m1.48YZ ’03
![Page 16: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/16.jpg)
16
Let be a parameter. . High degree vertices: vertices of degree .Low degree vertices: vertices of degree < .There are at most 2m/ high degree vertices
Finding C4’s in O(m 2-2/ n1/) time
[Eisendbrand, Grandoni ’03]
![Page 17: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/17.jpg)
17
Finding C4’s in O(m 2-2/ n1/) time
[EG ’03]
m mm
, ,m mm M n
m
![Page 18: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/18.jpg)
18
Let be a parameter.
High degree vertices: ≤ deg(v) Medium degree vertices: 1/2 ≤ deg(v) < Low degree vertices: deg(v) < 1/2
There are at most 2m/ high degree vertices.There are at most 2m/1/2 medium degree vertices.
Finding C4’s in O(m(4-1)/(2+1)) time [YZ ’03]
![Page 19: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/19.jpg)
19
Finding C4’s in O(m(4-1)/(2+1)) time [YZ ’03]
m mm
, ,m m mm M
m m
![Page 20: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/20.jpg)
20
• Where do we go from here?
• Why just three degree classes?
• How many cases will we have for C5, C6, …?
![Page 21: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/21.jpg)
21
The general case
• Partition the vertices into log n degree classes: Vi={ vV | 2i ≤ deg(v) ≤ 2i+1 }
• Number of cycle classes is only (log n)k.
• What is the most efficient way of handling each class?
![Page 22: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/22.jpg)
22
Handling a given cycle class
jd1kd
id2d
1d
0d
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.
![Page 23: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/23.jpg)
23
Finding paths
kd2d1d
1
m
d
Degree:
Sizeof class:
k
m
d2
m
d
We get a chain matrix product problem!
We can use the sparsity of the matrices.
![Page 24: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/24.jpg)
24
Finding paths (cont.)
kdm2dm1dmDegree:
Sizeof class:
1 kdm 21 dm 11 dm
It is convenient to express everything as a power of m.
1
1
( , 1)
( , ) min ( 1, )
max ( , ), ( , ), (1 ,1 ,1 )
j
ii r j
i r j
P i j d
P i j P i j d
P i r P r j M d d d
( , 1) 1P i i
![Page 25: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/25.jpg)
25
Finding cycles
0 1 1 ,
max ( , ), ( , )( , , , ) min
2k k i ji
P i j P j iC d d d
d
0 1 10 , , , 1 0 1 1max ( , , , )kk d d d k kc C d d d
Theorem: There is an time algorithm for finding Ck’s in directed graphs.
( )kcO m
![Page 26: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/26.jpg)
26
Finding C5’s
Theorem: 5
31.63
2c
5
1 1 1 1 1 3( , , , , )2 2 2 2 2 2
C
Requires a non-constant number of degree classes.
The worst-case running time is obtained for regular graphs.
![Page 27: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/27.jpg)
27
Finding C6’s
Conjecture:
10 3 134 4 6
22 4 13 917 4 6 4
6 11 2 9 164 5 4 7
10 16 57 7 2
2if
ifc
if
if
If the conjecture is true, then c6<1.65.
![Page 28: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/28.jpg)
28
Finding odd cycles
Conjecture: for odd k3.( 1)
(2 1)k
kc
k
The conjecture holds for k=3,5.
![Page 29: Finding cycles using rectangular matrix multiplication and dynamic programming](https://reader036.fdocuments.in/reader036/viewer/2022062520/5681572f550346895dc4cc45/html5/thumbnails/29.jpg)
29
Open problems
• Is it possible to extend the technique presented to obtain improved algorithms?
• Find a feasible way for rigorously computing c6, c7, etc.
• Other applications?