Steiner tree

Steiner Tree
on graphs of small treewidth
Algorithms and Networks 2014/2015
Hans L. Bodlaender
Johan M. M. van Rooij
1
This lecture
 Steiner Tree
 Recap
 Steiner Tree on Graphs of Small Treewidth
 What do we store at tables
 Computing on Nice Tree Decompositions
 Improvement using Rank Based Approach
 Based on work by:
 B, Cygan, Kratsch, Nederlof (2013)
 Fafianie, B, Nederlof (2013)
2
The Steiner Tree Problem
 Let G = (V,E) be an undirected graph, and let N µ V be a
subset of the terminals.
 A Steiner tree is a tree T = (V’,E’) in G connecting all
terminals in N
 V’ µ V, E’ µ E, N µ V’
 We use k=|N|.
 Streiner tree problem:
 Given: an undirected graph G = (V,E), a terminal set N µ V,
and an integer t.
 Question: is there a Steiner tree consisting of at most t edges
in G.
3
Discussed results
 Steiner Tree is NP-complete
 Distance network
 Steiner Tree, parameterized by number of terminals is
FPT: with k terminals, can be solved in O(2k p(n)) time
 Today an algorithm using O(ck n) time for:
 Given: Connected graph G, set of terminals W, tree
decomposition of G of width at most k
 Question: What is the minimum number of edges of a tree
that connects all terminals?
 And the weighted variant:
 Given: Connected graph G, set of terminals W, tree
decomposition of G of width at most k, weight for each edge
 Question: What is the minimum total weight of a tree that
connects all terminals?
4
Nice tree decompositions of special type
 Five types of nodes:
 Leaf (as before)
 Join (as before)
 Forget (as before)
 Introduce vertex (add a vertex, but without edges)
 Introduce edge (add an edge between two terminals)
 We assume in addition:
 The root of the tree decomposition is a bag with one vertex: a
terminal
5
To each bag,
we associate a subgraph G(i)
 Bag i:
 All vertices in bags in subtree rooted by i
 All edges that are introduced in subtree rooted by i
6
Leaf
 G(i) is graph with one vertex and no edges:
v
7
Join nodes
 Identify the two subgraphs on the vertices in the bag
+
8
=
Forget nodes
 Same graph – one vertex is no longer ‘boundary’
v
9
v
Introduce vertex nodes
 In an introduce vertex node, a new vertex (say v) is added
to G(i): at this point, v has no incident edges (yet)
v
10
Degree
0 now
Introduce edge node
 Adds an edge between two terminals
v
11
v
Partial solutions (1)
 If we have a Steiner tree T in G, how does the part of T in
G(i) look like?
v w
a, b terminals
a
b
12
Partial solutions (2)
 If we have a Steiner tree T in G, how does the part of T in
G(i) look like?
 Maybe like this:
v w
a, b terminals
a
b
13
Partial solutions (3)
 If we have a Steiner tree T in G, how does the part of T in
G(i) look like?
 Or this:
v w
a, b terminals
a
b
14
Partial solutions (4)
 If we have a Steiner tree T in G, how does the part of T in
G(i) look like?
 But not this:
 We cannot connect a and b to other terminals outside G(i)
v w
a, b terminals
a
b
15
Partial solutions (5)
 A partial solution is a forest in G(i), such that
 Each tree contains a vertex in the bag/boundary X(i)
 Each terminal in G(i) belongs to a tree in the forest
 Or, differently said: each terminal is connected to the
boundary bag
 Next step: characterize such forests with finite information
16
Characteristic of partial solution
 A characteristic of a partial solution for G(i) is:
 A subset S of the vertices in X(i):
• the vertices in X(i) that belong to the forest
 A partition of S
• Two vertices belong to the same partition, if and only if they are
connected in the forest
17
Example characterics
(weighted example)
 {{a,b,c}}, 10
 {{a,b,c}}, 11
 {{a},{b,c}}, 3
 Table:
 {{a},{b},{c}}, 0
 {{a},{b,c}}, 3
 {{b},{a,c}}, 9
 {{c},{a,b}}, 7
 {{a,b,c}}, 10
18
a 8
b 3 c
1
6
1
2
4
a 8
b 3 c
1
6
1
2
3
8
1
6
1
2
DP
 For each bag, compute a table:
 For each possible characteristic, what is the minimum weight
of a partial solution (forest fulfilling criteria) with that
characteristic
 Compute these tables bottom up in the tree
 Root bag gives the answer
 Remember: the root bag had one vertex, a terminal
 Only one possible characteristic in table for the root
 Its value gives the answer
19
Computing tables
 Leaf: trivial
 Forget: discard characteristics with the forgotten vertex as
only element in a partition (becomes never connected)
 Join: try all combinations of characteristics and compute
resulting characteristics
 Introduce vertex:
 For each element of child bag table:
 Add characteristic with introduced vertex as single element in
partition
 Add characteristic with introduced vertex not in forest
 Introduce edge:
 For each element of child bag table:
 If both endpoints in forest: Add characteristic with introduced edge
in the forest: this increases width and joins two forests
 Add unchanged characteristic: edge not used in forest
20
Improvement: intuition
 It is sufficient to have something for all different futures
 … if you have a set of insurance policies, such that each
possible event in the future is covered by at least one of
these, you do not need an additional insurance policy
 The future is here: a forest in the “other part”
4
?
5
4
3
8
6
1
1
2
21
3
8
6
1
1
2
Connectivity matrix
 Rows and columns marked with partitions
 Entry is 1 if: row+ column partition connect all
22
a–b-c
ab - c
ac - b
bc - a
abc
a–b-c
0
0
0
0
1
ab - c
0
0
1
1
1
ac - b
0
1
0
1
1
bc - a
0
1
1
0
1
abc
1
1
1
1
1
The connectivity matrix
1 iff partitions joined connect all
a–b-c
ab - c
ac - b
bc - a
abc
a–b-c
0
0
0
0
1
ab - c
0
0
1
1
1
ac - b
0
1
0
1
1
bc - a
0
1
1
0
1
abc
1
1
1
1
1
Table:
a – b – c: 0
ab – c: 7
ac – b: 9
bc – a: 7
abc: 10
23
Not needed!!!
Linear combinations
 If row i is a linear combination (when computing mod 2) of
other rows, but is at least as expensive as these, then we
do not need the solution of row i.
 For any future that helps i, we have an entry that is as least
as good, and is also helped by this future…
24
a–b-c
ab - c
ac - b
bc - a
abc
a–b-c
0
0
0
0
1
ab - c
0
0
1
1
1
ac - b
0
1
0
1
1
bc - a
0
1
1
0
1
abc
1
1
1
1
1
0
7
9
7
10
Rank
Theorem (without proof):
 The connectivity matrix on r elements has rank 2r-1
 … and the partitions in at most 2 sets form a basis
 Each column with partition p can be written as sum of the
columns in 2 sets that it refines (except the trivial
partition)
25
The reduce step
 This enables a reduce step: if a table has more than 2|W|
elements with the same vertices W in the forest, then we
can delete some superfluous table entries:
 Let W be the vertices in X(i) in the forest.
 Build part of the connectivity matrix:
 Rows are the entries in the current table with W as forest
vertices
 Columns are partitions in at most two sets of W
 Perform Gaussian elimination:
 Find rows that are linear combination of less or equally
expensive rows, and delete the corresponding entries
26
Wrapping up
 Table size after reduction step is bounded by 3tw.
 Running time is dominated by Gaussian elimination step
and join nodes: O(ctwn)
 Implementation: works fast for real-life graphs
 Proper representation, choice of data structures helps a lot
27