SlideShare a Scribd company logo
Treewidth – Dynamic Programming
Saket Saurabh
Institute of Mathematical Sciences, India
´
(Based on the slides of Daniel Marx)
ASPAK 2014: March 3-8

Treewidth – Dynamic Programming – p.1/24
Treewidth

Introduction and definition – DONE
Part I: Algorithms for bounded treewidth graphs.
Part II: Graph-theoretic properties of treewidth.
Part III: Applications for general graphs.

Treewidth – Dynamic Programming – p.2/24
Treewidth

Treewidth – Dynamic Programming – p.3/24
Treewidth
Treewidth: A measure of how “tree-like” the graph is.
a

(Introduced by Robertson and Seymour.)
Tree decomposition: Vertices are arranged in a tree

b

c

d

e

f

g

structure satisfying the following properties:
1. If u and v are neighbors, then there is a bag containing both of them.

h

2. For every vertex v , the bags containing v form a
connected subtree.

c, d, f
b, c, f
a, b, c

d, f , g

b, e, f

g, h

Treewidth – Dynamic Programming – p.4/24
Treewidth
Treewidth: A measure of how “tree-like” the graph is.
a

(Introduced by Robertson and Seymour.)
Tree decomposition: Vertices are arranged in a tree

b

c

d

e

f

g

structure satisfying the following properties:
1. If u and v are neighbors, then there is a bag containing both of them.

h

2. For every vertex v , the bags containing v form a
connected subtree.

c, d, f
b, c, f
a, b, c

d, f , g

b, e, f

g, h

Treewidth – Dynamic Programming – p.4/24
Treewidth
Treewidth: A measure of how “tree-like” the graph is.
a

(Introduced by Robertson and Seymour.)
Tree decomposition: Vertices are arranged in a tree

b

c

d

e

f

g

structure satisfying the following properties:
1. If u and v are neighbors, then there is a bag containing both of them.

h

2. For every vertex v , the bags containing v form a
connected subtree.

c, d, f
b, c, f
a, b, c

d, f , g

b, e, f

g, h

Treewidth – Dynamic Programming – p.4/24
Treewidth
Treewidth: A measure of how “tree-like” the graph is.
a

(Introduced by Robertson and Seymour.)
Tree decomposition: Vertices are arranged in a tree

b

c

d

e

f

g

structure satisfying the following properties:
1. If u and v are neighbors, then there is a bag containing both of them.

h

2. For every vertex v , the bags containing v form a
connected subtree.
Width of the decomposition: largest bag size −1.
treewidth: width of the best decomposition.
Fact: treewidth = 1 ⇐⇒ graph is a forest

c, d, f
b, c, f
a, b, c

d, f , g

b, e, f

g, h

Treewidth – Dynamic Programming – p.4/24
Treewidth
Treewidth: A measure of how “tree-like” the graph is.
a

(Introduced by Robertson and Seymour.)
Tree decomposition: Vertices are arranged in a tree

b

c

d

e

f

g

structure satisfying the following properties:
1. If u and v are neighbors, then there is a bag containing both of them.

h

2. For every vertex v , the bags containing v form a
connected subtree.
Width of the decomposition: largest bag size −1.
treewidth: width of the best decomposition.
Fact: treewidth = 1 ⇐⇒ graph is a forest

c, d, f
b, c, f
a, b, c

d, f , g

b, e, f

g, h

Treewidth – Dynamic Programming – p.4/24
Treewidth
Treewidth: A measure of how “tree-like” the graph is.
a

(Introduced by Robertson and Seymour.)
Tree decomposition: Vertices are arranged in a tree

b

c

d

e

f

g

structure satisfying the following properties:
1. If u and v are neighbors, then there is a bag containing both of them.

h

2. For every vertex v , the bags containing v form a
connected subtree.
Width of the decomposition: largest bag size −1.
treewidth: width of the best decomposition.
Fact: treewidth = 1 ⇐⇒ graph is a forest

c, d, f
b, c, f
a, b, c

d, f , g

b, e, f

g, h

Treewidth – Dynamic Programming – p.4/24
Finding tree decompositions

Fact: It is NP-hard to determine the treewidth of a graph (given a graph G and an
integer w , decide if the treewidth of G is at most w ), but there is a polynomial-time
algorithm for every fixed w .
Fact: [Bodlaender’s Theorem] For every fixed w , there is a linear-time algorithm that
finds a tree decomposition of width w (if exists).

⇒ Deciding if treewidth is at most w is fixed-parameter tractable.
⇒ If we want an FPT algorithm parameterized by treewidth w of the input graph, then
we can assume that a tree decomposition of width w is available.

Treewidth – Dynamic Programming – p.5/24
Finding tree decompositions

Fact: It is NP-hard to determine the treewidth of a graph (given a graph G and an
integer w , decide if the treewidth of G is at most w ), but there is a polynomial-time
algorithm for every fixed w .
Fact: [Bodlaender’s Theorem] For every fixed w , there is a linear-time algorithm that
finds a tree decomposition of width w (if exists).

⇒ Deciding if treewidth is at most w is fixed-parameter tractable.
⇒ If we want an FPT algorithm parameterized by treewidth w of the input graph, then
we can assume that a tree decomposition of width w is available.
Running time is 2O(w

3)

· n. Sometimes it is better to use the following results instead:

Fact: There is a O(33w · w · n2 ) time algorithm that finds a tree decomposition of width

4w + 1, if the treewidth of the graph is at most w .

Fact: There is a polynomial-time algorithm that finds a tree decomposition of width

√
O(w log w ), if the treewidth of the graph is at most w .

Treewidth – Dynamic Programming – p.5/24
Part I:
Algoritmhs for
bounded-treewidth graphs

Treewidth – Dynamic Programming – p.6/24
W EIGHTED M AX I NDEPENDENT S ET
and tree decompositions

Fact: Given a tree decomposition of width w , W EIGHTED M AX I NDEPENDENT S ET can
be solved in time O(2w · n).

c, d, f

Bx : vertices appearing in node x .
Vx : vertices appearing in the subtree rooted at x .

b, c, f
Generalizing our solution for trees:

d, f , g

b, e, f

a, b, c

g, h

Instead of computing 2 values A[v ], B[v ] for each
vertex of the graph, we compute 2|Bx | ≤ 2w +1

values for each bag Bx .

M[x, S]: the maximum weight of an independent
set I ⊆ Vx with I ∩ Bx = S .

∅ =?
b =?
c =?
f =?

bc =?
cf =?
bf =?
bcf =?

How to determine M[x, S] if all the values are known for
the children of x ?
Treewidth – Dynamic Programming – p.7/24
Nice tree decompositions

Definition: A rooted tree decomposition is nice if every node x is one of the following
4 types:
Leaf: no children, |Bx | = 1
Introduce: 1 child y , Bx = By ∪ {v } for some vertex v
Forget: 1 child y , Bx = By  {v } for some vertex v
Join: 2 children y1 , y2 with Bx = By1 = By2
Leaf

Introduce

Forget

Join

v

u, v , w

u, w

u, v , w

u, w

u, v , w

u, v , w

u, v , w

Fact: A tree decomposition of width w and n nodes can be turned into a nice tree
decomposition of width w and O(wn) nodes in time O(w 2 n).

Treewidth – Dynamic Programming – p.8/24
W EIGHTED M AX I NDEPENDENT S ET
and nice tree decompositions

Leaf: no children, |Bx | = 1
Trivial!

Introduce: 1 child y , Bx = By ∪ {v } for some vertex v

m[x, S] =


m[y , S]






if v ∈ S,

m[y , S  {v }] + w (v ) if v ∈ S but v has no neighbor in S ,

−∞

if S contains v and its neighbor.

Leaf

Introduce

Forget

Join

v

u, v , w

u, w

u, v , w

u, w

u, v , w

u, v , w

u, v , w
Treewidth – Dynamic Programming – p.9/24
W EIGHTED M AX I NDEPENDENT S ET
and nice tree decompositions

Forget: 1 child y , Bx = By  {v } for some vertex v

m[x, S] = max{m[y , S], m[y , S ∪ {v }]}
Join: 2 children y1 , y2 with Bx = By1 = By2

m[x, S] = m[y1 , S] + m[y2 , S] − w (S)

Leaf

Introduce

Forget

Join

v

u, v , w

u, w

u, v , w

u, w

u, v , w

u, v , w

u, v , w
Treewidth – Dynamic Programming – p.9/24
W EIGHTED M AX I NDEPENDENT S ET
and nice tree decompositions

Forget: 1 child y , Bx = By  {v } for some vertex v

m[x, S] = max{m[y , S], m[y , S ∪ {v }]}
Join: 2 children y1 , y2 with Bx = By1 = By2

m[x, S] = m[y1 , S] + m[y2 , S] − w (S)

There are at most 2w +1 · n subproblems m[x, S] and each subproblem can be solved
in constant time (assuming the children are already solved).

⇒ Running time is O(2w · n).
⇒ W EIGHTED M AX I NDEPENDENT S ET is FPT parameterized by treewidth.
⇒ W EIGHTED M IN V ERTEX C OVER is FPT parameterized by treewidth.

Treewidth – Dynamic Programming – p.9/24
3-C OLORING and
tree decompositions
Fact: Given a tree decomposition of width w , 3-C OLORING can be solved in O(3w · n).

Bx : vertices appearing in node x .
Vx : vertices appearing in the subtree rooted at x .

For every node x and coloring c : Bx → {1, 2, 3},

c, d, f
b, c, f

d, f , g

we compute the Boolean value E [x, c], which is

true if and only if c can be extended to a proper

g, h

b, e, f

a, b, c

3-coloring of Vx .
bcf=T
bcf=T

bcf=F
bcf=F

...

...

How to determine E [x, c] if all the values are known for
the children of x ?
Treewidth – Dynamic Programming – p.10/24
3-C OLORING and
nice tree decompositions

Leaf: no children, |Bx | = 1
Trivial!

Introduce: 1 child y , Bx = By ∪ {v } for some vertex v

If c(v ) = c(u) for every neighbor u of v , then E [x, c] = E [y , c ′ ], where c ′ is c
restricted to By .
Forget: 1 child y , Bx = By  {v } for some vertex v

E [x, c] is true if E [y , c ′ ] is true for one of the 3 extensions of c to By .
Join: 2 children y1 , y2 with Bx = By1 = By2

E [x, c] = E [y1 , c] ∧ E [y2 , c]
Leaf

Introduce

Forget

Join

v

u, v , w

u, w

u, v , w

u, w

u, v , w

u, v , w

u, v , w
Treewidth – Dynamic Programming – p.11/24
3-C OLORING and
nice tree decompositions

Leaf: no children, |Bx | = 1
Trivial!

Introduce: 1 child y , Bx = By ∪ {v } for some vertex v

If c(v ) = c(u) for every neighbor u of v , then E [x, c] = E [y , c ′ ], where c ′ is c
restricted to By .
Forget: 1 child y , Bx = By  {v } for some vertex v

E [x, c] is true if E [y , c ′ ] is true for one of the 3 extensions of c to By .
Join: 2 children y1 , y2 with Bx = By1 = By2

E [x, c] = E [y1 , c] ∧ E [y2 , c]
There are at most 3w +1 · n subproblems E [x, c] and each subproblem can be solved in

constant time (assuming the children are already solved).

⇒ Running time is O(3w · n).
⇒ 3-C OLORING is FPT parameterized by treewidth.

Treewidth – Dynamic Programming – p.11/24
Vertex coloring

More generally:
Fact: Given a tree decomposition of width w , c -C OLORING can be solved in O ∗ (c w ).
Exercise: Every graph of treewidth at most w can be colored with w + 1 colors.
Fact: Given a tree decomposition of width w , V ERTEX C OLORING can be solved in
time O ∗ (w w ).

⇒ V ERTEX C OLORING is FPT parameterized by treewidth.

Treewidth – Dynamic Programming – p.12/24
Hamiltonian cycle and
tree decompositions

Fact: Given a tree decomposition of width w , H AMILTONIAN CYCLE can be solved in
time w O(w ) · n.

Bx : vertices appearing in node x .
Vx : vertices appearing in the subtree rooted at x .

0
Bx

1
Bx

2
Bx

x

If H is a Hamiltonian cycle, then the subgraph

H[Vx ] is a set of paths with endpoints in Bx .
What are the important properties of H[Vx ] “seen
from the outside world”?
0
1
2
The subsets Bx , Bx , Bx of Bx having degree

Vx

0, 1, and 2.
1
The matching M of Bx .
0
1
2
Number of subproblems (Bx , Bx , Bx , M) for each node x : at most 3w · w w .
Treewidth – Dynamic Programming – p.13/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
For each subproblem (Bx , Bx , Bx , M), we have to determine if there is a set of paths

with this pattern.
How to do this for the different types of nodes?
(Assuming that all the subproblems are solved for the children.)
Leaf: no children, |Bx | = 1
Trivial!

Treewidth – Dynamic Programming – p.14/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Forget: 1 child y , Bx = By  {v } for some vertex v
0
1
2
In a solution H of (Bx , Bx , Bx , M), vertex v has degree 2. Thus subproblem
0
1
2
0
1
2
(Bx , Bx , Bx , M) of x is equivalent to subproblem (Bx , Bx , Bx ∪ {v }, M) of y .
0
Bx

1
Bx

2
Bx

Treewidth – Dynamic Programming – p.15/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Forget: 1 child y , Bx = By  {v } for some vertex v
0
1
2
In a solution H of (Bx , Bx , Bx , M), vertex v has degree 2. Thus subproblem
0
1
2
0
1
2
(Bx , Bx , Bx , M) of x is equivalent to subproblem (Bx , Bx , Bx ∪ {v }, M) of y .
0
Bx

1
Bx

2
Bx

v

Treewidth – Dynamic Programming – p.15/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Forget: 1 child y , Bx = By  {v } for some vertex v
0
1
2
In a solution H of (Bx , Bx , Bx , M), vertex v has degree 2. Thus subproblem
0
1
2
0
1
2
(Bx , Bx , Bx , M) of x is equivalent to subproblem (Bx , Bx , Bx ∪ {v }, M) of y .
0
Bx

1
Bx

2
Bx

v

Treewidth – Dynamic Programming – p.15/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Introduce: 1 child y , Bx = By ∪ {v } for some vertex v
0
0
1
2
Case 1: v ∈ Bx . Subproblem is equivalent with (Bx  {v }, Bx , Bx , M) for node y .

0
Bx

v

1
Bx

2
Bx

x

Treewidth – Dynamic Programming – p.16/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Introduce: 1 child y , Bx = By ∪ {v } for some vertex v
0
0
1
2
Case 1: v ∈ Bx . Subproblem is equivalent with (Bx  {v }, Bx , Bx , M) for node y .

0
Bx

v

1
Bx

0
By

2
Bx

x

1
By

2
By

y

Treewidth – Dynamic Programming – p.16/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Introduce: 1 child y , Bx = By ∪ {v } for some vertex v
0
0
1
2
Case 1: v ∈ Bx . Subproblem is equivalent with (Bx  {v }, Bx , Bx , M) for node y .

0
Bx

v

1
Bx

0
By

2
Bx

x

1
By

2
By

y

Treewidth – Dynamic Programming – p.16/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Introduce: 1 child y , Bx = By ∪ {v } for some vertex v
0
0
1
2
Case 1: v ∈ Bx . Subproblem is equivalent with (Bx  {v }, Bx , Bx , M) for node y .

0
Bx

v

1
Bx

0
By

2
Bx

x

⇐

1
By

2
By

y

Treewidth – Dynamic Programming – p.16/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Introduce: 1 child y , Bx = By ∪ {v } for some vertex v
1
Case 2: v ∈ Bx . Every neighbor of v in Vx is in Bx . Thus v has to be adjacent with one

other vertex of Bx .

0
1
2
Is there a subproblem (By , By , By , M ′ ) of node y such that making a vertex of By
0
1
2
adjacent to v makes it a solution for subproblem (Bx , Bx , Bx , M) of node x ?

0
Bx

2
Bx

1
Bx

v

x

Treewidth – Dynamic Programming – p.16/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Introduce: 1 child y , Bx = By ∪ {v } for some vertex v
1
Case 2: v ∈ Bx . Every neighbor of v in Vx is in Bx . Thus v has to be adjacent with one

other vertex of Bx .

0
1
2
Is there a subproblem (By , By , By , M ′ ) of node y such that making a vertex of By
0
1
2
adjacent to v makes it a solution for subproblem (Bx , Bx , Bx , M) of node x ?

0
Bx

2
Bx

1
Bx

v

x

Treewidth – Dynamic Programming – p.16/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Introduce: 1 child y , Bx = By ∪ {v } for some vertex v
1
Case 2: v ∈ Bx . Every neighbor of v in Vx is in Bx . Thus v has to be adjacent with one

other vertex of Bx .

0
1
2
Is there a subproblem (By , By , By , M ′ ) of node y such that making a vertex of By
0
1
2
adjacent to v makes it a solution for subproblem (Bx , Bx , Bx , M) of node x ?

0
Bx

0
By

2
Bx

1
Bx

v

x

1
By

2
By

y

Treewidth – Dynamic Programming – p.16/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Introduce: 1 child y , Bx = By ∪ {v } for some vertex v
1
Case 2: v ∈ Bx . Every neighbor of v in Vx is in Bx . Thus v has to be adjacent with one

other vertex of Bx .

0
1
2
Is there a subproblem (By , By , By , M ′ ) of node y such that making a vertex of By
0
1
2
adjacent to v makes it a solution for subproblem (Bx , Bx , Bx , M) of node x ?

0
Bx

0
By

2
Bx

1
Bx

v

x

1
By

2
By

y

Treewidth – Dynamic Programming – p.16/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Introduce: 1 child y , Bx = By ∪ {v } for some vertex v
1
Case 2: v ∈ Bx . Every neighbor of v in Vx is in Bx . Thus v has to be adjacent with one

other vertex of Bx .

0
1
2
Is there a subproblem (By , By , By , M ′ ) of node y such that making a vertex of By
0
1
2
adjacent to v makes it a solution for subproblem (Bx , Bx , Bx , M) of node x ?

0
Bx

1
Bx

0
By

2
Bx

v

x

⇐

1
By

2
By

y

Treewidth – Dynamic Programming – p.16/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Introduce: 1 child y , Bx = By ∪ {v } for some vertex v
2
Case 3: v ∈ Bx . Similar to Case 2, but 2 vertices of By are adjacent with v .

0
Bx

1
Bx

2
Bx
v

x

Treewidth – Dynamic Programming – p.16/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Introduce: 1 child y , Bx = By ∪ {v } for some vertex v
2
Case 3: v ∈ Bx . Similar to Case 2, but 2 vertices of By are adjacent with v .

0
Bx

1
Bx

2
Bx
v

x

Treewidth – Dynamic Programming – p.16/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Introduce: 1 child y , Bx = By ∪ {v } for some vertex v
2
Case 3: v ∈ Bx . Similar to Case 2, but 2 vertices of By are adjacent with v .

0
Bx

1
Bx

2
Bx
v

0
By

x

1
By

y

Treewidth – Dynamic Programming – p.16/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Introduce: 1 child y , Bx = By ∪ {v } for some vertex v
2
Case 3: v ∈ Bx . Similar to Case 2, but 2 vertices of By are adjacent with v .

0
Bx

1
Bx

2
Bx
v

0
By

x

1
By

y

Treewidth – Dynamic Programming – p.16/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Introduce: 1 child y , Bx = By ∪ {v } for some vertex v
2
Case 3: v ∈ Bx . Similar to Case 2, but 2 vertices of By are adjacent with v .

0
Bx

1
Bx

2
Bx
v

0
By

x

⇐

1
By

y

Treewidth – Dynamic Programming – p.16/24
Hamiltonian cycle and
nice tree decompositions

0
1
2
Solving subproblem (Bx , Bx , Bx , M) of node x .

Join: 2 children y1 , y2 with Bx = By1 = By2
A solution H is the union of a subgraph H1 ⊆ G [Vy1 ] and a subgraph H2 ⊆ G [Vy2 ].
0
1
2
If H1 is a solution for (By1 , By1 , By1 , M1 ) of node y1 and H2 is a solution for
0
1
2
(By2 , By2 , By2 , M2 ) of node y2 , then we can check if H1 ∪ H2 is a solution for
0
1
2
(Bx , Bx , Bx , M) of node x .

For any two subproblems of y1 and y2 , we check if they have solutions and if their union
0
1
2
is a solution for (Bx , Bx , Bx , M) of node x .

Treewidth – Dynamic Programming – p.17/24
Monadic Second Order Logic

Extended Monadic Second Order Logic (EMSO)
A logical language on graphs consisting of the following:
Logical connectives ∧, ∨, →, ¬, =, =
quantifiers ∀, ∃ over vertex/edge variables
predicate adj(u, v ): vertices u and v are adjacent
predicate inc(e, v ): edge e is incident to vertex v
quantifiers ∀, ∃ over vertex/edge set variables

∈, ⊆ for vertex/edge sets
Example: The formula ∃C ⊆ V ∀v ∈ C ∃u1 , u2 ∈ C (u1 = u2 ∧ adj(u1 , v ) ∧ adj(u2 , v ))
is true ...

Treewidth – Dynamic Programming – p.18/24
Monadic Second Order Logic

Extended Monadic Second Order Logic (EMSO)
A logical language on graphs consisting of the following:
Logical connectives ∧, ∨, →, ¬, =, =
quantifiers ∀, ∃ over vertex/edge variables
predicate adj(u, v ): vertices u and v are adjacent
predicate inc(e, v ): edge e is incident to vertex v
quantifiers ∀, ∃ over vertex/edge set variables

∈, ⊆ for vertex/edge sets
Example: The formula ∃C ⊆ V ∀v ∈ C ∃u1 , u2 ∈ C (u1 = u2 ∧ adj(u1 , v ) ∧ adj(u2 , v ))
is true if graph G (V , E ) has a cycle.

Treewidth – Dynamic Programming – p.18/24
Courcelle’s Theorem
Courcelle’s Theorem: If a graph property can be expressed in EMSO, then for every
fixed w ≥ 1, there is a linear-time algorithm for testing this property on graphs having
treewidth at most w .

Note: The constant depending on w can be very large (double, triple exponential etc.),
therefore a direct dynamic programming algorithm can be more efficient.

Treewidth – Dynamic Programming – p.19/24
Courcelle’s Theorem
Courcelle’s Theorem: If a graph property can be expressed in EMSO, then for every
fixed w ≥ 1, there is a linear-time algorithm for testing this property on graphs having
treewidth at most w .

Note: The constant depending on w can be very large (double, triple exponential etc.),
therefore a direct dynamic programming algorithm can be more efficient.
If we can express a property in EMSO, then we immediately get that testing this
property is FPT parameterized by the treewidth w of the input graph.
Can we express 3-C OLORING and H AMILTONIAN C YCLE in EMSO?

Treewidth – Dynamic Programming – p.19/24
Using Courcelle’s Theorem

3-C OLORING

∃C1 , C2 , C3 ⊆ V ∀v ∈ V (v ∈ C1 ∨ v ∈ C2 ∨ v ∈ C3 ) ∧ ∀u, v ∈ V adj(u, v ) →
(¬(u ∈ C1 ∧ v ∈ C1 ) ∧ ¬(u ∈ C2 ∧ v ∈ C2 ) ∧ ¬(u ∈ C3 ∧ v ∈ C3 ))

Treewidth – Dynamic Programming – p.20/24
Using Courcelle’s Theorem

3-C OLORING

∃C1 , C2 , C3 ⊆ V ∀v ∈ V (v ∈ C1 ∨ v ∈ C2 ∨ v ∈ C3 ) ∧ ∀u, v ∈ V adj(u, v ) →
(¬(u ∈ C1 ∧ v ∈ C1 ) ∧ ¬(u ∈ C2 ∧ v ∈ C2 ) ∧ ¬(u ∈ C3 ∧ v ∈ C3 ))
H AMILTONIAN C YCLE

∃H ⊆ E spanning(H) ∧ (∀v ∈ V degree2(H, v ))
degree0(H, v ) := ¬∃e ∈ H inc(e, v )

degree1(H, v ) := ¬degree0(H, v ) ∧ ¬∃e1 , e2 ∈ H (e1 = e2 ∧ inc(e1 , v ) ∧ inc(e2 , v ))
degree2(H, v ) := ¬degree0(H, v ) ∧ ¬degree1(H, v ) ∧ ¬∃e1 , e2 , e3 ∈ H (e1 =

e2 ∧ e2 = e3 ∧ e1 = e3 ∧ inc(e1 , v ) ∧ inc(e2 , v ) ∧ inc(e3 , v )))

spanning(H) := ∀u, v ∈ V ∃P ⊆ H ∀x ∈ V ((x = u ∨x = v )∧ degree1(P, x))∨(x =

u ∧ x = v ∧ (degree0(P, x) ∨ degree2(P, x)))

Treewidth – Dynamic Programming – p.20/24
Using Courcelle’s Theorem

Two ways of using Courcelle’s Theorem:
1. The problem can be described by a single formula (e.g, 3-C OLORING, H AMILTONIAN
C YCLE ).

⇒ Problem can be solved in time f (w ) · n for graphs of treewidth at most w .
⇒ Problem is FPT parameterized by the treewidth w of the input graph.

Treewidth – Dynamic Programming – p.21/24
Using Courcelle’s Theorem

Two ways of using Courcelle’s Theorem:
1. The problem can be described by a single formula (e.g, 3-C OLORING, H AMILTONIAN
C YCLE ).

⇒ Problem can be solved in time f (w ) · n for graphs of treewidth at most w .
⇒ Problem is FPT parameterized by the treewidth w of the input graph.
2. The problem can be described by a formula for each value of the parameter k .
Example: For each k , having a cycle of length exactly k can be expressed as

∃v1 , ... , vk ∈ V (adj(v1 , v2 ) ∧ adj(v2 , v3 ) ∧ · · · ∧ adj(vk−1 , vk ) ∧ adj(vk , v1 )).
⇒ Problem can be solved in time f (k, w ) · n for graphs of treewidth w .
⇒ Problem is FPT parameterized with combined parameter k and treewidth w .
Treewidth – Dynamic Programming – p.21/24
S UBGRAPH I SOMORPHISM
S UBGRAPH I SOMORPHISM: given graphs H and G , find a copy of H in G as subgraph.
Parameter k := |V (H)| (size of the small graph).
For each H , we can construct a formula φH that expresses “G has a subgraph
isomorphic to H ” (similarly to the k -cycle on the previous slide).

Treewidth – Dynamic Programming – p.22/24
S UBGRAPH I SOMORPHISM
S UBGRAPH I SOMORPHISM: given graphs H and G , find a copy of H in G as subgraph.
Parameter k := |V (H)| (size of the small graph).
For each H , we can construct a formula φH that expresses “G has a subgraph
isomorphic to H ” (similarly to the k -cycle on the previous slide).

⇒ By Courcelle’s Theorem, S UBGRAPH I SOMORPHISM can be solved in time
f (H, w ) · n if G has treewidth at most w .

Treewidth – Dynamic Programming – p.22/24
S UBGRAPH I SOMORPHISM
S UBGRAPH I SOMORPHISM: given graphs H and G , find a copy of H in G as subgraph.
Parameter k := |V (H)| (size of the small graph).
For each H , we can construct a formula φH that expresses “G has a subgraph
isomorphic to H ” (similarly to the k -cycle on the previous slide).

⇒ By Courcelle’s Theorem, S UBGRAPH I SOMORPHISM can be solved in time
f (H, w ) · n if G has treewidth at most w .
⇒ Since there is only a finite number of simple graphs on k vertices, S UBGRAPH
I SOMORPHISM can be solved in time f (k, w ) · n if H has k vertices and G has
treewidth at most w .
⇒ S UBGRAPH I SOMORPHISM is FPT parameterized by combined parameter
k := |V (H)| and the treewidth w of G .

Treewidth – Dynamic Programming – p.22/24
The Robber and Cops game

Game: k cops try to capture a robber in the graph.
In each step, the cops can move from vertex to vertex arbitrarily with helicopters.
The robber moves infinitely fast on the edges, and sees where the cops will land.
Fact:

k + 1 cops can win the game ⇐⇒ the treewidth of the graph is at most k .

Treewidth – Dynamic Programming – p.23/24
The Robber and Cops game

Game: k cops try to capture a robber in the graph.
In each step, the cops can move from vertex to vertex arbitrarily with helicopters.
The robber moves infinitely fast on the edges, and sees where the cops will land.
Fact:

k + 1 cops can win the game ⇐⇒ the treewidth of the graph is at most k .
The winner of the game can be determined in time nO(k) using standard techniques
(there are at most nk positions for the cops)

⇓

For every fixed k , it can be checked in polynomial-time if treewidth is at most k .

Treewidth – Dynamic Programming – p.23/24
The Robber and Cops game

Game: k cops try to capture a robber in the graph.
In each step, the cops can move from vertex to vertex arbitrarily with helicopters.
The robber moves infinitely fast on the edges, and sees where the cops will land.
Fact:

k + 1 cops can win the game ⇐⇒ the treewidth of the graph is at most k .
The winner of the game can be determined in time nO(k) using standard techniques
(there are at most nk positions for the cops)

⇓

For every fixed k , it can be checked in polynomial-time if treewidth is at most k .
Exercise 1: Show that the treewidth of the k × k grid is at least k − 1.
Exercise 2: Show that the treewidth of the k × k grid is at least k .

Treewidth – Dynamic Programming – p.23/24
The Robber and Cops game (cont.)

Example: 2 cops have a winning strategy in a tree.

Treewidth – Dynamic Programming – p.24/24
The Robber and Cops game (cont.)

Example: 2 cops have a winning strategy in a tree.

Treewidth – Dynamic Programming – p.24/24
The Robber and Cops game (cont.)

Example: 2 cops have a winning strategy in a tree.

Treewidth – Dynamic Programming – p.24/24
The Robber and Cops game (cont.)

Example: 2 cops have a winning strategy in a tree.

Treewidth – Dynamic Programming – p.24/24
The Robber and Cops game (cont.)

Example: 2 cops have a winning strategy in a tree.

Treewidth – Dynamic Programming – p.24/24
The Robber and Cops game (cont.)

Example: 2 cops have a winning strategy in a tree.

Treewidth – Dynamic Programming – p.24/24
The Robber and Cops game (cont.)

Example: 2 cops have a winning strategy in a tree.

Treewidth – Dynamic Programming – p.24/24
The Robber and Cops game (cont.)

Example: 2 cops have a winning strategy in a tree.

Treewidth – Dynamic Programming – p.24/24
The Robber and Cops game (cont.)

Example: 2 cops have a winning strategy in a tree.

Treewidth – Dynamic Programming – p.24/24

More Related Content

What's hot

Group homomorphism
Group homomorphismGroup homomorphism
Group homomorphism
NaliniSPatil
 
Antiderivatives and indefinite integration2009
Antiderivatives and indefinite integration2009Antiderivatives and indefinite integration2009
Antiderivatives and indefinite integration2009Ron Eick
 
Matroid Basics
Matroid BasicsMatroid Basics
Matroid BasicsASPAK2014
 
The Fundamental theorem of calculus
The Fundamental theorem of calculus The Fundamental theorem of calculus
The Fundamental theorem of calculus
AhsanIrshad8
 
Aljabar Fuzzy
Aljabar FuzzyAljabar Fuzzy
Aljabar Fuzzy
Firman_anag_ti
 
Topology for Computing: Homology
Topology for Computing: HomologyTopology for Computing: Homology
Topology for Computing: Homology
Sangwoo Mo
 
A course on integral calculus
A course on integral calculusA course on integral calculus
A course on integral calculus
GAURAV SAHA
 
Unit 1 introduction to proofs
Unit 1  introduction to proofsUnit 1  introduction to proofs
Unit 1 introduction to proofs
raksharao
 
Fuzzy graph
Fuzzy graphFuzzy graph
Fuzzy graph
MSheelaSheela
 
minimum spanning trees Algorithm
minimum spanning trees Algorithm minimum spanning trees Algorithm
minimum spanning trees Algorithm
sachin varun
 
Fundamental Theorem of Calculus
Fundamental Theorem of CalculusFundamental Theorem of Calculus
Fundamental Theorem of Calculus
gizemk
 
Lecture01a correctness
Lecture01a correctnessLecture01a correctness
Lecture01a correctness
Sonia Djebali
 
5.2 the substitution methods
5.2 the substitution methods5.2 the substitution methods
5.2 the substitution methodsmath265
 
Differential Calculus
Differential CalculusDifferential Calculus
Differential Calculus
RufatMammadov12
 
Ppt of graph theory
Ppt of graph theoryPpt of graph theory
Ppt of graph theory
ArvindBorge
 
Fuzzy Group Ideals and Rings
Fuzzy Group Ideals and RingsFuzzy Group Ideals and Rings
Fuzzy Group Ideals and Rings
IJERA Editor
 
Minimum spanning tree (mst)
Minimum spanning tree (mst)Minimum spanning tree (mst)
Minimum spanning tree (mst)
Pradeep Behera
 
Lecture 6 disjoint set
Lecture 6 disjoint setLecture 6 disjoint set
Lecture 6 disjoint set
Abirami A
 
Magic graphs
Magic graphsMagic graphs
Magic graphsSpringer
 
Vertex cover Problem
Vertex cover ProblemVertex cover Problem
Vertex cover Problem
Gajanand Sharma
 

What's hot (20)

Group homomorphism
Group homomorphismGroup homomorphism
Group homomorphism
 
Antiderivatives and indefinite integration2009
Antiderivatives and indefinite integration2009Antiderivatives and indefinite integration2009
Antiderivatives and indefinite integration2009
 
Matroid Basics
Matroid BasicsMatroid Basics
Matroid Basics
 
The Fundamental theorem of calculus
The Fundamental theorem of calculus The Fundamental theorem of calculus
The Fundamental theorem of calculus
 
Aljabar Fuzzy
Aljabar FuzzyAljabar Fuzzy
Aljabar Fuzzy
 
Topology for Computing: Homology
Topology for Computing: HomologyTopology for Computing: Homology
Topology for Computing: Homology
 
A course on integral calculus
A course on integral calculusA course on integral calculus
A course on integral calculus
 
Unit 1 introduction to proofs
Unit 1  introduction to proofsUnit 1  introduction to proofs
Unit 1 introduction to proofs
 
Fuzzy graph
Fuzzy graphFuzzy graph
Fuzzy graph
 
minimum spanning trees Algorithm
minimum spanning trees Algorithm minimum spanning trees Algorithm
minimum spanning trees Algorithm
 
Fundamental Theorem of Calculus
Fundamental Theorem of CalculusFundamental Theorem of Calculus
Fundamental Theorem of Calculus
 
Lecture01a correctness
Lecture01a correctnessLecture01a correctness
Lecture01a correctness
 
5.2 the substitution methods
5.2 the substitution methods5.2 the substitution methods
5.2 the substitution methods
 
Differential Calculus
Differential CalculusDifferential Calculus
Differential Calculus
 
Ppt of graph theory
Ppt of graph theoryPpt of graph theory
Ppt of graph theory
 
Fuzzy Group Ideals and Rings
Fuzzy Group Ideals and RingsFuzzy Group Ideals and Rings
Fuzzy Group Ideals and Rings
 
Minimum spanning tree (mst)
Minimum spanning tree (mst)Minimum spanning tree (mst)
Minimum spanning tree (mst)
 
Lecture 6 disjoint set
Lecture 6 disjoint setLecture 6 disjoint set
Lecture 6 disjoint set
 
Magic graphs
Magic graphsMagic graphs
Magic graphs
 
Vertex cover Problem
Vertex cover ProblemVertex cover Problem
Vertex cover Problem
 

Similar to Dynamic Programming Over Graphs of Bounded Treewidth

Paper introduction to Combinatorial Optimization on Graphs of Bounded Treewidth
Paper introduction to Combinatorial Optimization on Graphs of Bounded TreewidthPaper introduction to Combinatorial Optimization on Graphs of Bounded Treewidth
Paper introduction to Combinatorial Optimization on Graphs of Bounded Treewidth
Yu Liu
 
topological_sort_strongly Connected Components
topological_sort_strongly Connected Componentstopological_sort_strongly Connected Components
topological_sort_strongly Connected Components
JahidulIslam47153
 
Treewidth and Applications
Treewidth and ApplicationsTreewidth and Applications
Treewidth and ApplicationsASPAK2014
 
MTH 2001 Project 2Instructions• Each group must choos.docx
MTH 2001 Project 2Instructions• Each group must choos.docxMTH 2001 Project 2Instructions• Each group must choos.docx
MTH 2001 Project 2Instructions• Each group must choos.docx
gilpinleeanna
 
Applied Graph Theory Applications
Applied Graph Theory ApplicationsApplied Graph Theory Applications
Applied Graph Theory Applications
vipin3195
 
A Quest for Subexponential Time Parameterized Algorithms for Planar-k-Path: F...
A Quest for Subexponential Time Parameterized Algorithms for Planar-k-Path: F...A Quest for Subexponential Time Parameterized Algorithms for Planar-k-Path: F...
A Quest for Subexponential Time Parameterized Algorithms for Planar-k-Path: F...
cseiitgn
 
Chapter 24 aoa
Chapter 24 aoaChapter 24 aoa
Chapter 24 aoa
Hanif Durad
 
B.TECH Math project
B.TECH Math projectB.TECH Math project
B.TECH Math project
arunsarkar9
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
AhmedMalik74
 
The Kernel Trick
The Kernel TrickThe Kernel Trick
The Kernel Trick
Edgar Marca
 
Benginning Calculus Lecture notes 14 - areas & volumes
Benginning Calculus Lecture notes 14 - areas & volumesBenginning Calculus Lecture notes 14 - areas & volumes
Benginning Calculus Lecture notes 14 - areas & volumes
basyirstar
 
Decision Trees and Bayes Classifiers
Decision Trees and Bayes ClassifiersDecision Trees and Bayes Classifiers
Decision Trees and Bayes Classifiers
Alexander Jung
 
optimal graph realization
optimal graph realizationoptimal graph realization
optimal graph realizationIgor Mandric
 
Graph 01
Graph 01Graph 01
Graph 01
Ajharul Abedeen
 
SVM (2).ppt
SVM (2).pptSVM (2).ppt
SVM (2).ppt
NoorUlHaq47
 
[ML]-SVM2.ppt.pdf
[ML]-SVM2.ppt.pdf[ML]-SVM2.ppt.pdf
[ML]-SVM2.ppt.pdf
4NM20IS025BHUSHANNAY
 
Graph algorithms
Graph algorithmsGraph algorithms
Graph algorithms
University of Haripur
 
Introduction to Generative Adversarial Networks
Introduction to Generative Adversarial NetworksIntroduction to Generative Adversarial Networks
Introduction to Generative Adversarial Networks
BennoG1
 
Physics Assignment Help
Physics Assignment Help Physics Assignment Help
Physics Assignment Help
Edu Assignment Help
 

Similar to Dynamic Programming Over Graphs of Bounded Treewidth (20)

Paper introduction to Combinatorial Optimization on Graphs of Bounded Treewidth
Paper introduction to Combinatorial Optimization on Graphs of Bounded TreewidthPaper introduction to Combinatorial Optimization on Graphs of Bounded Treewidth
Paper introduction to Combinatorial Optimization on Graphs of Bounded Treewidth
 
topological_sort_strongly Connected Components
topological_sort_strongly Connected Componentstopological_sort_strongly Connected Components
topological_sort_strongly Connected Components
 
Treewidth and Applications
Treewidth and ApplicationsTreewidth and Applications
Treewidth and Applications
 
MTH 2001 Project 2Instructions• Each group must choos.docx
MTH 2001 Project 2Instructions• Each group must choos.docxMTH 2001 Project 2Instructions• Each group must choos.docx
MTH 2001 Project 2Instructions• Each group must choos.docx
 
Applied Graph Theory Applications
Applied Graph Theory ApplicationsApplied Graph Theory Applications
Applied Graph Theory Applications
 
A Quest for Subexponential Time Parameterized Algorithms for Planar-k-Path: F...
A Quest for Subexponential Time Parameterized Algorithms for Planar-k-Path: F...A Quest for Subexponential Time Parameterized Algorithms for Planar-k-Path: F...
A Quest for Subexponential Time Parameterized Algorithms for Planar-k-Path: F...
 
Chapter 24 aoa
Chapter 24 aoaChapter 24 aoa
Chapter 24 aoa
 
B.TECH Math project
B.TECH Math projectB.TECH Math project
B.TECH Math project
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
The Kernel Trick
The Kernel TrickThe Kernel Trick
The Kernel Trick
 
Benginning Calculus Lecture notes 14 - areas & volumes
Benginning Calculus Lecture notes 14 - areas & volumesBenginning Calculus Lecture notes 14 - areas & volumes
Benginning Calculus Lecture notes 14 - areas & volumes
 
Decision Trees and Bayes Classifiers
Decision Trees and Bayes ClassifiersDecision Trees and Bayes Classifiers
Decision Trees and Bayes Classifiers
 
optimal graph realization
optimal graph realizationoptimal graph realization
optimal graph realization
 
Graph 01
Graph 01Graph 01
Graph 01
 
SVM (2).ppt
SVM (2).pptSVM (2).ppt
SVM (2).ppt
 
[ML]-SVM2.ppt.pdf
[ML]-SVM2.ppt.pdf[ML]-SVM2.ppt.pdf
[ML]-SVM2.ppt.pdf
 
Graph algorithms
Graph algorithmsGraph algorithms
Graph algorithms
 
SVM.ppt
SVM.pptSVM.ppt
SVM.ppt
 
Introduction to Generative Adversarial Networks
Introduction to Generative Adversarial NetworksIntroduction to Generative Adversarial Networks
Introduction to Generative Adversarial Networks
 
Physics Assignment Help
Physics Assignment Help Physics Assignment Help
Physics Assignment Help
 

More from ASPAK2014

Kernel Lower Bounds
Kernel Lower BoundsKernel Lower Bounds
Kernel Lower BoundsASPAK2014
 
Color Coding
Color CodingColor Coding
Color CodingASPAK2014
 
Steiner Tree Parameterized by Treewidth
Steiner Tree Parameterized by TreewidthSteiner Tree Parameterized by Treewidth
Steiner Tree Parameterized by TreewidthASPAK2014
 
The Exponential Time Hypothesis
The Exponential Time HypothesisThe Exponential Time Hypothesis
The Exponential Time HypothesisASPAK2014
 
Cut and Count
Cut and CountCut and Count
Cut and CountASPAK2014
 
Important Cuts and (p,q)-clustering
Important Cuts and (p,q)-clusteringImportant Cuts and (p,q)-clustering
Important Cuts and (p,q)-clusteringASPAK2014
 
Representative Sets
Representative SetsRepresentative Sets
Representative SetsASPAK2014
 
Bidimensionality
BidimensionalityBidimensionality
BidimensionalityASPAK2014
 
The W Hierarchy
The W HierarchyThe W Hierarchy
The W HierarchyASPAK2014
 
Paths and Polynomials
Paths and PolynomialsPaths and Polynomials
Paths and PolynomialsASPAK2014
 
Kernelization Basics
Kernelization BasicsKernelization Basics
Kernelization BasicsASPAK2014
 
Iterative Compression
Iterative CompressionIterative Compression
Iterative CompressionASPAK2014
 
Important Cuts
Important CutsImportant Cuts
Important CutsASPAK2014
 
Fixed-Parameter Intractability
Fixed-Parameter IntractabilityFixed-Parameter Intractability
Fixed-Parameter IntractabilityASPAK2014
 

More from ASPAK2014 (14)

Kernel Lower Bounds
Kernel Lower BoundsKernel Lower Bounds
Kernel Lower Bounds
 
Color Coding
Color CodingColor Coding
Color Coding
 
Steiner Tree Parameterized by Treewidth
Steiner Tree Parameterized by TreewidthSteiner Tree Parameterized by Treewidth
Steiner Tree Parameterized by Treewidth
 
The Exponential Time Hypothesis
The Exponential Time HypothesisThe Exponential Time Hypothesis
The Exponential Time Hypothesis
 
Cut and Count
Cut and CountCut and Count
Cut and Count
 
Important Cuts and (p,q)-clustering
Important Cuts and (p,q)-clusteringImportant Cuts and (p,q)-clustering
Important Cuts and (p,q)-clustering
 
Representative Sets
Representative SetsRepresentative Sets
Representative Sets
 
Bidimensionality
BidimensionalityBidimensionality
Bidimensionality
 
The W Hierarchy
The W HierarchyThe W Hierarchy
The W Hierarchy
 
Paths and Polynomials
Paths and PolynomialsPaths and Polynomials
Paths and Polynomials
 
Kernelization Basics
Kernelization BasicsKernelization Basics
Kernelization Basics
 
Iterative Compression
Iterative CompressionIterative Compression
Iterative Compression
 
Important Cuts
Important CutsImportant Cuts
Important Cuts
 
Fixed-Parameter Intractability
Fixed-Parameter IntractabilityFixed-Parameter Intractability
Fixed-Parameter Intractability
 

Recently uploaded

The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 

Recently uploaded (20)

The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 

Dynamic Programming Over Graphs of Bounded Treewidth

  • 1. Treewidth – Dynamic Programming Saket Saurabh Institute of Mathematical Sciences, India ´ (Based on the slides of Daniel Marx) ASPAK 2014: March 3-8 Treewidth – Dynamic Programming – p.1/24
  • 2. Treewidth Introduction and definition – DONE Part I: Algorithms for bounded treewidth graphs. Part II: Graph-theoretic properties of treewidth. Part III: Applications for general graphs. Treewidth – Dynamic Programming – p.2/24
  • 3. Treewidth Treewidth – Dynamic Programming – p.3/24
  • 4. Treewidth Treewidth: A measure of how “tree-like” the graph is. a (Introduced by Robertson and Seymour.) Tree decomposition: Vertices are arranged in a tree b c d e f g structure satisfying the following properties: 1. If u and v are neighbors, then there is a bag containing both of them. h 2. For every vertex v , the bags containing v form a connected subtree. c, d, f b, c, f a, b, c d, f , g b, e, f g, h Treewidth – Dynamic Programming – p.4/24
  • 5. Treewidth Treewidth: A measure of how “tree-like” the graph is. a (Introduced by Robertson and Seymour.) Tree decomposition: Vertices are arranged in a tree b c d e f g structure satisfying the following properties: 1. If u and v are neighbors, then there is a bag containing both of them. h 2. For every vertex v , the bags containing v form a connected subtree. c, d, f b, c, f a, b, c d, f , g b, e, f g, h Treewidth – Dynamic Programming – p.4/24
  • 6. Treewidth Treewidth: A measure of how “tree-like” the graph is. a (Introduced by Robertson and Seymour.) Tree decomposition: Vertices are arranged in a tree b c d e f g structure satisfying the following properties: 1. If u and v are neighbors, then there is a bag containing both of them. h 2. For every vertex v , the bags containing v form a connected subtree. c, d, f b, c, f a, b, c d, f , g b, e, f g, h Treewidth – Dynamic Programming – p.4/24
  • 7. Treewidth Treewidth: A measure of how “tree-like” the graph is. a (Introduced by Robertson and Seymour.) Tree decomposition: Vertices are arranged in a tree b c d e f g structure satisfying the following properties: 1. If u and v are neighbors, then there is a bag containing both of them. h 2. For every vertex v , the bags containing v form a connected subtree. Width of the decomposition: largest bag size −1. treewidth: width of the best decomposition. Fact: treewidth = 1 ⇐⇒ graph is a forest c, d, f b, c, f a, b, c d, f , g b, e, f g, h Treewidth – Dynamic Programming – p.4/24
  • 8. Treewidth Treewidth: A measure of how “tree-like” the graph is. a (Introduced by Robertson and Seymour.) Tree decomposition: Vertices are arranged in a tree b c d e f g structure satisfying the following properties: 1. If u and v are neighbors, then there is a bag containing both of them. h 2. For every vertex v , the bags containing v form a connected subtree. Width of the decomposition: largest bag size −1. treewidth: width of the best decomposition. Fact: treewidth = 1 ⇐⇒ graph is a forest c, d, f b, c, f a, b, c d, f , g b, e, f g, h Treewidth – Dynamic Programming – p.4/24
  • 9. Treewidth Treewidth: A measure of how “tree-like” the graph is. a (Introduced by Robertson and Seymour.) Tree decomposition: Vertices are arranged in a tree b c d e f g structure satisfying the following properties: 1. If u and v are neighbors, then there is a bag containing both of them. h 2. For every vertex v , the bags containing v form a connected subtree. Width of the decomposition: largest bag size −1. treewidth: width of the best decomposition. Fact: treewidth = 1 ⇐⇒ graph is a forest c, d, f b, c, f a, b, c d, f , g b, e, f g, h Treewidth – Dynamic Programming – p.4/24
  • 10. Finding tree decompositions Fact: It is NP-hard to determine the treewidth of a graph (given a graph G and an integer w , decide if the treewidth of G is at most w ), but there is a polynomial-time algorithm for every fixed w . Fact: [Bodlaender’s Theorem] For every fixed w , there is a linear-time algorithm that finds a tree decomposition of width w (if exists). ⇒ Deciding if treewidth is at most w is fixed-parameter tractable. ⇒ If we want an FPT algorithm parameterized by treewidth w of the input graph, then we can assume that a tree decomposition of width w is available. Treewidth – Dynamic Programming – p.5/24
  • 11. Finding tree decompositions Fact: It is NP-hard to determine the treewidth of a graph (given a graph G and an integer w , decide if the treewidth of G is at most w ), but there is a polynomial-time algorithm for every fixed w . Fact: [Bodlaender’s Theorem] For every fixed w , there is a linear-time algorithm that finds a tree decomposition of width w (if exists). ⇒ Deciding if treewidth is at most w is fixed-parameter tractable. ⇒ If we want an FPT algorithm parameterized by treewidth w of the input graph, then we can assume that a tree decomposition of width w is available. Running time is 2O(w 3) · n. Sometimes it is better to use the following results instead: Fact: There is a O(33w · w · n2 ) time algorithm that finds a tree decomposition of width 4w + 1, if the treewidth of the graph is at most w . Fact: There is a polynomial-time algorithm that finds a tree decomposition of width √ O(w log w ), if the treewidth of the graph is at most w . Treewidth – Dynamic Programming – p.5/24
  • 12. Part I: Algoritmhs for bounded-treewidth graphs Treewidth – Dynamic Programming – p.6/24
  • 13. W EIGHTED M AX I NDEPENDENT S ET and tree decompositions Fact: Given a tree decomposition of width w , W EIGHTED M AX I NDEPENDENT S ET can be solved in time O(2w · n). c, d, f Bx : vertices appearing in node x . Vx : vertices appearing in the subtree rooted at x . b, c, f Generalizing our solution for trees: d, f , g b, e, f a, b, c g, h Instead of computing 2 values A[v ], B[v ] for each vertex of the graph, we compute 2|Bx | ≤ 2w +1 values for each bag Bx . M[x, S]: the maximum weight of an independent set I ⊆ Vx with I ∩ Bx = S . ∅ =? b =? c =? f =? bc =? cf =? bf =? bcf =? How to determine M[x, S] if all the values are known for the children of x ? Treewidth – Dynamic Programming – p.7/24
  • 14. Nice tree decompositions Definition: A rooted tree decomposition is nice if every node x is one of the following 4 types: Leaf: no children, |Bx | = 1 Introduce: 1 child y , Bx = By ∪ {v } for some vertex v Forget: 1 child y , Bx = By {v } for some vertex v Join: 2 children y1 , y2 with Bx = By1 = By2 Leaf Introduce Forget Join v u, v , w u, w u, v , w u, w u, v , w u, v , w u, v , w Fact: A tree decomposition of width w and n nodes can be turned into a nice tree decomposition of width w and O(wn) nodes in time O(w 2 n). Treewidth – Dynamic Programming – p.8/24
  • 15. W EIGHTED M AX I NDEPENDENT S ET and nice tree decompositions Leaf: no children, |Bx | = 1 Trivial! Introduce: 1 child y , Bx = By ∪ {v } for some vertex v m[x, S] =  m[y , S]      if v ∈ S, m[y , S {v }] + w (v ) if v ∈ S but v has no neighbor in S , −∞ if S contains v and its neighbor. Leaf Introduce Forget Join v u, v , w u, w u, v , w u, w u, v , w u, v , w u, v , w Treewidth – Dynamic Programming – p.9/24
  • 16. W EIGHTED M AX I NDEPENDENT S ET and nice tree decompositions Forget: 1 child y , Bx = By {v } for some vertex v m[x, S] = max{m[y , S], m[y , S ∪ {v }]} Join: 2 children y1 , y2 with Bx = By1 = By2 m[x, S] = m[y1 , S] + m[y2 , S] − w (S) Leaf Introduce Forget Join v u, v , w u, w u, v , w u, w u, v , w u, v , w u, v , w Treewidth – Dynamic Programming – p.9/24
  • 17. W EIGHTED M AX I NDEPENDENT S ET and nice tree decompositions Forget: 1 child y , Bx = By {v } for some vertex v m[x, S] = max{m[y , S], m[y , S ∪ {v }]} Join: 2 children y1 , y2 with Bx = By1 = By2 m[x, S] = m[y1 , S] + m[y2 , S] − w (S) There are at most 2w +1 · n subproblems m[x, S] and each subproblem can be solved in constant time (assuming the children are already solved). ⇒ Running time is O(2w · n). ⇒ W EIGHTED M AX I NDEPENDENT S ET is FPT parameterized by treewidth. ⇒ W EIGHTED M IN V ERTEX C OVER is FPT parameterized by treewidth. Treewidth – Dynamic Programming – p.9/24
  • 18. 3-C OLORING and tree decompositions Fact: Given a tree decomposition of width w , 3-C OLORING can be solved in O(3w · n). Bx : vertices appearing in node x . Vx : vertices appearing in the subtree rooted at x . For every node x and coloring c : Bx → {1, 2, 3}, c, d, f b, c, f d, f , g we compute the Boolean value E [x, c], which is true if and only if c can be extended to a proper g, h b, e, f a, b, c 3-coloring of Vx . bcf=T bcf=T bcf=F bcf=F ... ... How to determine E [x, c] if all the values are known for the children of x ? Treewidth – Dynamic Programming – p.10/24
  • 19. 3-C OLORING and nice tree decompositions Leaf: no children, |Bx | = 1 Trivial! Introduce: 1 child y , Bx = By ∪ {v } for some vertex v If c(v ) = c(u) for every neighbor u of v , then E [x, c] = E [y , c ′ ], where c ′ is c restricted to By . Forget: 1 child y , Bx = By {v } for some vertex v E [x, c] is true if E [y , c ′ ] is true for one of the 3 extensions of c to By . Join: 2 children y1 , y2 with Bx = By1 = By2 E [x, c] = E [y1 , c] ∧ E [y2 , c] Leaf Introduce Forget Join v u, v , w u, w u, v , w u, w u, v , w u, v , w u, v , w Treewidth – Dynamic Programming – p.11/24
  • 20. 3-C OLORING and nice tree decompositions Leaf: no children, |Bx | = 1 Trivial! Introduce: 1 child y , Bx = By ∪ {v } for some vertex v If c(v ) = c(u) for every neighbor u of v , then E [x, c] = E [y , c ′ ], where c ′ is c restricted to By . Forget: 1 child y , Bx = By {v } for some vertex v E [x, c] is true if E [y , c ′ ] is true for one of the 3 extensions of c to By . Join: 2 children y1 , y2 with Bx = By1 = By2 E [x, c] = E [y1 , c] ∧ E [y2 , c] There are at most 3w +1 · n subproblems E [x, c] and each subproblem can be solved in constant time (assuming the children are already solved). ⇒ Running time is O(3w · n). ⇒ 3-C OLORING is FPT parameterized by treewidth. Treewidth – Dynamic Programming – p.11/24
  • 21. Vertex coloring More generally: Fact: Given a tree decomposition of width w , c -C OLORING can be solved in O ∗ (c w ). Exercise: Every graph of treewidth at most w can be colored with w + 1 colors. Fact: Given a tree decomposition of width w , V ERTEX C OLORING can be solved in time O ∗ (w w ). ⇒ V ERTEX C OLORING is FPT parameterized by treewidth. Treewidth – Dynamic Programming – p.12/24
  • 22. Hamiltonian cycle and tree decompositions Fact: Given a tree decomposition of width w , H AMILTONIAN CYCLE can be solved in time w O(w ) · n. Bx : vertices appearing in node x . Vx : vertices appearing in the subtree rooted at x . 0 Bx 1 Bx 2 Bx x If H is a Hamiltonian cycle, then the subgraph H[Vx ] is a set of paths with endpoints in Bx . What are the important properties of H[Vx ] “seen from the outside world”? 0 1 2 The subsets Bx , Bx , Bx of Bx having degree Vx 0, 1, and 2. 1 The matching M of Bx . 0 1 2 Number of subproblems (Bx , Bx , Bx , M) for each node x : at most 3w · w w . Treewidth – Dynamic Programming – p.13/24
  • 23. Hamiltonian cycle and nice tree decompositions 0 1 2 For each subproblem (Bx , Bx , Bx , M), we have to determine if there is a set of paths with this pattern. How to do this for the different types of nodes? (Assuming that all the subproblems are solved for the children.) Leaf: no children, |Bx | = 1 Trivial! Treewidth – Dynamic Programming – p.14/24
  • 24. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Forget: 1 child y , Bx = By {v } for some vertex v 0 1 2 In a solution H of (Bx , Bx , Bx , M), vertex v has degree 2. Thus subproblem 0 1 2 0 1 2 (Bx , Bx , Bx , M) of x is equivalent to subproblem (Bx , Bx , Bx ∪ {v }, M) of y . 0 Bx 1 Bx 2 Bx Treewidth – Dynamic Programming – p.15/24
  • 25. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Forget: 1 child y , Bx = By {v } for some vertex v 0 1 2 In a solution H of (Bx , Bx , Bx , M), vertex v has degree 2. Thus subproblem 0 1 2 0 1 2 (Bx , Bx , Bx , M) of x is equivalent to subproblem (Bx , Bx , Bx ∪ {v }, M) of y . 0 Bx 1 Bx 2 Bx v Treewidth – Dynamic Programming – p.15/24
  • 26. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Forget: 1 child y , Bx = By {v } for some vertex v 0 1 2 In a solution H of (Bx , Bx , Bx , M), vertex v has degree 2. Thus subproblem 0 1 2 0 1 2 (Bx , Bx , Bx , M) of x is equivalent to subproblem (Bx , Bx , Bx ∪ {v }, M) of y . 0 Bx 1 Bx 2 Bx v Treewidth – Dynamic Programming – p.15/24
  • 27. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Introduce: 1 child y , Bx = By ∪ {v } for some vertex v 0 0 1 2 Case 1: v ∈ Bx . Subproblem is equivalent with (Bx {v }, Bx , Bx , M) for node y . 0 Bx v 1 Bx 2 Bx x Treewidth – Dynamic Programming – p.16/24
  • 28. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Introduce: 1 child y , Bx = By ∪ {v } for some vertex v 0 0 1 2 Case 1: v ∈ Bx . Subproblem is equivalent with (Bx {v }, Bx , Bx , M) for node y . 0 Bx v 1 Bx 0 By 2 Bx x 1 By 2 By y Treewidth – Dynamic Programming – p.16/24
  • 29. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Introduce: 1 child y , Bx = By ∪ {v } for some vertex v 0 0 1 2 Case 1: v ∈ Bx . Subproblem is equivalent with (Bx {v }, Bx , Bx , M) for node y . 0 Bx v 1 Bx 0 By 2 Bx x 1 By 2 By y Treewidth – Dynamic Programming – p.16/24
  • 30. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Introduce: 1 child y , Bx = By ∪ {v } for some vertex v 0 0 1 2 Case 1: v ∈ Bx . Subproblem is equivalent with (Bx {v }, Bx , Bx , M) for node y . 0 Bx v 1 Bx 0 By 2 Bx x ⇐ 1 By 2 By y Treewidth – Dynamic Programming – p.16/24
  • 31. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Introduce: 1 child y , Bx = By ∪ {v } for some vertex v 1 Case 2: v ∈ Bx . Every neighbor of v in Vx is in Bx . Thus v has to be adjacent with one other vertex of Bx . 0 1 2 Is there a subproblem (By , By , By , M ′ ) of node y such that making a vertex of By 0 1 2 adjacent to v makes it a solution for subproblem (Bx , Bx , Bx , M) of node x ? 0 Bx 2 Bx 1 Bx v x Treewidth – Dynamic Programming – p.16/24
  • 32. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Introduce: 1 child y , Bx = By ∪ {v } for some vertex v 1 Case 2: v ∈ Bx . Every neighbor of v in Vx is in Bx . Thus v has to be adjacent with one other vertex of Bx . 0 1 2 Is there a subproblem (By , By , By , M ′ ) of node y such that making a vertex of By 0 1 2 adjacent to v makes it a solution for subproblem (Bx , Bx , Bx , M) of node x ? 0 Bx 2 Bx 1 Bx v x Treewidth – Dynamic Programming – p.16/24
  • 33. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Introduce: 1 child y , Bx = By ∪ {v } for some vertex v 1 Case 2: v ∈ Bx . Every neighbor of v in Vx is in Bx . Thus v has to be adjacent with one other vertex of Bx . 0 1 2 Is there a subproblem (By , By , By , M ′ ) of node y such that making a vertex of By 0 1 2 adjacent to v makes it a solution for subproblem (Bx , Bx , Bx , M) of node x ? 0 Bx 0 By 2 Bx 1 Bx v x 1 By 2 By y Treewidth – Dynamic Programming – p.16/24
  • 34. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Introduce: 1 child y , Bx = By ∪ {v } for some vertex v 1 Case 2: v ∈ Bx . Every neighbor of v in Vx is in Bx . Thus v has to be adjacent with one other vertex of Bx . 0 1 2 Is there a subproblem (By , By , By , M ′ ) of node y such that making a vertex of By 0 1 2 adjacent to v makes it a solution for subproblem (Bx , Bx , Bx , M) of node x ? 0 Bx 0 By 2 Bx 1 Bx v x 1 By 2 By y Treewidth – Dynamic Programming – p.16/24
  • 35. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Introduce: 1 child y , Bx = By ∪ {v } for some vertex v 1 Case 2: v ∈ Bx . Every neighbor of v in Vx is in Bx . Thus v has to be adjacent with one other vertex of Bx . 0 1 2 Is there a subproblem (By , By , By , M ′ ) of node y such that making a vertex of By 0 1 2 adjacent to v makes it a solution for subproblem (Bx , Bx , Bx , M) of node x ? 0 Bx 1 Bx 0 By 2 Bx v x ⇐ 1 By 2 By y Treewidth – Dynamic Programming – p.16/24
  • 36. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Introduce: 1 child y , Bx = By ∪ {v } for some vertex v 2 Case 3: v ∈ Bx . Similar to Case 2, but 2 vertices of By are adjacent with v . 0 Bx 1 Bx 2 Bx v x Treewidth – Dynamic Programming – p.16/24
  • 37. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Introduce: 1 child y , Bx = By ∪ {v } for some vertex v 2 Case 3: v ∈ Bx . Similar to Case 2, but 2 vertices of By are adjacent with v . 0 Bx 1 Bx 2 Bx v x Treewidth – Dynamic Programming – p.16/24
  • 38. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Introduce: 1 child y , Bx = By ∪ {v } for some vertex v 2 Case 3: v ∈ Bx . Similar to Case 2, but 2 vertices of By are adjacent with v . 0 Bx 1 Bx 2 Bx v 0 By x 1 By y Treewidth – Dynamic Programming – p.16/24
  • 39. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Introduce: 1 child y , Bx = By ∪ {v } for some vertex v 2 Case 3: v ∈ Bx . Similar to Case 2, but 2 vertices of By are adjacent with v . 0 Bx 1 Bx 2 Bx v 0 By x 1 By y Treewidth – Dynamic Programming – p.16/24
  • 40. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Introduce: 1 child y , Bx = By ∪ {v } for some vertex v 2 Case 3: v ∈ Bx . Similar to Case 2, but 2 vertices of By are adjacent with v . 0 Bx 1 Bx 2 Bx v 0 By x ⇐ 1 By y Treewidth – Dynamic Programming – p.16/24
  • 41. Hamiltonian cycle and nice tree decompositions 0 1 2 Solving subproblem (Bx , Bx , Bx , M) of node x . Join: 2 children y1 , y2 with Bx = By1 = By2 A solution H is the union of a subgraph H1 ⊆ G [Vy1 ] and a subgraph H2 ⊆ G [Vy2 ]. 0 1 2 If H1 is a solution for (By1 , By1 , By1 , M1 ) of node y1 and H2 is a solution for 0 1 2 (By2 , By2 , By2 , M2 ) of node y2 , then we can check if H1 ∪ H2 is a solution for 0 1 2 (Bx , Bx , Bx , M) of node x . For any two subproblems of y1 and y2 , we check if they have solutions and if their union 0 1 2 is a solution for (Bx , Bx , Bx , M) of node x . Treewidth – Dynamic Programming – p.17/24
  • 42. Monadic Second Order Logic Extended Monadic Second Order Logic (EMSO) A logical language on graphs consisting of the following: Logical connectives ∧, ∨, →, ¬, =, = quantifiers ∀, ∃ over vertex/edge variables predicate adj(u, v ): vertices u and v are adjacent predicate inc(e, v ): edge e is incident to vertex v quantifiers ∀, ∃ over vertex/edge set variables ∈, ⊆ for vertex/edge sets Example: The formula ∃C ⊆ V ∀v ∈ C ∃u1 , u2 ∈ C (u1 = u2 ∧ adj(u1 , v ) ∧ adj(u2 , v )) is true ... Treewidth – Dynamic Programming – p.18/24
  • 43. Monadic Second Order Logic Extended Monadic Second Order Logic (EMSO) A logical language on graphs consisting of the following: Logical connectives ∧, ∨, →, ¬, =, = quantifiers ∀, ∃ over vertex/edge variables predicate adj(u, v ): vertices u and v are adjacent predicate inc(e, v ): edge e is incident to vertex v quantifiers ∀, ∃ over vertex/edge set variables ∈, ⊆ for vertex/edge sets Example: The formula ∃C ⊆ V ∀v ∈ C ∃u1 , u2 ∈ C (u1 = u2 ∧ adj(u1 , v ) ∧ adj(u2 , v )) is true if graph G (V , E ) has a cycle. Treewidth – Dynamic Programming – p.18/24
  • 44. Courcelle’s Theorem Courcelle’s Theorem: If a graph property can be expressed in EMSO, then for every fixed w ≥ 1, there is a linear-time algorithm for testing this property on graphs having treewidth at most w . Note: The constant depending on w can be very large (double, triple exponential etc.), therefore a direct dynamic programming algorithm can be more efficient. Treewidth – Dynamic Programming – p.19/24
  • 45. Courcelle’s Theorem Courcelle’s Theorem: If a graph property can be expressed in EMSO, then for every fixed w ≥ 1, there is a linear-time algorithm for testing this property on graphs having treewidth at most w . Note: The constant depending on w can be very large (double, triple exponential etc.), therefore a direct dynamic programming algorithm can be more efficient. If we can express a property in EMSO, then we immediately get that testing this property is FPT parameterized by the treewidth w of the input graph. Can we express 3-C OLORING and H AMILTONIAN C YCLE in EMSO? Treewidth – Dynamic Programming – p.19/24
  • 46. Using Courcelle’s Theorem 3-C OLORING ∃C1 , C2 , C3 ⊆ V ∀v ∈ V (v ∈ C1 ∨ v ∈ C2 ∨ v ∈ C3 ) ∧ ∀u, v ∈ V adj(u, v ) → (¬(u ∈ C1 ∧ v ∈ C1 ) ∧ ¬(u ∈ C2 ∧ v ∈ C2 ) ∧ ¬(u ∈ C3 ∧ v ∈ C3 )) Treewidth – Dynamic Programming – p.20/24
  • 47. Using Courcelle’s Theorem 3-C OLORING ∃C1 , C2 , C3 ⊆ V ∀v ∈ V (v ∈ C1 ∨ v ∈ C2 ∨ v ∈ C3 ) ∧ ∀u, v ∈ V adj(u, v ) → (¬(u ∈ C1 ∧ v ∈ C1 ) ∧ ¬(u ∈ C2 ∧ v ∈ C2 ) ∧ ¬(u ∈ C3 ∧ v ∈ C3 )) H AMILTONIAN C YCLE ∃H ⊆ E spanning(H) ∧ (∀v ∈ V degree2(H, v )) degree0(H, v ) := ¬∃e ∈ H inc(e, v ) degree1(H, v ) := ¬degree0(H, v ) ∧ ¬∃e1 , e2 ∈ H (e1 = e2 ∧ inc(e1 , v ) ∧ inc(e2 , v )) degree2(H, v ) := ¬degree0(H, v ) ∧ ¬degree1(H, v ) ∧ ¬∃e1 , e2 , e3 ∈ H (e1 = e2 ∧ e2 = e3 ∧ e1 = e3 ∧ inc(e1 , v ) ∧ inc(e2 , v ) ∧ inc(e3 , v ))) spanning(H) := ∀u, v ∈ V ∃P ⊆ H ∀x ∈ V ((x = u ∨x = v )∧ degree1(P, x))∨(x = u ∧ x = v ∧ (degree0(P, x) ∨ degree2(P, x))) Treewidth – Dynamic Programming – p.20/24
  • 48. Using Courcelle’s Theorem Two ways of using Courcelle’s Theorem: 1. The problem can be described by a single formula (e.g, 3-C OLORING, H AMILTONIAN C YCLE ). ⇒ Problem can be solved in time f (w ) · n for graphs of treewidth at most w . ⇒ Problem is FPT parameterized by the treewidth w of the input graph. Treewidth – Dynamic Programming – p.21/24
  • 49. Using Courcelle’s Theorem Two ways of using Courcelle’s Theorem: 1. The problem can be described by a single formula (e.g, 3-C OLORING, H AMILTONIAN C YCLE ). ⇒ Problem can be solved in time f (w ) · n for graphs of treewidth at most w . ⇒ Problem is FPT parameterized by the treewidth w of the input graph. 2. The problem can be described by a formula for each value of the parameter k . Example: For each k , having a cycle of length exactly k can be expressed as ∃v1 , ... , vk ∈ V (adj(v1 , v2 ) ∧ adj(v2 , v3 ) ∧ · · · ∧ adj(vk−1 , vk ) ∧ adj(vk , v1 )). ⇒ Problem can be solved in time f (k, w ) · n for graphs of treewidth w . ⇒ Problem is FPT parameterized with combined parameter k and treewidth w . Treewidth – Dynamic Programming – p.21/24
  • 50. S UBGRAPH I SOMORPHISM S UBGRAPH I SOMORPHISM: given graphs H and G , find a copy of H in G as subgraph. Parameter k := |V (H)| (size of the small graph). For each H , we can construct a formula φH that expresses “G has a subgraph isomorphic to H ” (similarly to the k -cycle on the previous slide). Treewidth – Dynamic Programming – p.22/24
  • 51. S UBGRAPH I SOMORPHISM S UBGRAPH I SOMORPHISM: given graphs H and G , find a copy of H in G as subgraph. Parameter k := |V (H)| (size of the small graph). For each H , we can construct a formula φH that expresses “G has a subgraph isomorphic to H ” (similarly to the k -cycle on the previous slide). ⇒ By Courcelle’s Theorem, S UBGRAPH I SOMORPHISM can be solved in time f (H, w ) · n if G has treewidth at most w . Treewidth – Dynamic Programming – p.22/24
  • 52. S UBGRAPH I SOMORPHISM S UBGRAPH I SOMORPHISM: given graphs H and G , find a copy of H in G as subgraph. Parameter k := |V (H)| (size of the small graph). For each H , we can construct a formula φH that expresses “G has a subgraph isomorphic to H ” (similarly to the k -cycle on the previous slide). ⇒ By Courcelle’s Theorem, S UBGRAPH I SOMORPHISM can be solved in time f (H, w ) · n if G has treewidth at most w . ⇒ Since there is only a finite number of simple graphs on k vertices, S UBGRAPH I SOMORPHISM can be solved in time f (k, w ) · n if H has k vertices and G has treewidth at most w . ⇒ S UBGRAPH I SOMORPHISM is FPT parameterized by combined parameter k := |V (H)| and the treewidth w of G . Treewidth – Dynamic Programming – p.22/24
  • 53. The Robber and Cops game Game: k cops try to capture a robber in the graph. In each step, the cops can move from vertex to vertex arbitrarily with helicopters. The robber moves infinitely fast on the edges, and sees where the cops will land. Fact: k + 1 cops can win the game ⇐⇒ the treewidth of the graph is at most k . Treewidth – Dynamic Programming – p.23/24
  • 54. The Robber and Cops game Game: k cops try to capture a robber in the graph. In each step, the cops can move from vertex to vertex arbitrarily with helicopters. The robber moves infinitely fast on the edges, and sees where the cops will land. Fact: k + 1 cops can win the game ⇐⇒ the treewidth of the graph is at most k . The winner of the game can be determined in time nO(k) using standard techniques (there are at most nk positions for the cops) ⇓ For every fixed k , it can be checked in polynomial-time if treewidth is at most k . Treewidth – Dynamic Programming – p.23/24
  • 55. The Robber and Cops game Game: k cops try to capture a robber in the graph. In each step, the cops can move from vertex to vertex arbitrarily with helicopters. The robber moves infinitely fast on the edges, and sees where the cops will land. Fact: k + 1 cops can win the game ⇐⇒ the treewidth of the graph is at most k . The winner of the game can be determined in time nO(k) using standard techniques (there are at most nk positions for the cops) ⇓ For every fixed k , it can be checked in polynomial-time if treewidth is at most k . Exercise 1: Show that the treewidth of the k × k grid is at least k − 1. Exercise 2: Show that the treewidth of the k × k grid is at least k . Treewidth – Dynamic Programming – p.23/24
  • 56. The Robber and Cops game (cont.) Example: 2 cops have a winning strategy in a tree. Treewidth – Dynamic Programming – p.24/24
  • 57. The Robber and Cops game (cont.) Example: 2 cops have a winning strategy in a tree. Treewidth – Dynamic Programming – p.24/24
  • 58. The Robber and Cops game (cont.) Example: 2 cops have a winning strategy in a tree. Treewidth – Dynamic Programming – p.24/24
  • 59. The Robber and Cops game (cont.) Example: 2 cops have a winning strategy in a tree. Treewidth – Dynamic Programming – p.24/24
  • 60. The Robber and Cops game (cont.) Example: 2 cops have a winning strategy in a tree. Treewidth – Dynamic Programming – p.24/24
  • 61. The Robber and Cops game (cont.) Example: 2 cops have a winning strategy in a tree. Treewidth – Dynamic Programming – p.24/24
  • 62. The Robber and Cops game (cont.) Example: 2 cops have a winning strategy in a tree. Treewidth – Dynamic Programming – p.24/24
  • 63. The Robber and Cops game (cont.) Example: 2 cops have a winning strategy in a tree. Treewidth – Dynamic Programming – p.24/24
  • 64. The Robber and Cops game (cont.) Example: 2 cops have a winning strategy in a tree. Treewidth – Dynamic Programming – p.24/24