Algorithms

Algorithms
Dynamic Programming
LCS (Longest Common Subsequence)
abcddeb
bdabaed
๐ด๐‘› = ๐ต๐‘š 1 + ๐‘‚๐‘๐‘ก(๐‘› โˆ’ 1, ๐‘š โˆ’ 1)
๐‘‚๐‘๐‘ก(๐‘›, ๐‘š โˆ’ 1)
๐‘‚๐‘๐‘ก(๐‘›, ๐‘š) = {
๐ด๐‘› โ‰  ๐ต๐‘š
max {
๐‘‚๐‘๐‘ก(๐‘› โˆ’ 1, ๐‘š)
๐‘‘
๐‘
๐‘Ž
๐‘
๐‘
๐‘Ž
๐œ™
0
0
0
0
0
0
0
๐œ™
1
1
0
0
๐‘
2
1
0
0
๐‘
0
๐‘‘
0
๐‘Ž
0
๐‘
0
๐‘
0
๐‘Ž
Ramsy Theory
Erdes and Szekeresh proved that given a permutation of {1, โ€ฆ , ๐‘›}, at least one increasing or
decreasing substring exists with length > โˆš๐‘›.
For example, observe the following permutation of {1, โ€ฆ ,10}:
10
5
8
1
4
3
6
2
7
9
(1,1)(1,2)(2,2)(1,3) โ€ฆ
The pairs present the number of the longest increasing substring and longest decreasing
substring till that point (accordingly).
Since every number raises the length of one of the substrings by one (either the increasing
or decreasing) each lengths pair is unique
Due to this fact, one of the numbers must be at least โˆš๐‘›
Bandwidth Problem
The bandwidth problem is an NP hard problem.
Definition: Given a symmetrical matrix, is there a way to switch the columns s.t. the
"bandwidth" of the matrix is smaller than a number received as input.
Another variant is to find the column switch that produces the smallest bandwidth.
The bandwidth of a matrix is defined as the largest difference between numbering of end
points.
0
1
1
0
1
1
1
0
1
1
0
0
1
0
0
Special Cases
If the graph is a line, it's very easy finding the smallest bandwidth (it's 1 โ€“ need to align the
vertices as a line). In case of "caterpillar" graphs however, the problem is already NP hard.
("Caterpillars" are graphs that consist of a line with occasional side lines)
Parameterized Complexity
Given a parameter k, does the graph have an arrangement with bandwidth โ‰ค k?
One idea, is to remember the last 6 vertices (including their order!), and simply remember
the vertices before and after (without order) so that we know not to repeat a vertex twice.
A trivial solution would be to simply remember them all. But while it's feasible to remember
๐‘›
the last 6 vertices, remembering the vertices we've passed takes up (๐‘— โˆ’ ๐‘˜ ) where ๐‘— is the
๐‘›
step index. In case of ๐‘— = 2 we would need time exponential in ๐‘›.
A breakthrough came in the early 80s by Saxe. The main idea is to remember the vertices
we've passed implicitly.
In order to do so, here are a few observations:
1) Wlog, ๐บ is connected (otherwise we can find the connected sub-graphs in linear
time and execute the algorithm independently on each of them, concatenating the
results at the end)
2) Maximal degree of the graph (if has bandwidth โ‰ค ๐‘˜) is โ‰ค 2๐‘˜.
Prefix
Active Region
Suffix
Due to these observations, a vertex is in the prefix, if it is connected to the active region
without using dangling edges.
A vertex in suffix must use dangling edges to connect to active region.
--------end of lesson 1
Color Coding
๐ด(๐‘ฅ)
The measure of complexity would be the expected running time (over random coin tosses of
the algorithm) for the worst possible input.
Monte Carlo Algorithms
There is no guarantee the solution is correct. It is probably correct.
Las Vegas Algorithms
You want the answer to be always correct. But the running time might differ.
Hamiltonian path
A simple path that visits all verties of a graph.
Logest Simple Path
TODO: Draw vertices
We are looking for the longest simple path from some vertex ๐‘ฃ to some vertex ๐‘ข.
Simple path means we are not allowed to repeat a vertex twice.
This problem is NP-Hard.
Given a parameter ๐‘˜ and find a simple path of length ๐‘˜.
A trivial algorithm would work in time ๐‘›๐‘˜ .
Algorithm 1
- Take a random permutation over the vertices.
- Remove every โ€œbackwardโ€ edge
- Find the longest path in remaining graph using dynamic programming
TODO: Draw linear numbering
For some permutation, some of the edges go forward, and some go forward. After removing
backward edges, we get a DAG.
For each vertex ๐‘ฃ from left to right, record length of longest path that ends at ๐‘ฃ.
Suppose the graph contains a path of length ๐‘˜.
What is the probability all edges of the path survived the first step?
The vertices have ๐‘˜! possible permutations, and only one permutation is good for us. So with
1
probability ๐‘˜! we will not drop the edges of the path and the algorithm succeeds.
This is not too good! If ๐‘˜ = 10 it is not too good!
So what do we do? Keep running it until it succeeds.
1
The probability of a failure is (1 โˆ’ (๐‘˜!)), but if we run it more than once it becomes:
1
๐‘๐‘˜!
(1 โˆ’ (๐‘˜!))
1 ๐‘
โ‰ˆ (๐‘’) expected running.
Expected running time ๐‘‚(๐‘›2 ๐‘˜!).
๐‘˜๐‘˜
log ๐‘›
You can approximate ๐‘˜! =โ‰ˆ ๐‘’ ๐‘˜ โ‰ค ๐‘›, ๐‘˜ โ‰… log log ๐‘›
Algorithm 2
- Color the vertices of the graph at random with ๐‘˜ colors.
- Use dynamic programming to find a colorful path.
1
2
โ€ฆ ๐‘˜
๐‘ฃ1 ๐‘†1
๐‘ฃ1 ๐‘†2
๐‘ฃ๐‘– + ๐‘†๐‘–
โ‹ฎ
๐‘˜
๐‘ฃ๐‘› ๐‘† 2
S is the set of colors we used so far.
๐‘˜!
๐‘˜๐‘˜
1
Probability that all vertices on path of length ๐‘˜ have different colors: ๐‘˜ ๐‘˜ โ‰ˆ ๐‘’ ๐‘˜ ๐‘˜ ๐‘˜ = ๐‘’ ๐‘˜
If ๐‘˜ โ‰… log ๐‘› then the success would be
1
.
๐‘›1โ€ฆ
Tournaments
A tournament is a directed graph in which for every pair of vertices there exists an edge (in
one direction). An edge exists if the player (represented by the vertex of origin) won another
player (represented by the second vertex).
We try to find the most consistent ranking of the players.
We want to find a linear order that minimizes the number of upsets.
An upset is an edge going in the other direction of another edge (tour?).
A Feedback Arc Set in a Tournament (FAST) is all the arcs that go backwards.
Another motivation
Suppose you want to open a Meta search engine. How can you aggregate the answers given
from the different engines?
TODO: Draw the rankingโ€ฆ
The problem is NP-Hard.
k-FAST
Find a linear alignment in which there are at most ๐‘˜ edges going backwards.
๐‘›
( )
0โ‰ค๐‘˜โ‰ค 2
2
We will describe an algorithm that is good for ๐‘› โ‰ค ๐‘˜ โ‰ค ๐‘Ž(๐‘›2 )
Suppose there are ๐‘ก subparts that have the optimal solution and we want to merge them
into a bigger solution.
If the graph ๐บ is partitioned into ๐‘ก parts, and we are given the โ€œtrueโ€ order within each part,
merging the parts takes time ๐‘›๐‘‚(๐‘ก) (O just for the bookkeeping).
Color Coding
Pick ๐‘ก (๐‘Ž ๐‘“๐‘ข๐‘›๐‘๐‘ก๐‘–๐‘œ๐‘› ๐‘œ๐‘“ ๐‘˜) and color the vertices independently with ๐‘ก colors.
We want that: For the minimum feedback arc set ๐น, every arc of ๐น has endpoints of distinct
colors. Denote it as โ€œ๐น is colorfulโ€.
Why is this desirable?
If ๐น is colorful, then for every color class we do know the true order.
We use the fact that this is a tournament! The order is unique due to the fact that between
every two vertices there is an arc (in some direction).
Lets look at two extreme cases:
1) ๐‘ก > 2๐‘˜ - the probability the second vertex gets the first color then the probability is
๐‘˜
๐‘ก
< 2. However, the runtime would be ๐‘›๐‘‚(๐‘˜)
2) ๐‘ก < โˆš๐‘˜ - not too good! Intuition: You have a โˆš๐‘˜ vertices where the direction of the
arcs is essentially random. So you can create a graph that has very bad chances
(didnโ€™t provide a real proof).
If ๐‘ก > 8โˆš๐‘˜ then with good probability โ€“ F is colorful. The probability behaves something
1
like: ๐‘›๐‘ก. Then the expected running time is ๐‘›๐‘ก , and with the previous running time the total
running time is still ๐‘›๐‘‚(๐‘ก) .
๐‘˜
1 ๐‘˜
1 ๐‘ก
โ†’ (1 โˆ’ ) โ‰ˆ ( ) โ†’ ๐‘ก โ‰… โˆš๐‘˜
๐‘ก
๐‘’
1 โˆš๐‘˜
( )
๐‘’
๐‘›๐‘‚(โˆš๐‘˜)
Lemma: Every graph with k edges has an ordering of its vertices in which no vertex has more
than โˆš2๐‘˜ forward edges.
Why is this true? Pick an arbitrary graph with k edges, and start arranging its edges with the
lowest degree first. So each time we put the vertex of lower degree of the suffix.
deg ๐‘– =degree of ๐‘ฃ๐‘–
๐‘‘๐‘– =number of forward edges of ๐‘ฃ๐‘–
๐‘  =๐‘›โˆ’๐‘–
๐‘‘ โ‰ค ๐‘  - Because a vertex can have one forward edge to every vertex to its right
๐‘‘ โ‰ค deg ๐‘– โ†’ ๐‘‘ โˆ™ ๐‘  โ‰ค deg ๐‘– โˆ™ ๐‘  โ‰ค โˆ‘๐‘—>๐‘– deg ๐‘— โ‰ค โˆ‘๐‘— deg ๐‘— = 2๐พ
Therefore, ๐‘‘2 โ‰ค 2๐พ โ†’ ๐‘‘ โ‰ค โˆš2๐พ.
The chance of failure for some vertex is bound by
๐‘‘๐‘–
๐‘ก
(each neighbor has a chance of having
๐‘‘
the wrong color). Therefore, the chance of success is at least 1 โˆ’ ๐‘ก๐‘–.
However, since ๐‘‘๐‘– is blocked by โˆš2๐พ, in order to have a valid expression, ๐‘ก must be larger
than โˆš2๐พ.
(1 โˆ’
โˆ (1 โˆ’
๐‘–
-------end of lesson 2
๐‘‘๐‘–
๐‘‘๐‘–
) โ‰… ๐‘’โˆ’ ๐‘ก
๐‘ก
โˆ‘ ๐‘‘๐‘–
๐‘‘๐‘–
2๐‘˜
๐‘‘๐‘–
) โ‰ค โˆ ๐‘’ โˆ’ ๐‘ก = ๐‘’ ๐‘ก = ๐‘’ โˆ’ ๐‘ก = ๐‘’ โˆ’โˆš๐‘˜
๐‘ก
Repeating last weekโ€™s lesson:
In every graph with ๐‘š edges, if we color its vertices at random with โˆš8๐‘š colors, then w.p. โ‰ฅ
(2๐‘’)โˆ’โˆš8๐‘š the coloring is proper.
Assume we color the graph with ๐‘ก colors.
TODO: Draw the example that shows the coloring is dependent.
Inductive Coloring
Given an arbitrary graph ๐บ, you find the vertex with the least degree in the graph. Then
remove that vertex. Then find the next one with the least degree and so onโ€ฆ
This determines an ordering of the vertices:
๐‘ฃ1 , ๐‘ฃ2 , โ€ฆ , ๐‘ฃ๐‘›
๐‘ฃ๐‘– - has the least degree in ๐บ(๐‘ฃ๐‘– , โ€ฆ , ๐‘ฃ๐‘› ).
Then we start by coloring the last vertex. Each time we color the vertex according to the
vertices to its right (so it will be proper).
If ๐‘‘ is the maximum right degree of any vertex, then inductive coloring uses at most ๐‘‘ + 1
colors.
In every planar graph, there is some vertex of degree at most 5.
Corollary: Planar graphs can be colored (easily) with 6 colors.
Every graph with ๐‘š edges, has an ordering of the vertices in which all right degrees are at
most โˆš2๐‘š.
So we need at least โˆš2๐‘š + 1 colors. But we donโ€™t want our chances of success to be too
low, so we use twice that number of colors - 2โˆš2๐‘š.
Let the list of degrees to the right - ๐‘‘1 , ๐‘‘2 , โ€ฆ , ๐‘‘๐‘› .
๐‘›
โˆ‘ ๐‘‘๐‘– = ๐‘š
๐‘–=1
What is the probability of violating the proper coloring for vertex ๐‘–?
Number of colors left for vertex ๐‘– -
๐‘กโˆ’๐‘‘๐‘–
๐‘ก
๐‘ก โˆ’ ๐‘‘๐‘–
๐‘‘๐‘–
โˆ(
) = โˆ (1 โˆ’ )
๐‘ก
๐‘ก
๐‘–
But we know
๐‘‘๐‘—
๐‘ก
โ‰ค
โˆš2๐‘š
โˆš8๐‘š
=
1
2
Itโ€™s easier to evaluate sums than products.
Suppose
๐‘‘๐‘—
๐‘ก
1
= ๐‘˜ (a very small number)
๐‘–
Why is this true:
1โˆ’
2
1
โ‰ฅ 2โˆ’๐‘˜
๐‘˜
Letโ€™s raise both sides:
๐‘˜
๐‘˜
2 2
1 2
1
(1 โˆ’ ) โ‰ฅ (2โˆ’๐‘˜ ) =
๐‘˜
2
1
1
As long as < , each power only chops off less than half of what remains meaning the left
๐‘˜
2
1
side wonโ€™t for below 2. So the inequality is true.
So, back to the original formula:
โˆ 2โˆ’
2๐‘‘๐‘–
๐‘ก
= 2โˆ’
๐‘‘
โˆ‘ ๐‘–
๐‘ก
๐‘š
= 2๐‘ก
๐‘–
Maximum weight independent set in a tree
Given a tree. In which, each vertex has a non-negative weight.
We need to select an independent set in the tree.
In graphs this problem is NP hard, but in trees we can do it in polynomial time.
TODO: Add a drawing of a tree
We pick an arbitrary vertex ๐‘Ÿ as the root.
We think of the vertices as being directed โ€œawayโ€ from the root.
Given a vertex ๐‘ฃ, denote by ๐‘‡(๐‘ฃ) as the set of vertices reachable from ๐‘ฃ (in the direction
from the root).
So for each vertex, we will keep two variables:
๐‘Š + (๐‘ฃ) โˆ’ is the maximum weight independent set in the tree ๐‘‡(๐‘ฃ), that contain ๐‘ฃ.
๐‘Š โˆ’ (๐‘ฃ) โˆ’ is the maximum weight independent set in the tree ๐‘‡(๐‘ฃ), that do not contain ๐‘ฃ.
Need to find ๐‘Š + (๐‘Ÿ), ๐‘Š โˆ’ (๐‘Ÿ) and the answer is the largest of the two.
The initialization is trivial. ๐‘Š + (๐‘ฃ) = ๐‘ค(๐‘ฃ) and ๐‘Š โˆ’ (๐‘ฃ) = 0.
For every leaf ๐‘™ of ๐‘‡, determine ๐‘Š + (๐‘™) = ๐‘ค(๐‘™), ๐‘Š โˆ’ (๐‘™) = 0 and remove it from the tree.
Pick a leaf of the remaining tree, with children ๐‘ข1 , โ€ฆ , ๐‘ข๐‘˜ .
๐‘˜
๐‘Š
+ (๐‘ฃ)
= ๐‘ค(๐‘ฃ) + โˆ‘ ๐‘Š โˆ’ (๐‘ข๐‘– )
๐‘–=1
๐‘˜
๐‘Š โˆ’ (๐‘ฃ) = 0 + โˆ‘ max{๐‘Š โˆ’ (๐‘ข๐‘– ), ๐‘Š + (๐‘ข๐‘– )}
๐‘–=1
This algorithm can also work on graphs that are slightly different than trees. (do private
calculations for the non-compatible parts).
Can we have a theorem of when the graph is just a bit different than a tree and still the
algorithm can run in polynomial time?
Tree Decomposition of a Graph
We have some graph ๐บ, and we want to represent it as a tree ๐‘‡.
Each node of the tree ๐‘‡ would represent a set of vertices of graph ๐บ.
Every node of the tree is labeled by a set of vertices of the original graph ๐บ.
Denote such sets as bags.
We also have the following constraints:
1) Moreover, the union of all these sets is all vertices of ๐บ.
2) Every edge โŒฉ๐‘ฃ๐‘– , ๐‘ฃ๐‘— โŒช in ๐บ is in some bag.
3) For every vertex ๐‘ฃ โˆˆ ๐บ, the bags containing ๐‘ฃ are connected in ๐‘‡. Meaning, that
they are connected with vertices that contain ๐‘ฃ, and do not have to pass through
vertices that do not contain ๐‘ฃ.
Given two bags - ๐ต1 and ๐ต2 ๐‘ . ๐‘ก. ๐ต1 โŠ† ๐ต2 , they are connected through a single path (because
itโ€™s a tree). This path must contain all vertices of ๐ต1 .
Tree Width of a Tree Decomposition
The Tree width of ๐‘‡ is ๐‘ if the maximal bag size is ๐‘ + 1.
Tree width of ๐บ is the smallest ๐‘ for which there is a tree decomposition of tree width ๐‘.
Intuitively โ€“ a graph is closer to a tree when its ๐‘ is smaller.
Properties regarding Tree width of graphs
Lemma: If ๐บ has tree width ๐‘, then ๐บ has a vertex of degree at most ๐‘.
Observe a tree decomposition of ๐บ.
It has some leaf ๐‘ฃ. The bag of this leaf has ๐‘ + 1 vertices at most. It has only one neighbor
(since itโ€™s a leaf).
Since no bag contains another bag, there is some vertex that exists in its neighbor that is not
in ๐‘ฃ. TODO: Copy the rest
Fact: ๐‘‡๐‘Š(๐บ\๐‘ฃ) โ‰ค ๐‘‡๐‘Š(๐บ). Since we can always take the original tree decomposition and
remove the vertex.
Corrolery: If ๐บ has tree width ๐‘ then ๐บ can be properly colored ๐‘ + 1 colors.
Indicates that if ๐บ is a tree, its tree width is 1 (since a tree is a bi-part graph and therefore
can be colored by 2 colors).
A graph with no edges has tree width 0, since you can have each bag as a singleton of a
vertex.
A complete graph on ๐‘› vertices has ๐‘‡๐‘Š = ๐‘› โˆ’ 1 (one bad holding all vertices)
A compete graph missing an edge โ€“ โŒฉ๐‘ข, ๐‘ฃโŒช has ๐‘‡๐‘Š = ๐‘› โˆ’ 1:
We can construct two bags โ€“ ๐บ โˆ’ ๐‘ข and ๐บ โˆ’ ๐‘ฃ and connect them.
Theorem: ๐บ has ๐‘‡๐‘Š = 1 iff ๐บ is a tree.
Assume ๐บ has ๐‘‡๐‘Š = 1. Has a vertex ๐‘ฃ of degree 1. Remove ๐‘ฃ. The graph is still a tree! So we
can continueโ€ฆ
We assume the graph is connected. But it doesnโ€™t have a cycled! If it had a cycle, we would
have a contradiction. A connected graph with no cycles is a tree.
Assume ๐บ is a tree. Lets construct the decomposition as follows:
Lets define each vertex as a bag with two vertices. An edge is connected to all edges that are
other edges of the contained vertices.
Series-Parallel graphs
TODO: Draw resistorsโ€ฆ
Series-Parallel graphs are exactly all graphs with ๐‘‡๐‘Š = 2.
Start from isolated vertices.
1) Add a vertex in series.
2) Add a self loop
3) Add an edge in parallel to an existing edge
4) Subdivide an edge
Series-Parallelโ‡’ ๐‘‡๐‘Š(2).
TODO: Draw
------ end of lesson 3
Graph Minor
A graph ๐ป is a minor of graph ๐บ if ๐ป can be obtained from ๐บ by:
(1) Removing vertices
(2) Removing edges
(3) Contracting edges
TODO: Draw graph
Definition: A sub-graph is a graph generated by removing edges and vetices
Definition: An induced sub-graph is a graph with a subset of the vertices that includes all
remaining edges.
Contracting an edge is joining the two vertices of the edge together, such that the new
vertex has edges to all the vertices the original vertices had.
A graph is planar if and only if it does not contain neither ๐พ5 nor ๐พ3,3 as a minor.
TODO: Draw the forbidden graphs
Definition: A graph is a tree or a forest if it doesnโ€™t contain a cycleโ‡”A clique of 3 vertices as
a minor.
A graph is Series parallel, if it does not contain a ๐‘˜4 as a minor.
Theorem: There are planar graphs on ๐‘› vertices with tree width ฮฉ(โˆš๐‘›)
Letโ€™s look at an โˆš๐‘› by โˆš๐‘› grid
โˆ™ โˆ’ โˆ™ โˆ’ โˆ™ โˆ’ โˆ™
|
|
|
|
โˆ™ โˆ’ โˆ™ โˆ’ โˆ™ โˆ’ โˆ™
|
|
|
|
โˆ™ โˆ’ โˆ™ โˆ’ โˆ™ โˆ’ โˆ™
|
|
|
|
โˆ™ โˆ’ โˆ™ โˆ’ โˆ™ โˆ’ โˆ™
We will construct โˆš๐‘› โˆ’ 1 bags.
A bag ๐‘– contains columns ๐‘– and ๐‘– + 1
Bags:
โˆ™ โˆ’ โˆ™
โˆ’ โˆ™ โ€ฆ
This is a tree decomposition by all the properties.
Vertex Separators
Vertex Separators: A set of ๐‘† of vertices in a graph ๐บ is a vertex separator if removing ๐‘† from
๐บ, the graph ๐บ decomposes into connected components of size at most
2๐‘›
3
TODO: Draw schematic picture of a graph
It means we can partition the connected components into two groups, none of them with
more than
2๐‘›
3
vertices.
Every tree has a separator of size 1
Let ๐‘‡ be a tree. Pick an arbitrary root ๐‘Ÿ.
๐‘‡(๐‘ฃ) =the size of the sub-tree of ๐‘ฃ (according to ๐‘Ÿ).
๐‘‡(๐‘Ÿ) = ๐‘›.
2
3
2
3
All leaves have size 1. So โˆƒ๐‘ฃ with ๐‘‡(๐‘ฃ) > ๐‘› and ๐‘‡(๐‘ข) โ‰ค ๐‘› for all children ๐‘ข of ๐‘ฃ.
That ๐‘ฃ is the separator.
If a graph ๐บ has tree width ๐‘, then it has a separator of size ๐‘ + 1.
My summary:
Let ๐ท be some tree decomposition.
Each bag has at most ๐‘ + 1 vertices. We can now find the separator of ๐ท and consider its
๐‘ + 1 vertices as the separator of the graph ๐บ.
Note that when we calculate ๐‘‡(๐‘ฃ) for some ๐‘ฃ โˆˆ ๐ท, we should count the number of vertices
inside the bags below it (not the number of bags).
His summary:
Consider a tree decomposition ๐‘‡ of width ๐‘.
Let ๐‘Ÿ serve as its root. And orient edges of ๐‘‡ away from ๐‘Ÿ.
2
Pick ๐‘† to be the lowest bag whose sub-tree contains more than 3 ๐‘› vertices.
Every Separator in the โˆš๐‘› by โˆš๐‘› grid is of size at least
โˆš๐‘›
6
Why is this so?
Letโ€™s assume otherwise. So there is such a separator.
Let ๐‘† be a set of
5โˆš๐‘›
6
โˆš๐‘›
6
vertices.
rows that do not contain a vertex from ๐‘†.
Same for columns.
Letโ€™s ignore all vertices in the same row or column with a vertex from ๐‘†.
So we ignore at most
โˆš๐‘›
6
โˆ™ โˆš๐‘› +
โˆš๐‘›
6
๐‘›
โˆ™ โˆš๐‘› = 3 vertices.
Claim: All other vertices are in the same connected component. Since we can walk on the
row and column freely (since no members of ๐‘† share the same row and column). Therefore
2
we have 3 ๐‘› connected components โ€“ A contradiction.
If ๐บ has tree width ๐‘, then ๐บ is colorable by ๐‘ + 1 colors.
Every planar graph is 5-colorable.
Proof: A planar graph has a vertex of degree at most 5.
We will use a variation of inductive coloring.
Pick the vertex with the smallest degree.
Assume we have a vertex with a degree 5. These 5 neighbors cannot form a clique! (since
the graph is planar)
So one edge is missing. Contract the two vertices of that missing edge with the center vertex
(the one with degree 5).
Fact: Contraction of edges maintains planarity. This is immediately seen when thinking of
bringing the edges closer in the plain.
Now we color the new graph (after contraction). Then we give all โ€œcontractedโ€ vertices the
same color in the original graph (before contraction).
After the contraction we have degree 4, so we can color it with 5 colors.
Hadwiger: Every graph that does not contain ๐พ๐‘ก as a minor, can be colored with ๐‘ก โˆ’ 1 colors.
(A generalization of the 4 colors theorem).
If a graph has tree width ๐‘, then we can find its chromatic number in time ๐‘‚(๐‘“(๐‘) โˆ™ ๐‘›)
Note: The number of colors is definitely between 1 and ๐‘ + 1 (we know it can be colored by
๐‘ + 1 colorsโ€ฆ The question is whether it can be colored with less).
For a value of ๐‘ก โ‰ค ๐‘, is ๐บ ๐‘ก-colorable?
Theorem (without proof): Given a graph of tree width ๐‘, a tree decomposition with tree
width ๐‘ can be found in time linear in ๐‘› โˆ™ ๐‘“(๐‘)
TODO: Draw the tree decomposition
For each bag, we will keep a table of size ๐‘ก ๐‘+1 of all possible colorings of its vertices. For
each entry in the table, we need to keep one bit that determines whether that coloring is
legal with the bags below that bag.
We can easily do it for every leaf (0/1 depending on: โ€œis this coloring is legal with sub-graph
below bag).
A coloring is legal if the sub-tree can be colored such that there is no collision of assignment
of colors.
A family ๐น of graphs is minor-closed (or closed under taking minors) if whenever ๐บ โˆˆ ๐น and
๐ป is a minor of ๐บ, then ๐ป โˆˆ ๐น.
Characterizing ๐น:
1) By some other property
2) List all graphs in the family (only if the family is finite)
3) List all graphs not in ๐น (if the complementary of the family is finite)
4) List all forbidden minors
5) List a minimal set of forbidden minors
For planar graphs, this minimal set was ๐พ5 and ๐พ3,3
A list of minors is a list of graphs: ๐บ1 , ๐บ2 โ€ฆ such that no graph is a minor of the other.
A conjecture by Wagner: Minor relation induces a โ€œwell quasi orderโ€โ‡”No infinite
antichain โ‡” A chain of graphs such that no graph is a minor of another graph.
So this is always a finite property!!!
The conjecture was proved by Robertson and Seymour.
----- End of lesson 4
Greedy Algorithms
When we try to solve a combinatorical problem, we have many options:
- Exhaustive Search
- Dynamic Programming
Now we introduce greedy algorithms as a new approach
Scheduling theory
Matroids
Interval Scheduling
There are jobs that need to be performed at certain times that take a certain time
๐‘—1 ๐‘ 1 โˆ’ ๐‘ก1
๐‘—2 ๐‘ 2 โˆ’ ๐‘ก2
โ‹ฎ
We canโ€™t schedule two jobs at the same time!
TODO: Draw intervals
We can represent the problem as a graph in which two intervals will share an edge if they
intersect. Then we will look for the maximal independent set.
Such a graph is called interval graph.
There are classes of graphs in which we can solve Independent Set in polynomial time. One
such family of graphs is Perfect graphs.
Algorithm: Sort intervals by earliest ending times and use a greedy algorithm to select the
interval that ends sooner. Remove all its intersecting intervals and repeat until no more
intervals remain.
Why does it work?
Proof:
Suppose the greedy algorithm picked some intervals ๐‘”1 , ๐‘”2 , โ€ฆ
Consider the optimal solution that has the largest common prefix with the greedy one:
๐‘œ1 , ๐‘œ2 , โ€ฆ
Consider first index ๐‘– such that ๐‘œ๐‘– โ‰  ๐‘”๐‘–
Since ๐‘”๐‘– ends at the same time (or sooner) than ๐‘œ๐‘– we can generate a new optimal solution
that has ๐‘”๐‘– instead of ๐‘œ๐‘– . Such a solution would still be optimal (same number of intervals)
and is legal โ‡’ there exists a solution with a larger common prefix, a contradiction!
Interval Scheduling 2
๐ฝ1 โˆถ ๐‘ค1 > 0, ๐‘™๐‘– > 0
๐ฝ1 โˆถ ๐‘ค1 > 0, ๐‘™๐‘– > 0
๐‘ค determines how important the job is. ๐‘™ determines how much time would it take for a CPU
to perform the job.
Penalty for job ๐‘– given a particular schedule is the ending time of ๐‘– × ๐‘ค๐‘–
Total penalty is โˆ‘๐‘– ๐‘๐‘  (๐‘–)
Find schedule ๐‘  than minimizes the total penalty.
๐ฝ1 โ€ฆ ๐ฝ๐‘– ๐ฝ๐‘— โ€ฆ
Letโ€™s flip some job:
๐ฝ1 , โ€ฆ ๐ฝ๐‘— ๐ฝ๐‘– โ€ฆ
And suppose that by flipping the order grew.
The penalty for the prefix and the suffix stays the same!
So we should only consider what happens to the penalty from ๐ฝ๐‘– , ๐ฝ๐‘— that resulted the switch
๐‘ค๐‘– (๐‘ก + ๐‘™๐‘– ) + ๐‘ค๐‘— (๐‘ก + ๐‘™๐‘– + ๐‘™๐‘— )
๐‘ค๐‘— (๐‘ก + ๐‘™๐‘— ) + ๐‘ค๐‘– (๐‘ก + ๐‘™๐‘— + ๐‘™๐‘– )
๐‘ค๐‘— ๐‘ค๐‘–
๐‘ค๐‘— ๐‘™๐‘– < ๐‘ค๐‘– ๐‘™๐‘— โ‡’
<
๐‘™๐‘—
๐‘™๐‘–
So this suggests the following algorithm:
Schedule jobs in decreasing order of
๐‘ค๐‘–
๐‘™๐‘–
This is optimal.
Proof: Consider any other schedule which does not respect this order.
Then there must be some ๐‘– in which
๐‘ค๐‘—
๐‘™๐‘—
<
๐‘ค๐‘–
๐‘™๐‘–
. Then we can reverse the order, and get a
better scheduling โ€“ a contradiction!
General Definition of Greedy-Algorithm solvable problems โ€“ Matroids
๐‘† = {๐‘’1 , โ€ฆ , ๐‘’๐‘› } (sometimes we have matroids in which the items represent edges)
๐น = a collection of subsets of ๐‘†. (Short for โ€œFeasibleโ€. Often called โ€œindependent setsโ€).
We want ๐น to be hereditary.
Hereditary - If ๐‘‹ โˆˆ ๐น, ๐‘Œ โŠ‚ ๐‘‹ โ‡’ ๐‘Œ โˆˆ ๐น
And we also need a cost function:
๐‘: ๐‘† โ†’ ๐‘… +
Find a set ๐‘‹ โˆˆ ๐น with maximum cost. โˆ‘๐‘’๐‘— โˆˆ๐‘‹ ๐‘(๐‘’๐‘— )
Example: Given a graph ๐บ, the items are the vertices of ๐บ. ๐น is the independent sets of ๐บ,
โˆ€๐‘ฅ. ๐‘(๐‘ฅ) = 1.
๐‘€๐ผ๐‘†(๐บ) is NP hard.
Definition: A hereditary family ๐น is a matroid, if and only if โˆ€๐‘‹, ๐‘Œ โˆˆ ๐น if |๐‘‹| > |๐‘Œ| then โˆƒ๐‘’ โˆˆ
๐‘‹, ๐‘’ โˆ‰ ๐‘Œ such that ๐‘Œ โˆช {๐‘’} โˆˆ ๐น.
Proposition: All maximal sets in a matroid have the same cardinality.
Suppose |๐‘‹| > |๐‘Œ|, then there should be some item in ๐‘‹ that we can add to ๐‘Œ to make it
feasible, and therefore ๐‘Œ does not have the maximal cardinality.
All maximal sets is called โ€œbasesโ€, and the cardinality of the maximal sets is called the โ€œrank
of the matroidโ€.
We have all sorts of terms: Matroids, Independent Sets, Basis, Rank. How are they related?
Consider a matrix. The items are the columns of the matrix.
The independent sets are columns that are linearly independent columns.
Note that it is hereditary. Because if a set of columns is linearly independent, then any
subsets is also linearly independent.
The basis of the matrix is the largest set of columns that spans the space. And the rank is
also the same as in linear algebra.
Theorem: For every hereditary family ๐น, the greedy algorithm finds the maximum solution
for every cost function ๐‘ โ‡” ๐น is a matroid
Greedy Algorithm: Iteratively, add to the solution the item ๐‘’๐‘— with largest cost that still keeps
the solution feasible.
Proof: Assume that F is not a matroid.
So (by definition) there are some sets ๐‘‹, ๐‘Œ such that |๐‘‹| > |๐‘Œ|, ๐‘‹, ๐‘Œ โˆˆ ๐น
and โˆ€๐‘’ โˆˆ ๐‘‹\๐‘Œ. ๐‘Œ โˆช {๐‘’} โˆ‰ ๐น.
1
๐‘›
โˆ€๐‘’ โˆˆ ๐‘Œ. ๐‘(๐‘’) = 1 + ๐œ– ๐œ– < if ๐‘› = |๐น| (or something similar)
โˆ€๐‘’ โˆˆ ๐‘‹\๐‘Œ. ๐‘(๐‘’) = 1
โˆ€๐‘’ โˆ‰ ๐‘‹ โˆช ๐‘Œ. ๐‘(๐‘’) = ๐œ– 2
Since the elements of ๐‘Œ have the highest cost, they will be selected until the set ๐‘Œ is chosen
and cannot increase any further. But the optimal solution would be to select the elements of
๐‘‹ โ€“ so the greedy algorithm does not solve the problem!
Suppose ๐น is a matroid.
Since ๐‘: ๐‘† โ†’ ๐‘… + - all weights are positive, the optimal solution is a basis.
But likewise, the greedy algorithm is also a basis
Sort items in solution in order of decreasing cost.
Suppose the items in the greedy solutions are ๐‘”1 , โ€ฆ , ๐‘”๐‘Ÿ where ๐‘Ÿ is the rank of the matroid.
And the items in the optimal solution are ๐‘œ1 , โ€ฆ , ๐‘œ๐‘Ÿ where ๐‘Ÿ is the rank of the matroid.
Suppose the maximum prefix is not the entire list of items. Suppose index ๐‘— is different. So
๐‘œ๐‘— โ‰  ๐‘”๐‘— but ๐‘œ๐‘—โˆ’1 = ๐‘”๐‘—โˆ’1 .
But we know that:
๐‘(๐‘”๐‘— ) โ‰ฅ ๐‘(๐‘œ๐‘— )
So letโ€™s build another optimal solution.
Observe the set:
๐‘œ1 , โ€ฆ ๐‘œ๐‘—โˆ’1 , ๐‘”๐‘—
Because this is a matroid, we definitely have some item in ๐‘œ1 , โ€ฆ , ๐‘œ๐‘—โˆ’1 , ๐‘œ๐‘— , โ€ฆ , ๐‘œ๐‘Ÿ that can be
added and still have an element of ๐น. We can continue doing so until the group is just as
large as ๐‘œ1 , โ€ฆ , ๐‘œ๐‘—โˆ’1 , ๐‘œ๐‘— , โ€ฆ , ๐‘œ๐‘Ÿ . But all added items have to be of the set {๐‘œ๐‘— , โ€ฆ , ๐‘œ๐‘Ÿ }.
But since all items are ordered all of them must have a cost โ‰ฅ ๐‘(๐‘œ๐‘— ) and ๐‘(๐‘œ๐‘— ) โ‰ค ๐‘(๐‘”๐‘— )
Greedy works also for general ๐‘, if the requirement is to find a basis.
Graphical Matroid
Graph ๐บ. items are edges of ๐บ.๐น - forests of ๐บ. Sets of edges that do not close a cycle. ๐บ is
connected โ€“ basesโ‡”spanning trees.
Greedy algorithm - Finds maximum weight spanning tree.
We can also find minimal spanning tree โ€“ Kruskalโ€™s algorithm.
----- End of lesson 5
Matroids โ€“ a hereditary family of sets ๐‘‹ โˆˆ ๐น, ๐‘Œ โŠ‚ ๐‘‹ โ‡’ ๐‘Œ โˆˆ ๐น
๐‘‹, ๐‘Œ โˆˆ ๐น, |๐‘‹| > |๐‘Œ| โ‡’ ๐‘’ โˆˆ ๐‘‹ ๐‘ . ๐‘ก. ๐‘Œ โˆช {๐‘’} โˆˆ ๐น
The natural greedy algorithm, given any cost function: ๐‘: ๐‘† โ†’ ๐‘… + , finds the independent set
(members of ๐‘†) of maximum total weight/cost.
The maximal sets in ๐‘“ all have the same cardinality, ๐‘Ÿ(rank). The maximal sets are called
โ€œbasisโ€.
๐‘†โ€ฒ โŠ‚ ๐‘†
And for every ๐‘‹ โŠ‚ ๐‘†, ๐‘‹ โˆˆ ๐น. ๐‘‹ โ€ฒ = ๐‘‹ โˆฉ ๐‘† โ€ฒ
This gives rise to a family ๐น โ€ฒ .
If (S, F) is a matroid, then so is (๐‘† โ€ฒ , ๐น โ€ฒ ) |๐‘‹ โ€ฒ | > |๐‘Œ โ€ฒ |
The rank of the new matroid is ๐‘Ÿ โ€ฒ โ‡’ ๐‘Ÿ โ€ฒ โ‰ค ๐‘Ÿ
Dual of a Matroid
Given a matroid (๐‘†, ๐น), itโ€™s dual (๐‘†, ๐น โˆ— ) is the collection of all sets where each ๐‘‹ satisfies
๐‘†\๐‘‹ still contains a basis for (๐‘†, ๐น)
In the graphical matroid:
๐‘† edges of graph ๐บ.
๐น - forests of graph ๐บ
The bases are the spanning trees of the graph.
๐น โˆ— - Any collection of edges that by removing it the graph is still connected.
Theorem: The dual ๐น โˆ— of matroid ๐น is a matroid by itself.
Moreover, (๐น โˆ— )โˆ— = ๐น.
Proof:
We need to show that the dual is hereditary โ€“ but this is easy to see. If we remove an item
from ๐‘ฅ, it still doesnโ€™t interfere with the bases of ๐‘†.
๐‘‹, ๐‘Œ โˆˆ ๐น โˆ— , |๐‘‹| > |๐‘Œ| โˆƒ๐‘’ โˆˆ ๐‘‹. ๐‘Œ โˆช {๐‘ฅ} โˆˆ ๐น โˆ—
TODO: Draw sets ๐‘‹ and ๐‘Œ.
Letโ€™s look at ๐‘† โ€ฒ = ๐‘† โˆ’ (๐‘‹ โˆช ๐‘Œ)
We know that (๐‘† โ€ฒ , ๐น โ€ฒ ) is a matroid, and it has rank ๐‘Ÿ โ€ฒ .
If ๐‘Ÿ โ€ฒ = ๐‘Ÿ we can move any item from ๐‘‹ to ๐‘Œ and we will still be in ๐น โˆ— .
So the only case we have a problem is when ๐‘Ÿ โ€ฒ < ๐‘Ÿ (it canโ€™t be larger).
๐ตโ€ฒ be a basis for (๐‘† โ€ฒ , ๐น โ€ฒ ). |๐ต| = ๐‘Ÿ โ€ฒ
๐‘Ÿ โˆ’ ๐‘Ÿ โ€ฒ โ‰ค |๐‘Œ\๐‘‹|
Complete ๐ตโ€ฒ to a basis of ๐น using ๐ต๐‘ฆ .
The number of elements of ๐ต๐‘ฆ that we use is exactly ๐‘Ÿ โˆ’ ๐‘Ÿ โ€ฒ โ‰ค ๐‘Œ\๐‘‹ < ๐‘‹\๐‘Œ.
So some item wasnโ€™t used in ๐‘‹\๐‘Œ!
We can take that item, and add it to ๐‘Œ and therefore still get a basis when ๐‘Œ plus that item is
removed from ๐‘†.
(๐น โˆ— )โˆ— = ๐น ?
Because the bases of the dual is just the complement of the bases of the original matroid.
|๐‘†| = ๐‘› Also all the bases of the dual are of size ๐‘› โˆ’ ๐‘Ÿ. ๐‘Ÿ โˆ— = ๐‘› โˆ’ ๐‘Ÿ.
How did we find the minimal spanning tree?
We sorted all weights by their weight, and added an edge in the spanning tree as long as it
doesnโ€™t close a cycle.
Minimum weight basis for ๐น=complement of maximum weight basis for ๐น โˆ— .
Graphical Matroids on Planar Graphs
TODO: Draw planar graphs
Every interior (a shape closed by edges) is denoted as a vertex. Then every two vertices are
connected if they share a common โ€œsideโ€ (or edge). The exterior is a single vertex.
A minimal cut set in the primal is a cycle in the dual.
The dual of a spanning tree is a spanning tree.
The complement of a spanning tree in the primal is a spanning tree in the dual.
Assume we have a planar graph with ๐‘ฃ vertices, ๐‘“ faces, and ๐‘’ edges.
๐‘ฃโˆ’1+๐‘“โˆ’1=๐‘’
We can always triangulate a planar graph, thus increasing the number of vertices but
keeping it planar.
In such graphs 3๐‘“ = 2๐‘’.
2๐‘’
๐‘ฃโˆ’1+
โˆ’1=๐‘’
3
๐‘’
๐‘ฃโˆ’2=
3
๐‘’ = 3๐‘ฃ โˆ’ 6
๐‘’
2 (๐‘ฃ) = 6 โˆ’
12
๐‘ฃ
= 6 minus something โ€“ at least one with 5 or less!
(๐‘†, ๐น1 ), (๐‘†, ๐น2 )
We can look at their intersection such that ๐‘‹ โˆˆ ๐น1 and ๐‘‹ โˆˆ ๐น2
Partition Matroid
Partition ๐‘† into:
๐‘†1 , ๐‘†2 , โ€ฆ , ๐‘†๐‘Ÿ
And every set that contains at most one item from each partition.
TODO: Draw stuff
A matching is a collection of edges where no two of them touch the same vertex.
The intersection of two partition matroids is the set of matchings in bipartite graph.
In a bipartite graph the set of matchings are not a matroid.
TODO: Draw example graph.
Theorem: For every cost function ๐‘: ๐‘† โ†’ ๐‘… +, one can optimize over the intersection of two
matroids in polynomial time.
Intersections of 3 matroids.
TODO: Draw partitions for the matroid.
Given a collection of triples โ€“ find a set of maximum cardinality of disjoint triples. This
problem is ๐‘๐‘ƒ-Hard.
Things we will see:
1) Algorithm for maximum cardinality matching in bipartite graphs.
2) Algorithm for maximum cardinality matching in arbitrary graphs.
3) Algorithm for maximum weight matching in bipartite graphs.
There is also an algorithm for maximum weight matching in arbitrary graphs, but we will not
show it in class.
Vertex cover โ€“ a set of vertices that cover (touch) all edges.
Min vertex cover โ‰ฅ maximum matching
Min vertex cover โ‰ค 2 โˆ™maximal matching.
For bipartite graphs minV.C.=max matching.
Alternating Paths
TODO: Draw graphs
Vertices not in our current matching will be called โ€œexposedโ€.
An alternating path connects two exposed vertices and edges alternates with respect to
being in the matching.
Given an arbitrary matching ๐‘€ and an alternating path ๐‘ƒ, we can get a larger matching by
switching the matching along ๐‘ƒ.
Alternating forest: A collection of rooted trees. The roots are the exposed vertices, and the
trees are alternating.
TODO: Draw alternating forest
In a single step:
- connect exposed vertices
- Add two edges to a tree (some tree)
The procedure to extend a tree:
Pick an outer vertex, and connect it to
- exposed vertex โ€“ alternating path โ€“ extend matching
- outer vertex โ€“ different tree. So we can get from a root of some tree to the root of
another tree.
- Extened the tree (alternating forest) by two edges.
Claim: When Iโ€™m stuck I certainly have a maximum matching.
Proof by picture.
Select the inner vertices as the vertex cover.
--- end of lesson 6
Matchings
TODO: Draw an alternating forest
1) If you find an edge between exposed vertices then you can just add it to the
matching
2) An edge between two outer vertices (in different trees) โ€“ alternating path
3) Edge from outer vertex (the exposed vertices are considered as outer vertices) to an
unused matching edge
In cases 1 and 2 we restart building a forest
Gallai-Edmondโ€™s Decomposition
Outer vertices ar denoted as ๐ถ (components)
Inner vertices are denoted as ๐‘† (separator)
The rest are denoted as ๐‘… (Rest)
We donโ€™t have edges between ๐ถ and itself otherwise the algorithm would not stop
We also donโ€™t have edges between ๐ถ and ๐‘… otherwise it wouldnโ€™t have stopped
In short, we may have edges between ๐ถ and ๐‘†, ๐‘† can have edges between it and itself, ๐‘† can
have edges between it and ๐‘… and ๐‘… can have edges between it and itself.
The only choice of matching we used are internal edges of ๐‘… and edges between C and ๐‘†.
All vertices of ๐‘… are matched, all vertices of ๐‘† are matched, and the number of vertices of ๐ถ
participate in the matching is |๐ถ| โˆ’ |๐‘†|
Another definition of ๐ถ, ๐‘† and ๐‘…:
๐ถ is the set of vertices that are not matched some maximum matching.
๐‘† is all neighbors of ๐ถ
๐‘… is the rest
The number of vertices not matched in a maximum matching is exactly |๐ถ| โˆ’ |๐‘†|.
General Graph
In general graphs we might have odd cycles. So case 2 doesnโ€™t work anymore (because an
edge can exist in the same tree)
We must have a new case:
2a) An edge between two outer vertices of the same tree.
In this case we get an odd cycle.
Contract the odd cycle! The contracted vertex is an outer vertex.
Suppose we had a graph ๐บ, and now we have ๐บ โ€ฒ as the contracted graph.
First note the following: Size of matching in ๐บ โ€ฒ is equal to size of matching in ๐บ โˆ’ ๐‘˜ if the
odd cycle had length 2๐‘˜ + 1.
Lift matching from ๐บ โ€ฒ to ๐บ and restart building a forest (instead of just restart building a
forest).
Now we can see why we call the outer vertices ๐ถ - since they might represent components
(contracted odd cycles)
Can be see that each component always represents an odd number of vertices.
Now, we might have components that might have edges to themselves, but not between
two components. So the separator really separates the different components from each
other and ๐‘†.
Vertices of ๐‘† are all matched. Components in ๐ถ are either connected to some vertex in ๐‘† or
none (at most connected to one vertex in ๐‘†)
But then this is the optimal matching! Which means that the algorithm is correct.
So the algorithm finds a matching that misses |๐ถ| โˆ’ |๐‘†|. But this is the minimal number of
edges we miss by any covering โ€“ so our solution is the optimal one.
Theorem: If in a graph there is a set ๐‘† of vertices where removal leaves in the graph ๐‘ก
components of odd size (and any number of components of even size, then the size of the
maximum matching is at most
๐‘›โˆ’(๐‘กโˆ’|๐‘†|)
2
Minimum Weight Perfect Matching in Bipartite Graphs
Weights are non-negative, and we try to find the perfect matching with the maximal weight.
Letโ€™s observe the variant where we search for a maximal weight.
If an edge is missing, we can add zeroes instead. Then a perfect matching always exist. And
then we can apply a transformation on the maximal variant to make it a minimal variant. So
the problem is well defined for non-perfect graphs.
We will use:
- Weight Shifting
- Primal-Dual method
In our case the primal problem โ€“ minimum weight covering of vertices by edges. But a
perfect matching is a covering problem with minimal weight.
The dual problem is the packing problem: Assign non-negative weights to the vertices such
that for every edge, sum of weights of its endpoints is at most weight the edge. Maximize
sum of weights of vertices.
TODO: Draw a bipartite graph
The primal is a minimization problem, so itโ€™s at least as large as the dual.
For optimal solution there is equality! We will show thatโ€ฆ
This is a theorem of Evergary of 1931
Letโ€™s try to reduce the problem to an easier problem.
Let ๐‘ค๐‘š the smallest weight of an edge
Subtract ๐‘ค๐‘š from the weight of every edge.
Every perfect matching contains exactly ๐‘› โˆ™ ๐‘ค๐‘š from its weight.
As for the dual problem, we can start with the weight of every vertex as 0, and increase the
weight of every vertex by
๐‘ค๐‘š
.
2
The dual we got is a feasible dual, and we decreased the
weight of the edges.
Let ๐‘ฃ be some vertex. We can subtract ๐‘ค๐‘ฃ from all of its edges. Since one of them has to be
in the final perfect matching, the perfect matching lost exactly ๐‘ค๐‘ฃ
And in the dual, we can increase the weight of ๐‘ฃ by ๐‘ค๐‘ฃ
We will keep the following claims true:
- For every edge, the amount of weight it loses is exactly equal to the number of
weight gained by its endpoints.
- At any state, edges have non-negative weights.
Consider only edges of zero weight and find maximum matching.
There are two possibilities now:
- It is a perfect matching. In this case it is optimal.
- Itโ€™s not a perfect matching. We can observe the Galai-Edmond decomposition of the
graph.
Let ๐œ– be the minimum weight of an edge between ๐ถ and ๐‘… or an edge of weight 2๐œ– between
๐ถ and ๐ถ.
For every vertex in ๐ถ, we will add to its weight +๐œ–
For every vertex is ๐‘† we will reduce its weight by ๐œ–
With respect to the matching, we did not change the weight. But we created one more zero
weight edge!
(Note that no edges became negative)
Either we increased the matching (for an edge between ๐ถ and ๐ถ)
Or we increased ๐‘† (for an edge between ๐ถ and ๐‘…, since the new connected component of ๐‘…
now belongs to ๐‘† since a neighbor of some vertex in ๐ถ)
Every time we make progress. So in ๐‘‚(๐‘›2 ) weight shifting steps, get a perfect matching of
weight zero.
--- end of lesson 7
Algebraic Methods for Solving Algorithms
Search of Triangles
By using exhaustive search, we can go over all triples and do it in ๐‘‚(๐‘›3 )
The question is, can we do it better?
Multipication of Two Complex Numbers
(๐‘Ž + ๐’พ๐‘)(๐‘ + ๐’พ๐‘‘) = ๐‘Ž๐‘ โˆ’ ๐‘๐‘‘ + ๐’พ(๐‘Ž๐‘‘ + ๐‘๐‘)
Assume the numbers are large!
Multiplications are rather expensive. Much more then addition and subtractions.
Letโ€™s compute ๐‘Ž๐‘, ๐‘๐‘‘, and then compute:
๐‘Ž + ๐‘ and then ๐‘ + ๐‘‘
And then calculate: (๐‘Ž + ๐‘)(๐‘ + ๐‘‘) = ๐‘Ž๐‘ + ๐‘Ž๐‘‘ + ๐‘๐‘ + ๐‘๐‘‘
But then we can use the previous values to extract ๐‘Ž๐‘‘ + ๐‘๐‘
So the naïve way uses 4 products and 2 additions/subtractions. The new way uses 3
products and 5 additions/subtractions.
Fast Matrix Multiplication
Suppose we have a matrix:
๐‘Ž11 ๐‘Ž12 โ€ฆ ๐‘Ž1๐‘›
โ‹ฎ
โ‹ฎ
๐ด=[ โ‹ฎ
๐ต = (๐‘๐‘–๐‘— ),
๐‘€ = ๐ด๐ต = (๐‘š๐‘–๐‘— ),
๐‘š๐‘–๐‘— = โˆ‘ ๐‘Ž๐‘–๐‘˜ ๐‘๐‘˜๐‘—
โ‹ฎ ],
๐‘˜
๐‘Ž๐‘›1 โ€ฆ โ€ฆ ๐‘Ž๐‘›๐‘›
So we need ๐‘›3 products to compute ๐‘€
Unlike the previous problem, we want to reduce both the number of products and the
number of additions.
We will show a very known algorithm by Strassen:
Assume for simplicity that ๐‘› is a power of 2. If not we can pad it with zeroes to the next
power of 2.
Letโ€™s partition ๐ด and ๐ต into blocks:
๐ด
๐ด12
๐ต
๐ต12
๐ด = [ 11
๐ต = [ 11
],
]
๐ด21 ๐ด22
๐ต21 ๐ต22
And then:
๐ด ๐ต + ๐ด12 ๐ต21
๐‘€ = [ 11 11
๐ด11 ๐ต12 + ๐ด12 ๐ต22
๐ด21 ๐ต11 + ๐ด22 ๐ต21
๐‘€
] = [ 11
๐ด21 ๐ต12 + ๐ด22 ๐ต22
๐‘€21
๐‘€12
]
๐‘€22
๐‘›
2
So ๐‘‡(๐‘›) = 8๐‘‡ ( ) + ๐‘‚(๐‘›2 )
After solving the recursion, we get:
๐‘‡(๐‘›) = ๐‘‚(8log ๐‘› ) = ๐‘›3
If we could compute everything by 7 multiplication (instead of 8) the time will be:
๐‘›
๐‘‡(๐‘›) = 7๐‘‡ ( ) + ๐‘‚(๐‘›2 ) = ๐‘‚(7log ๐‘› ) = ๐‘‚(๐‘›log 7 ) = (๐‘›2.8 )
2
๐ด11
๐ด12
๐ด21
๐ด22
๐ต11
๐‘€11
๐ต12
๐‘€12
๐‘€21
๐ต21
๐ต22
๐‘€11
๐‘€12
๐‘€21
๐‘€22
๐‘€22
Products:
For example:
0 + +
+ 0 + +
โˆ’ 0 โˆ’ โˆ’
0 0 0 0
0 0 0 0
0
0
0
0
0
What we want:
+ 0 0 0
0 0 + 0
0 0 0 0
0 0 0 0
If you think of pluses and minuses as +1 and -1 then we have a matrix of rank 2.
As we can see, every multiplication gives a matrix of rank 1!
So we must use 7 matrices of rank 1, and generate 8 matrices of rank 2.
+ +
0 0
๐‘ƒ1 = [
+ +
0 0
0
0
๐‘ƒ2 = [
0
0
0
0
0
0
0
0
] = (๐ด11 + ๐ด21 )(๐ต11 + ๐ต12 )
0
0
0 0 0
0 + +
] = (๐ด12 + ๐ด22 )(๐ต21 + ๐ต22 )
0 0 0
0 + +
We can observe that ๐‘ƒ1 + ๐‘ƒ2 = ๐‘€11 + ๐‘€12 + ๐‘€21 + ๐‘€22
In other words ๐‘€22 = ๐‘ƒ1 + ๐‘ƒ2 โˆ’ ๐‘€11 โˆ’ ๐‘€12 โˆ’ ๐‘€21
So we used two products and we can find one expression. We only need to calculate these
three expressions.
0 0 0 0
0 0 0 0
๐‘ƒ3 = [
] = ๐ด21 (๐ต11 + ๐ต21 )
+ 0 + 0
0 0 0 0
0 0 0 0
0 0 0 0
๐‘ƒ4 = [
] = (๐ด21 + ๐ด22 )๐ต21
0 0 โˆ’ 0
0 0 + 0
So we have that ๐‘€21 = ๐‘ƒ3 + ๐‘ƒ4
0
0
๐‘ƒ5 = [
0
0
0
0
๐‘ƒ6 = [
0
0
0 0 0
0+ 0 +
] = ๐ด12 (๐ต12 + ๐ต22 )
0 0 0
0 0 0
+ 0 0
โˆ’ 0 0
] = (๐ด11 โˆ’ ๐ด12 )๐ต12
0 0 0
0 0 0
So we already used 6 products, and generated ๐‘€12 , ๐‘€21 and are able to compute ๐‘€22 later.
We are only missing ๐‘€11 and only one multiplication left! Can we do it???
(the tension!)
0 0 0 0
0 โˆ’ + 0
๐‘ƒ7 = [
]
0 โˆ’ + 0
0 0 0 0
๐‘€11 = ๐‘ƒ7 + ๐‘ƒ1 โˆ’ ๐‘ƒ3 โˆ’ ๐‘ƒ6
We did it!! The world was saved!
But you can even multiply matrices faster!
If you divide the matrix into 70 parts you can find algorithms that solve it with ๐‘›2.79
The best known result is ๐‘›2.37.
Often people specify that matrices can be multiplied with ๐‘‚(๐‘›๐œ” ) and use it as a subroutine.
The final lower bound is ๐‘›2
Multiplying Big Numbers
Multiplying numbers of size ๐‘› takes ๐‘‚(๐‘›2 ) by using the naïve approach.
You can break every number into two and apply an approach similar to the one used when
multiplying complex numbers.
The best running time is something like: ๐‘› โˆ™ log ๐‘› โˆ™ log log ๐‘›โ€ฆ
Testing
How can you check that ๐ด โˆ™ ๐ต = ๐‘€ is correct?
Probabilistic test:
๐‘ฅ โˆˆ๐‘… โŸ
0011001 โ€ฆ
๐‘›
If you got the right answer:
๐ดโˆ™๐ตโˆ™๐‘ฅ =๐‘€โˆ™๐‘ฅ
But this is rather easy! A multiplication by a vector takes ๐‘‚(๐‘›2 ) time, and we can use
associativity on the left to multiply ๐‘ฅ by ๐ต first.
Suppose the true answer is ๐‘€, but we got ๐‘€โ€ฒ
So with a random vector, thereโ€™s a good probability that ๐‘€๐‘ฅ โ‰  ๐‘€โ€ฒ ๐‘ฅ
โ€ฒ
Since they are different, there must be that ๐‘€๐‘–๐‘— โ‰  ๐‘€๐‘–๐‘—
The chance is exactly ½ that we catch the bad matrix. The reason is too long for the shulaim
of this sikum.
The inverse of a matrix can also be calculated using matrix multiplication, so finding an
inverse takes ๐‘‚(๐‘›๐œ” ) as well.
Boolean Matrix Multiplication
There are settings in which subtraction is not allowed. One such setting is Boolean matrix
multiplication.
In this case, multiplication is an AND operation and addition is an OR operation.
So itโ€™s clear why we canโ€™t subtract.
In this case, we can replace OR with addition and AND with a regular multiplication then:
โ€ฒ
๐‘€๐‘–๐‘—
= 0 โ‡’ ๐‘€๐‘–๐‘— = 0
โ€ฒ
๐‘€๐‘–๐‘—
> 0 โ‡’ ๐‘€๐‘–๐‘— = 1
If you donโ€™t like big numbers, you can use everything under mod ๐‘ of some prime variable
But we can think of worst cases such that things stop working. Such as when the OR is
replaced by XOR.
Back to Search of Triangles
๐‘ฃ1 โ€ฆ โ€ฆ ๐‘ฃ๐‘›
โ‹ฎ
[โ‹ฎ
]
๐‘ฃ๐‘›
๐ด๐‘–๐‘— = 1 โ‡” (๐‘–, ๐‘—) โˆˆ ๐ธ
Otherwise itโ€™s zero.
Letโ€™s look at ๐ด2
๐ด2๐‘–๐‘— = 1 if thereโ€™s a path of length 2 between vertex ๐‘– and ๐‘—
So ๐ด2 is a matrix of the number of paths of size at most 2.
๐ด๐‘ก = # length ๐‘ก paths between ๐‘–, ๐‘—
So ๐ด3๐‘–๐‘– is the number of paths of size 3 from ๐‘– to itself.
But every such path is a triangle!
So ๐‘ก๐‘Ÿ๐‘Ž๐‘๐‘’(๐ด3 ) = # triangles in G times 6 (since for every triangle, there are 2 possible paths
from each of the vertices to itself)
But you can calculate ๐ด3 in ๐‘‚(๐‘›๐œ” )!
๐ด๐‘ก๐‘–๐‘— = 1 โ‡” there is a path of length at most ๐‘ก from ๐‘– to ๐‘—.
So ๐ด๐‘› actually โ€œhashesโ€ all reachability of a graph!
So by performing log ๐‘› โˆ™ ๐‘‚(๐‘›๐œ” ) operations we can find the closure of the graph.
--- end of lesson 8
Matrices and Permanents
Permanent ๐‘๐‘’๐‘Ÿ(๐ด) = โˆ‘๐œŽ โˆ๐‘›๐‘–=1 ๐‘Ž๐‘–,๐œŽ(๐‘–)
Determinant det(๐ด) = โˆ‘๐œŽ(โˆ’1)๐œŽ โˆ๐‘›๐‘–=1 ๐‘Ž๐‘–,๐œŽ(๐‘–)
det(๐ด) = 0 โ‡” ๐ด is singular
Valiant showed that: Computing the permanent is #๐‘ƒ complete. So ๐‘๐‘ƒ hard.
Even for 0,1 matrices.
TODO: Draw a neighbor matrix of a bipartite graph.
Permanent of a 0/1 matrix ๐ด is the same as the number of perfect matchings in the
associated bipartite graph.
๐‘ƒ๐‘’๐‘Ÿ(๐ด) (๐‘š๐‘œ๐‘‘ 2) = det(๐ด) (๐‘š๐‘œ๐‘‘ 2)
(because subtraction and addition are the same!)
๐‘ƒ๐‘’๐‘Ÿ(๐ด) (๐‘š๐‘œ๐‘‘ 3)
Suppose ๐‘› = 30
30 30
๐‘’
The number of permutations is 30! โ‰ˆ ( )
There is an algorithm that is still exponential but substantially faster.
It was suggested by Ryser, and its running time is around 2๐‘› . So in the case of 30, itโ€™s 230
which is not so bad.
The trick is to use the โ€œInclusion-Exclusionโ€ principle.
๐‘› × ๐‘› matrix ๐ด
๐‘† non-empty set of columns.
๐‘…๐‘– (๐‘†) โ€“ Sum of entries in row ๐‘– and columns from ๐‘†.
๐‘›
๐‘›โˆ’|๐‘†|
๐‘ƒ๐‘’๐‘Ÿ(๐ด) = โˆ‘(โˆ’1)
๐‘†
โˆ ๐‘…๐‘– (๐‘†)
๐‘–=1
Since we go over all ๐‘†, we have 2๐‘› terms. The running time is something around 2๐‘› times
some polynomial.
๐‘ฅ11
๐‘ƒ๐‘’๐‘Ÿ ( โ‹ฎ
๐‘ฅ๐‘›1
โ€ฆ ๐‘ฅ1๐‘›
โ‹ฑ
โ‹ฎ ) = โˆ‘ โˆ ๐‘ฅ๐‘–,๐œŽ(๐‘–) =
โ€ฆ ๐‘ฅ๐‘›
๐œŽ
๐‘–
Multilinear polynomial. ๐‘›! monomials. Each monomial is a product of variables. We have ๐‘›2
variables.
This applies both to the determinant and the permanent.
In Ryzerโ€™s formula we only get monomials with ๐‘› variables โ€“ 1 from each row.
In the original definition we also get monomials with ๐‘› variables โ€“ 1 from each row. But each
of them must be from a different column.
First letโ€™s see that all the terms that should be in Ryzerโ€™s formula are actually there.
โˆ๐‘›๐‘–=1 ๐‘ฅ๐‘–,๐œŽ(๐‘–) - only for ๐‘† = all columns.
This is a monomial that includes 5 variables but only 3 columns:
๐‘ฅ11 ๐‘ฅ21 ๐‘ฅ33 ๐‘ฅ32 ๐‘ฅ55
๐‘› variables, ๐‘ columns โ€“ {1,3,5}
๐‘โŠ‚๐‘†
The number of minus signs: โˆ‘๐‘†|๐‘โŠ‚๐‘†(โˆ’1)๐‘›โˆ’|๐‘†| โˆ™ 1 ๐‘‡๐‘’๐‘Ÿ๐‘š = 0
TODO: Draw many partially drawn matrices.
For every variable independently, substitute a random value {0, โ€ฆ , ๐‘ โˆ’ 1} ๐‘ > ๐‘›2 , ๐‘ is
prime. Then compute the determinant.
And we can even do the computations modulo ๐‘.
Lemma: For every multilinear polynomial in ๐‘›2 variables, if one substitutes random values
from 0, โ€ฆ , ๐‘ โˆ’ 1 and computes modulo prime ๐‘, the answer is 0 with probability at most
๐‘›2
.
๐‘
1
๐‘Ž๐‘ฅ + ๐‘ = 0 (๐‘š๐‘œ๐‘‘ ๐‘) the probability is ๐‘
๐‘˜
Suppose the probability is ๐‘ for ๐‘˜ variables. We want to show itโ€™s
๐‘˜+1
for ๐‘˜
๐‘
+ 1 variables.
We can look at the new polynomial as ๐‘(๐‘ฅ1 , โ€ฆ , ๐‘ฅ๐‘˜+1 ) ๐‘ฅ๐‘˜+1 (๐‘1 (๐‘ฅ1 , โ€ฆ , ๐‘ฅ๐‘˜ ) + ๐‘2 (๐‘ฅ1 , โ€ฆ , ๐‘ฅ๐‘˜ ))
๐‘˜
๐‘
If ๐‘1 and ๐‘2 are zero, this happens in probability (by induction) and otherwise, thereโ€™s only
one possible vale of ๐‘ฅ๐‘˜+1 such that everything is zero. So the total probability is
(๐‘˜+1)
๐‘
Kastaleyn: Computing the number of matchings in planar graphs is in polynomial graphs.
Kirchoff: Matrix-tree theorem. Counts the number of spanning trees in a graph.
We have a graph ๐บand we want the number of spanning trees.
Laplacian of ๐บ โ€“ ๐ฟ.
๐‘ฃ1
โ‹ฎ
๐‘ฃ๐‘›
๐‘ฃ1
๐‘‘1
0
โ€ฆ
โˆ’1
โ‹ฑ
๐‘ฃ๐‘›
๐‘‘๐‘›
๐‘™๐‘–,๐‘— = ๐‘™๐‘—,๐‘– = โˆ’1 โˆ™ (โŒฉ๐‘–, ๐‘—โŒช โˆˆ ๐ธ)
๐‘™๐‘–,๐‘– = degree of vertex ๐‘–
TODO: Draw the graph and its corresponding matrix
(though we got the point)
The algorithm: Generate the Laplacian matrix of the graph. Cross some row and column
(same column) and calculate the determinant. This is the number of spanning trees of the
graph.
Given ๐บ, Direct its edges arbitrarily. Create the incidence matrix of the graph.
๐‘ฃ1
๐‘ฃ2
๐‘ฃ3
๐‘ฃ4
๐‘’1 ๐‘’2 ๐‘’3 ๐‘’4
+1 0
0
0
โˆ’1 โˆ’1 +1 0
0
0 โˆ’1 โˆ’1
0 +1 0 +1
For each edge you put a +1 for the vertex it is entering and โˆ’1 for the vertex it leaves.
Denote this matrix ๐‘€.
If we multiply ๐‘€ โˆ™ ๐‘€๐‘‡ we get the Laplacian.
The incidence matrix has special properties. One of the properties is its โ€œTotally
Unimodulerโ€.
Totally unimodular: Every square sub-matrix has determinant either +1, โˆ’1 or 0.
Theorem: Every matrix in which every column has at most a single +1, at most a single โˆ’1
and rest of the entries are zero, is totally unimodular.
--- end of lesson
Given a graph ๐บ we have its Laplacian denoted ๐ฟ.
Also ๐‘€ is the vertex-edge incidence matrix.
We know that ๐‘€๐‘€๐‘‡ = ๐ฟ
Another thing we said about ๐‘€ is that itโ€™s totally unimodular. Which means that every
square submatrix has determinant either 0,1 or +1.
Wlog, we always look at the case where ๐‘š โ‰ฅ ๐‘› (๐‘š is the number of edges, ๐‘› is the number
of vertices).
If the number of edges is smaller than the number of vertices, either we can use all edges as
a spanning tree or we donโ€™t have a spanning tree.
๐‘Ÿ๐‘Ž๐‘›๐‘˜(๐‘€) โ‰ค ๐‘› โˆ’ 1
Letโ€™s observe the matrix transposed:
TODO: Draw a transposed incidence matrix.
If we take ๐‘ฅ = [1
Then ๐‘ฅ โˆˆ ker ๐‘€
โ€ฆ 1]
What do we know about a submatrix with a subset of the edges (but all the vertices)
If ๐‘† is a spanning tree, then the rank is ๐‘› โˆ’ 1.
Otherwise, then ๐‘Ÿ๐‘Ž๐‘›๐‘˜ < ๐‘› โˆ’ 1
๐‘‡
๐‘‡
det(๐‘€๐‘ โˆ’๐‘– โˆ™ ๐‘€๐‘ โˆ’๐‘–
) = det(๐‘€๐‘ โˆ’๐‘– ) โˆ™ det(๐‘€๐‘ โˆ’๐‘–
) = 1 if ๐‘† is a spanning tree and 0 otherwise.
Denote ๐‘€๐‘ โˆ’๐‘– = ๐‘€๐‘†โ€ฒ
So the number of spanning trees = โˆ‘๐‘† det ๐‘€๐‘†โ€ฒ โˆ™ det ๐‘€๐‘†โ€ฒ
Binet-Cauchy Formula for computing a determinant:
Let ๐ด and ๐ต be two matrices. Say ๐ด is ๐‘Ÿ × ๐‘› and ๐ต is ๐‘Ÿ × ๐‘›, ๐‘› > ๐‘Ÿ.
Then det ๐ด โˆ™ ๐ต๐‘‡ = โˆ‘๐‘†(det ๐ด๐‘† )(det ๐ต๐‘† )
(๐‘† ranges over all subsets of ๐‘Ÿ columns)
If ๐‘Ÿ = ๐‘› then det(๐ด โˆ™ ๐ต) = (det ๐ด) โˆ™ (det ๐ต)
If ๐‘Ÿ > ๐‘› the determinant is zero. So itโ€™s not interesting.
If ๐‘› > ๐‘Ÿ
Set ๐ด = ๐ต = ๐‘€โˆ’๐‘– . Then everything comes out.
Prove the Binet-Cauchy formula:
x1 0 0
ฮ” = [0 โ‹ฑ 0 ]
n×n
0 0 ๐‘ฅ๐‘›
matrix
det(๐ดฮ”๐ต๐‘‡ ) = โˆ‘(det ๐ด) โˆ™ (det BS ) โˆ™ (โˆ ๐‘ฅ๐‘– )
๐‘†
๐‘–โˆˆ๐‘†
We will prove this, and this is a stronger statement then the one we need to prove.
The answer ๐ดฮ”๐ต๐‘‡ is an ๐‘Ÿ × ๐‘Ÿ matrix:
Every entry in the matrix is a linear polynomial in the variable ๐‘ฅ๐‘– . Linear because we never
multiply an ๐‘ฅ๐‘– in ๐‘ฅ๐‘— . In addition we donโ€™t have any constant terms.
What is the determinant?
det(๐ดฮ”๐ต๐‘‡ ) is a homogenous polynomial of degree ๐‘Ÿ.
We can take any monomial of degree ๐‘Ÿ, and see that the coefficients in both cases are the
same.
On the right hand side we donโ€™t have any monomials of degree higher than ๐‘Ÿ or lower than
๐‘Ÿ. We need to prove they are zero on the left side.
๐‘‡ = a set of less then ๐‘Ÿ variables.
Substitute 0 for all variables which are not in ๐‘‡.
๐ดฮ”โ€ฒ ๐ต๐‘‡
BAAAAHHH. Canโ€™t write anything in this class!
Spectral Graph Theory
NP-Hard problems on random instances.
Like 3๐‘†๐ด๐‘‡, Hamiltonicity k-clique, etcโ€ฆ
We sometimes want to look at max-clique (which is the optimization version of k-clique).
We can also look at the optimization version of MAX-3SAT.
3XOR or 3LIN:
(๐‘ฅ1 โŠ• ฬ…ฬ…ฬ…
๐‘ฅ2 โŠ• ๐‘ฅ3 ) โ€ฆ
This problem is generally in ๐‘. But if we look for the maximal one we get an NP-Hard
problem.
Motivations:
- Average case (good news)
- Develop algorithmic tools
- Cryptography
- Properties of random objects
Heuristics:
3SAT: โ€œyesโ€ โ€“ Find a satisfying assignment in many cases (yes/maybe).
Refutation/โ€noโ€ โ€“ find a โ€œwitnessโ€ that guarantees that the formula is not satisfyable.
(no/maybe).
Hamiltonicity
๐บ๐‘›,๐‘ - Esdes-Rengi random graph model:
Between any two vertices independently, place an edge with probability ๐‘.
๐บ๐‘›,๐‘= 5 . The ๐‘ doesnโ€™t have to be a constant.
๐‘›
Process of putting edges in the graph at random one by one.
3SAT: At first, a short list of clauses is satisfyable. But as the formula becomes larger, it is not
so sure that it is satisfyable.
What is that point?
A conjecture is t 4.3 โˆ™ ๐‘›.
There is a proof of 3.5 โˆ™ ๐‘›.
However, there is a proof that this is a sharp transition.
For refutation, the condition is exactly opposite. The longer the formula, the easier it is to
find a witness for โ€œnoโ€.
--- end of lesson
Adjacency matrix:
0
1
[
] ๐‘Ž๐‘–,๐‘— = 1 โ‡” (๐‘–, ๐‘—) โˆˆ ๐ธ
โ‹ฑ
1
0
For regular graphs, there is no difference between the adjacency matrix and the laplacian.
For irregular graphs, we do have differences and we will not get into it.
Properties: Non-negative, symmetric, connected โ‡” irreducible
Irreducible means we cannot represent it as a block matrix such that the upper right block is
zeroes.
๐œ†1 โ‰ฅ ๐œ†2 โ‰ฅ โ‹ฏ โ‰ฅ ๐œ†๐‘› are all real, we might have multiplicities so we also allow equality.
๐‘ฃ1 , โ€ฆ , ๐‘ฃ๐‘› eigenvectors.
If we take two distinct eigenvalues ๐œ†๐‘– โ‰  ๐œ†๐‘— then ๐‘ฃ๐‘– โŠฅ ๐‘ฃ๐‘—
โ„๐‘› has an orthogonal basis using eigenvectors of ๐ด.
If we look at the eigenvector that corresponds to the largest eigenvalue, then the
eigenvector is positive (all its elements are positive).
๐œ†1 > ๐œ†2 ,
๐œ†1 โ‰ฅ |๐œ†๐‘› |
(The last 2 properties are only true if the graph is connected)
๐‘ฅ is an eigenvector with eigenvalue ๐œ† if ๐ด๐‘ฅ = ๐œ†๐‘ฅ
In graphs, if we have the adjacency matrix, and we multiply it by ๐‘ฅ.
The values of ๐‘ฅ corresponds to values we give to some of the vectices of ๐ด.
TODO: Draw graph.
If some ๐‘ฅ is an eigenvector of ๐ด, it means every vertex is given a value that is a multiple of
the values of its neighbors.
๐‘ก๐‘Ÿ๐‘Ž๐‘๐‘’๐ด = 0
โˆ‘ ๐œ†๐‘– = ๐‘ก๐‘Ÿ๐‘Ž๐‘๐‘’
Since ๐œ†1 > 0 โ‡’ ๐œ†๐‘› < 0
Bipartite Graphs
Let ๐‘ฅ be an eigenvector with non-zero eigenvalue ๐œ†.
TODO: Draw bipartite graph
By flipping the value of ๐‘ฅ on one site of the bipartite graph, we get a new eigenvector and it
has eigenvalue โ€“ ๐œ†.
This is a property only of bipartite graphs (as long as weโ€™re dealing with connected graphs).
Consider an eigenvector ๐‘ฅ. Then observe:
๐‘ฅ ๐‘‡ ๐ด๐‘ฅ
๐‘ฅ๐‘‡๐‘ฅ
This is called Rayleigh quotients
If ๐‘ฅ is an eigenvector of eigenvalue ๐œ† โ‡’
๐‘ฅ ๐‘‡ ๐œ†๐‘ฅ
๐‘ฅ๐‘‡๐‘ฅ
=
๐œ†
โˆ™
=๐œ†
๐‘ฅ๐‘‡๐‘ฅ
๐‘ฅ๐‘‡๐‘ฅ
Let ๐‘ฃ1 , โ€ฆ , ๐‘ฃ๐‘› be an orthonormal eigenvector basis of โ„๐‘› .
In this case:
๐‘ฅ = ๐‘Ž1 ๐‘ฃ1 + โ‹ฏ + ๐‘Ž๐‘› ๐‘ฃ๐‘› where ๐‘Ž๐‘– = โŒฉ๐‘ฅ, ๐‘ฃ๐‘– โŒช
๐ด (โˆ‘ ๐‘Ž๐‘– ๐‘ฃ๐‘– ) = โˆ‘ ๐‘Ž๐‘– ๐œ†๐‘– ๐‘ฃ๐‘–
โˆ‘ ๐‘Ž๐‘–2 ๐œ†๐‘–
โˆ‘ ๐‘Ž๐‘–2
This is like a weighted average where every ๐œ†๐‘– gets the weight ๐‘Ž๐‘–2
So this expression cannot be larger than ๐œ†1 and cannot be smaller than ๐œ†๐‘›
๐‘‡
(โˆ‘ ๐‘Ž๐‘– ๐‘๐‘– ) (โˆ‘ ๐‘Ž๐‘– ๐œ†๐‘– ๐‘ฃ๐‘– ) =
Suppose we know that ๐‘ฅ โŠฅ ๐‘ฃ1 ?
It means that the result is a weighted average of all vectors except for ๐œ†1
Another way of getting the same thing:
โˆ‘๐‘–,๐‘— ๐‘Ž๐‘–๐‘— ๐‘ฅ1 ๐‘ฅ๐‘— (element-wise multiplication of the matrix ๐ด and the matrix ๐‘ฅ โˆ™ ๐‘ฅ ๐‘‡ .
Large max cut โ‡’ ๐œ†๐‘› is close to โˆ’๐œ†1
Can show it using rayleighโ€™s quitients.
But the interesting thing is that the opposite direction is not so true!
We looked at the relation between ๐œ†1 and ๐œ†๐‘› . Now letโ€™s look at the relation between ๐œ†1 and
๐œ†2 .
If a graph is ๐‘‘-regular all 1 eigenvalue.
If we have a disconnected d-regular graph, ๐œ†1 , ๐œ†2 are equal! Since 111111 โ€ฆ is an
eigenvector of both ๐œ†1 and ๐œ†2 .
So if they are equal, the graph is disconnected!
What happens if they are close to being equal?
๐œ†2 close to ๐œ†1 , then ๐บ close to being disconnected!
Suppose we have a graph.
TODO: Draw the graph we are supposed to have.
We perform a random walk on a graph. What is the mixing time?
If a token starts at a certain point, what is the probability it will be in any of the other
vertices? If it turns quickly into a uniform distribution then the mixing is good.
Small cuts are obstacles of fast mixing.
If we started on the first vertex, we can say we started with the (probabilities) vector:
[1 0 โ€ฆ 0]
๐ด โˆ‘ ๐‘Ž๐‘– ๐‘ฃ๐‘–
๐‘‘
๐ด๐‘ก
If I do ๐‘ก steps of the random walk itโ€™s: ๐‘‘๐‘ก (โˆ‘ ๐‘Ž๐‘– ๐‘ฃ๐‘– ) =
โˆ‘ ๐‘Ž๐‘– (๐œ†๐‘– )๐‘ก ๐‘ฅ๐‘–
๐‘‘๐‘ก
If ๐œ†๐‘– โ‰ซ |๐œ†๐‘™ | then we get a uniform distribution over all vertices.
๐€๐Ÿ for non-regular graphs
Suppose the graph has maximum degree ฮ” and average degree ๐‘‘.
So we know ๐œ†1 โ‰ค ฮ”
But this is always true: ๐œ†1 โ‰ฅ ๐‘‘
๐‘ฅ ๐‘‡ = (1,1, โ€ฆ 1) and consider
๐‘ฅ ๐‘‡ ๐ด๐‘ฅ
๐‘ฅ๐‘‡๐‘ฅ
So:
๐‘ฅ ๐‘‡ ๐ด๐‘ฅ
๐‘ฅ๐‘‡๐‘ฅ
= sum over all entries of ๐ด =
2๐‘š
๐‘›
โ‰ฅ average degree.
c-core of a graph is the largest subgraph in which every vertex has degree โ‰ฅ ๐‘.
Let ๐‘ โˆ— be the largest ๐‘ for which the graph ๐‘” has a c-core.
At ๐‘‘-regular graphs ๐‘ โˆ— = ๐‘‘.
๐œ†1 โ‰ค ๐‘ โˆ—
๐‘ฃ is the eigenvector associated with ๐œ†1 . Sort vertices by their value in the vector ๐‘ฃ.
So ๐‘ฃ1 is the largest value and ๐‘ฃ๐‘› is the smallest. And all numbers are positive (according to
the provinious bla bla theorem).
The graph cannot have a ๐œ†1 + 1-core.
(a vertex cannot be connected to ๐œ†1 neighbors above it, since then it cannot equal to a
multiple ๐œ†1 of the values of its neighbors)
If we look at a star graph
ฮ” = ๐‘›โˆ’1
๐‘‘ = 2 (a bit less than)
And the largest eigenvalue ๐œ†1 = โˆš๐‘› โˆ’ 1
We can give the center โˆš๐‘› โˆ’ 1 and the rest 1.
Sometimes when we have a graph that is nearly regular but have a small number of vertices
with a high degree, we should remove the vertices of high degree since they skew the
spectrum!
Letโ€™s use ๐›ผ(๐บ) to denote the size of the maximum independent set in the graph.
And letโ€™s assume that ๐บ is ๐‘‘-regular.
๐›ผ(๐บ) โ‰ค โˆ’
๐‘›๐œ†๐‘›
๐‘‘ โˆ’ ๐œ†๐‘›
๐บ is bipartite. Then ๐œ†๐‘› = โˆ’๐œ†1 and then ๐›ผ(๐บ) =
Proof: ๐œ†๐‘› โ‰ค
๐‘ฅ ๐‘‡ ๐ด๐‘ฅ
๐‘ฅ๐‘‡๐‘ฅ
๐‘›๐œ†1
2๐œ†1
๐‘›
=2
โˆ€๐‘ฅ
Let ๐‘† be the largest independent set in ๐บ.
TODO: Draw ๐‘ฅ
So the entries of ๐‘  will equal ๐‘› โˆ’ ๐‘  and the other vertices will be โ€“ ๐‘ 
0
0 |
๐‘‘ โˆ™ ๐‘  1โ€ฒ ๐‘ 
| โˆ’๐‘ (๐‘› โˆ’ ๐‘ )
0
0 |
|
โˆ’
โˆ’ +
โˆ’
โˆ’
โˆ’
โˆ’ +
โˆ’
โˆ’ =
๐‘‘ โˆ™ ๐‘  1โ€ฒ ๐‘ 
| ๐‘‘ โˆ™ (๐‘› โˆ’ 2๐‘ ) 1โ€ฒ ๐‘ 
โˆ’๐‘ (๐‘› โˆ’ ๐‘ )
|
๐‘ 2
|
]
|
[
] [
๐‘  2 (๐‘›๐‘‘ โˆ’ 2๐‘‘๐‘ ) โˆ’ 2๐‘ (๐‘› โˆ’ ๐‘ )๐‘‘๐‘  ๐‘  2 ๐‘›๐‘‘ โˆ’ 2๐‘‘๐‘  3 โˆ’ 2๐‘  2 ๐‘›๐‘‘ + 2๐‘‘๐‘  3
๐‘ ๐‘‘
๐œ†1 โ‰ค
=
=โˆ’
๐‘ (๐‘› โˆ’ ๐‘ )2 + (๐‘› โˆ’ ๐‘ )๐‘  2
๐‘›โˆ’๐‘ 
๐‘ (๐‘› โˆ’ ๐‘ )((๐‘› โˆ’ ๐‘ ) + ๐‘ )
(๐‘› โˆ’ ๐‘ )2
๐œ†๐‘› โˆ™ ๐‘› โˆ’ ๐œ†๐‘› ๐‘  โ‰ค โˆ’๐‘‘๐‘ 
๐‘ (๐‘‘ โˆ’ ๐œ†๐‘› ) โ‰ค โˆ’๐œ†๐‘› ๐‘›
โˆ’๐œ†๐‘› ๐‘›
๐‘ โ‰ค
๐‘‘ โˆ’ ๐œ†๐‘›
If |๐œ†๐‘› | โ‰ช ๐‘‘ we get a very good bound. Otherwise we donโ€™t.
โˆ‘ ๐œ†๐‘– = 0
We can also look at the trace of ๐ด2 = โˆ‘(๐œ†๐‘– )2
On the other hand, it is also โˆ‘ ๐‘‘๐‘–
Only for regular graphs, this is ๐‘› โˆ™ ๐‘‘
So it follows that the average square value: ๐ด๐‘ฃ๐‘”(๐œ†2๐‘– ) = ๐‘‘
๐ด๐‘ฃ๐‘”|๐œ†๐‘– | โ‰ค โˆš๐‘‘
Recall that ๐œ†1 = ๐‘‘!
It turns out that in random graphs (regular or nearly regular).
With high probability โˆ€๐‘– โ‰  1 โ‡’ |๐œ†๐‘– | = ๐‘‚(โˆš๐‘‘)
In almost all graphs, |๐œ†1 | โ‰ซ |๐œ†๐‘› |
โˆ’๐œ† ๐‘›
2โˆš๐‘‘๐‘›
Therefore: ๐‘  โ‰ค ๐‘‘โˆ’๐œ†๐‘› โ‰ค ๐‘‘+2โˆš๐‘‘ โ‰ค
๐‘›
2๐‘›
โˆš๐‘‘