SlideShare a Scribd company logo
1 of 64
Download to read offline
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 (20)

Boolean algebra and logic gates
Boolean algebra and logic gatesBoolean algebra and logic gates
Boolean algebra and logic gates
 
11 Unit1 Chapter 1 Getting Started With Python
11   Unit1 Chapter 1 Getting Started With Python11   Unit1 Chapter 1 Getting Started With Python
11 Unit1 Chapter 1 Getting Started With Python
 
Cadancesimulation
CadancesimulationCadancesimulation
Cadancesimulation
 
Graph theory
Graph theoryGraph theory
Graph theory
 
Day2 Verilog HDL Basic
Day2 Verilog HDL BasicDay2 Verilog HDL Basic
Day2 Verilog HDL Basic
 
1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx
1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx
1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx
 
non linear data structure -introduction of tree
non linear data structure -introduction of treenon linear data structure -introduction of tree
non linear data structure -introduction of tree
 
Graph Theory
Graph TheoryGraph Theory
Graph Theory
 
Radix-2 DIT FFT
Radix-2 DIT FFT Radix-2 DIT FFT
Radix-2 DIT FFT
 
Bellman Ford's Algorithm
Bellman Ford's AlgorithmBellman Ford's Algorithm
Bellman Ford's Algorithm
 
Python Workshop
Python WorkshopPython Workshop
Python Workshop
 
Quine Mc Cluskey Method
Quine Mc Cluskey MethodQuine Mc Cluskey Method
Quine Mc Cluskey Method
 
NumPy
NumPyNumPy
NumPy
 
NumPy.pptx
NumPy.pptxNumPy.pptx
NumPy.pptx
 
Lti system
Lti systemLti system
Lti system
 
Stack project
Stack projectStack project
Stack project
 
Generating function
Generating functionGenerating function
Generating function
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
quine mc cluskey method
 quine mc cluskey method quine mc cluskey method
quine mc cluskey method
 
Understanding feature-space
Understanding feature-spaceUnderstanding feature-space
Understanding feature-space
 

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 TreewidthYu Liu
 
Introduction to Treewidth
Introduction to TreewidthIntroduction to Treewidth
Introduction to TreewidthASPAK2014
 
topological_sort_strongly Connected Components
topological_sort_strongly Connected Componentstopological_sort_strongly Connected Components
topological_sort_strongly Connected ComponentsJahidulIslam47153
 
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.docxgilpinleeanna
 
Applied Graph Theory Applications
Applied Graph Theory ApplicationsApplied Graph Theory Applications
Applied Graph Theory Applicationsvipin3195
 
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
 
B.TECH Math project
B.TECH Math projectB.TECH Math project
B.TECH Math projectarunsarkar9
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning treeAhmedMalik74
 
The Kernel Trick
The Kernel TrickThe Kernel Trick
The Kernel TrickEdgar 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 & volumesbasyirstar
 
Decision Trees and Bayes Classifiers
Decision Trees and Bayes ClassifiersDecision Trees and Bayes Classifiers
Decision Trees and Bayes ClassifiersAlexander Jung
 
optimal graph realization
optimal graph realizationoptimal graph realization
optimal graph realizationIgor Mandric
 
Introduction to Generative Adversarial Networks
Introduction to Generative Adversarial NetworksIntroduction to Generative Adversarial Networks
Introduction to Generative Adversarial NetworksBennoG1
 

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
 
Introduction to Treewidth
Introduction to TreewidthIntroduction to Treewidth
Introduction to 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
 

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
 
Matroid Basics
Matroid BasicsMatroid Basics
Matroid BasicsASPAK2014
 
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 (15)

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
 
Matroid Basics
Matroid BasicsMatroid Basics
Matroid Basics
 
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

CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 

Recently uploaded (20)

CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 

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