Algorithms and Networks: Exponential time algorithms

Steiner Tree
Algorithms and Networks 2014/2015
Hans L. Bodlaender
Johan M. M. van Rooij
1
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.
2
My Last Lecture
 Steiner Tree.
 Interesting problem that we have not seen yet.
 Introduction
 Variants / applications
 NP-Completeness
 Polynomial time solvable special cases.
 Distance network.
 Solving Steiner tree with k-terminals in O*(2k)-time.
 Uses inclusion/exclusion.
 Algorithm invented by one of our former students.
3
Steiner Tree – Algorithms and Networks
INTRODUCTION
4
Variants and Applications
 Applications:
 Wire routing of VLSI.
 Customer’s bill for renting communication networks.
 Other network design and facility location problems.
 Some variants:
 Vertices are points in the plane.
 Vertex weights / edge weights vs unit weights.
 Different variants for directed graphs.
5
Steiner Tree is NP-Complete
 Steiner Tree is NP-Complete.
 Membership of NP: certificate is a subset
of the edges.
 NP-Hard: reduction from Vertex Cover.
 Take an instance of Vertex Cover,




G=(V,E), integer k.
Build G’=(V’,E’) by subdividing each edge.
Set N = set of newly introduced vertices.
All edges length 1.
Add one superterminal connected to all
vertices.
 G’ has Steiner Tree with |E|+k edges, if
and only if, G has vertex cover with k
vertices.
= terminal
6
Steiner Tree – Algorithms and Networks
POLYNOMIAL-TIME
SOLVABLE SPECIAL CASES
7
Special Cases of Steiner Tree
 k = 1: trivial.
 k = 2: shortest path.
 k = n: minimum spanning tree.
 k = c = O(1): constant number of terminals, polynomial-
time solvable (next slides).
8
Distance Networks
 Distance network D(X) of G=(V,E) (induced by the set X).
 Take complete graph with vertex set X.
 Cost of edge {v,w} in distance network is length shortest path
from v to w in G.
Observations:
 Let W be the set of vertices of degree larger than two for an
optimal Steiner tree T in G with terminal set N.
 The Steiner tree T consists of a series of shortest paths between
vertices in N [ W.
 The cost of T equals the cost of the minimum spanning tree in
D(N[W).
 The cost of the optimal Steiner tree in D(V) equals the cost of T.
9
Steiner Tree with O(1) Terminals
 Suppose |N|= k is constant c.
 Compute distance network D(V).
 There is a minimum cost Steiner tree in D(V) that contains
at most k – 2 non-terminals.
 Any Steiner tree that has one that is no longer without non-
terminal vertices of degree 1 and 2.
 A tree with r leaves and internal vertices of degree at least 3
has at most r – 2 internal vertices.
 Polynomial time algorithm for k = O(1) terminals:
 Enumerate all sets W of at most k – 2 non-terminals in G.
 For each W, find a minimum spanning tree in the distance
network D(NW).
 Take the best over all these solutions
 Takes polynomial time for fixed k = O(1).
10
Steiner Tree – Algorithms and Networks
O*(2K) ALGORITHM BY
INCLUSION/EXCLUSION
11
Some background on the algorithm
 Algorithm invented by Jesper Nederlof.
 Just after he finished his Master thesis supervised by Hans
(and a little bit by me).
 Master thesis on Inclusion/Exclusion algorithms.
12
A Recap: Inclusion/Exclusion Formula
 General form of the Inclusion/Exclusion formula:
 Let N be a collection of objects (anything).
 Let 1,2, ...,n be a series of requirements on objects.
 Finally, let for a subset W µ {1,2,...,n}, N(W) be the
number of objects in N that do not satisfy the
requirements in W.
 Then, the number of objects X that satisfy all requirements
is:
X
 (1)
W {1, 2 ,..., n}
13
|W |
N (W )
The Inclusion/Exclusion formula:
Alternative proofs
X
 (1)
|W |
N (W )
W {1, 2 ,..., n}
 Various ways to prove the formula.
1. See the formula as a branching algorithm branching on a
requirement:
required = optional – forbidden
2. If an object satisfies all requirements, it is counted in N().
If an object does not satisfy all requirements, say all but
those in a set W’, then it is counted in all W µ W’
 With a +1 if W is even, and a -1 if W is odd.
 W’ has equally many even as odd subsets: total contribution is 0.
14
Using the Inclusion/Exclusion Formula
for Steiner Tree (problematic version)
X
 One possible approach:
 Objects: trees in the graph G.
 Requirements: contain every terminal.
|W |
(

1
)
N (W )

W {1, 2 ,..., n}
 Then we need to compute 2k times the number of trees in
a subgraph of G.
 For each W µ N, compute trees in G[V\W].
 However, counting trees is difficult:
 Hard to keep track of which vertices are already in the tree.
 Compare to Hamiltonian Cycle:
 We want something that looks like a walk, so that we do not
need to remember where we have been.
15
Branching Walks
 Definition: Branching walk in G=(V,E) is a tuple (T,Á):
 Ordered tree T.
 Mapping Á from nodes of T to nodes of G, s.t. for any edge
{u,v} in the tree T we have that {Á(u),Á(v)} 2 E.
 The length of a branching walk is the number of edges in T.
 When r is the root of T, we say that the branching walk
starts in Á(r) 2 V.
 For any n 2 T, we say that the branching walk visits all
vertices Á(n) 2 V.
 Some examples on the blackboard...
16
Branching Walks and Steiner Tree
 Definition: Branching walk in G=(V,E) is a tuple (T,Á):
 Ordered tree T.
 Mapping Á from nodes of T to nodes of G, s.t. for any edge
{u,v} in the tree T we have that {Á(u),Á(v)} 2 E.
 Lemma: Let s 2 N a terminal. There exists a Steiner tree T
in G with at most c edges, if and only if, there exists a
branching walk of length at most c starting in s visiting all
terminals N.
17
Using the Inclusion/Exclusion Formula
for Steiner Tree
X
|W |
(

1
)
N (W )

 Approach:
W {1, 2 ,..., n}
 Objects: branching walks from
some s 2 N of length c in the graph G.
 Requirements: contain every terminal in N\{s}.
 We need to compute 2k-1 times the number of branching
walks of length c in a subgraph of G.
 For each W µ N\{s}, compute branching walks from s in
G[V\W].
 Next: how do we count branching walks?
 Dynamic programming (similar to ordinary walks).
18
Counting Branching Walks
 Let BW(v,j) be the number of branching walks of length j
starting in v in G[W].
 BW(v,0) = 1 for any vertex v.
 BW(v,j) = u2(N(v)ÅW) j
BW(u,j1) BW(v,j2)
1 + j2 = j-1
 j2 = 0 covers the case where we do not branch / split up and
walk to vertex u.
 Otherwise, a subtree of size j1 is created from neighbour u,
while a new tree of size j2 is added starting in v.
This splits off one branch, and can be repeated to split of more
branches.
 We can compute BW(v,j) for j = 0,1,2,....,t.
 All in polynomial time.
19
Putting It All Together
Algorithm:
 Choose any s 2 N.
X
|W |
(

1
)
N (W )

W {1, 2 ,..., n}
 For t = 1, 2, …
 Use the inclusion/exclusion formula to count the number of
branching walks from s of length t visiting all terminals N.
 This results in 2k-1 times counting branching walks from s of
length c in G[V\W].
 If this number is non-zero: stop the algorithm and output that
the smallest Steiner tree has size t.
20
Steiner Tree – Algorithms and Networks
THAT’S ALL FOLKS…
21