Treewidth Algorithms and Networks Overview Historic introduction Series



























































- Slides: 59
Treewidth Algorithms and Networks
Overview • Historic introduction: Series parallel graphs • Dynamic programming on trees • Dynamic programming on series parallel graphs • Treewidth • Dynamic programming on graphs of small treewidth • Finding tree decompositions 2 Treewidth
Computing the Resistance With the Laws of Ohm 1789 -1854 R 1 R 2 Two resistors in series R 1 R 2 Two resistors in parallel 3 Treewidth
Repeated use of the rules 6 6 2 2 1 5 7 Has resistance 4 1/6 + 1/2 = 1/(1. 5) 1. 5 + 5 = 8 1 + 7 = 8 1/8 + 1/8 = 1/4 4 Treewidth
5 A tree structure S 7 P 5 2 6 2 6 1 5 P S 1 2 6 7 P Treewidth
Carry on! 6 6 2 2 1 5 7 • Internal structure of graph can be forgotten once we know essential information about it! 4 ¼ + ¼ = ½ 6 Treewidth
Using tree structures for solving hard problems on graphs 1 • Network is ‘series parallel graph’ • 196*, 197*: many problems that are hard for general graphs are easy for – Trees – Series parallel graphs e. g. : NP-complete • Many well-known problems Linear / polynomial time computable 7 Treewidth
Weighted Independent Set • Independent set: set of vertices that are pair wise non-adjacent. • Weighted independent set – Given: Graph G=(V, E), weight w(v) for each vertex v. – Question: What is the maximum total weight of an independent set in G? • NP-complete 8 Treewidth
Weighted Independent Set on Trees • On trees, this problem can be solved in linear time with dynamic programming. • Choose root r. For each v, T(v) is subtree with v as root. • Write A(v) = maximum weight of independent set S in T(v) B(v) = maximum weight of independent set S in T(v), such that v Ï S. 9 Treewidth
Recursive formulations • If v is a leaf: – A(v) = w(v) – B(v) = 0 • If v has children x 1, … , xr: A(v) = max{ w(v) + B(x 1) + … + B(xr) , A(x 1) + … A(xr) } B(v) = A(x 1) + … A(xr) 10 Treewidth
Linear time algorithm • Compute A(v) and B(v) for each v, bottomup. – E. g. , in postorder • Constructing corresponding sets can also be done in linear time. 11 Treewidth
Second example: Weighted dominating set • A set of vertices S is dominating, if each vertex in G belongs to S or is adjacent to a vertex in S. • Problem: given a graph G with vertex weights, what is the minimum total weight of a dominating set in G? • Again, NP-complete, but linear time on trees. 12 Treewidth
Subproblems • C(v) = minimum weight of dominating set S of T(v) • D(v) = minimum weight of dominating set S of T(v) with v Î S. • E(v) = minimum weight of a set S of T(v) that dominates all vertices, except possibly v. 13 Treewidth
Recursive formulations • If v is a leaf, … • If v has children x 1, … , xr: – C(v) = the minimum of: • w(v) + E(x 1) + … + E(xr) • C(x 1) + … + C(xi-1) + D(xi) + C(xi+1) + … + C(xr), over all i, 1 £ i £ r. – D(v) = w(v) + E(x 1) + … + E(xr) – E(v) = min { w(v) + E(x 1) + … + E(xr), C(x 1) + … + C(xr) } 14 Treewidth
Gives again a linear time algorithm • Compute bottom up (e. g. , postorder), and use another type of dynamic programming for the values C(v). • Constructing sets can also be done in linear time 15 Treewidth
Generalizing to series parallel graphs • 16 Treewidth
Series composition s 1 s 2 s 1 t 2 s 2 s 2 =t 1 + t 1 t 2 17 Treewidth
Parallel composition s 1 s 2 s 1 s 1 =s 2 t 1 t 1 =t 2 + t 1 18 Treewidth
5 Series Parallel Graphs have an SP-tree S 7 P 19 2 6 2 6 1 5 P S 1 2 6 7 P Treewidth
5 2 6 • P 1 2 7 P 6 6 2 P 5 20 S 2 6 S Treewidth
Maximum weighted independent set for series parallel graphs • 21 Treewidth
Maximum weighted independent set of series parallel graphs 2 • 22 Treewidth
Many generalizations • 23 Treewidth
Idea of treewidth (intuition) • 24 Treewidth
Join (“gluing”) + 25 = Treewidth
Tree decomposition b d a g c f e ac b h af c a gf gh c de 26 Treewidth
Tree decomposition b d a g c f e ac b h af c a gf gh c de 27 Treewidth
Treewidth (definition) g a b c d e ac b h f af c c de 28 a gf gh a b c e f d g h Treewidth
Some graphs have small treewidth • Appearing in some applications (e. g. , probabilistic networks) • Trees have treewidth 1 • Series Parallel graphs have treewidth 2. • … 29 Treewidth
Trees have treewidth one • a b c e a d b a c b 30 e a d b Treewidth
Algorithms using tree decompositions • 31 Treewidth
Separator property w i v 33 If both v and w not in Xi, then v and w are not adjacent Treewidth
Nice tree decompositions • Rooted tree, and four types of nodes i: – Leaf: leaf of tree with |Xi| = 1. – Join: node with two children j, j’ with Xi = Xj’. – Introduce: node with one child j with Xi = Xj È {v} for some vertex v – Forget: node with one child j with Xi = Xj - {v} for some vertex v • There is always a nice tree decomposition with the same width. 34 Treewidth
Transformation to a nice tree decomposition • Step 1: Choose an arbitrary vertex as root • Step 2: Ensure that each node has at most 2 children: X i Xi Xi Xj(1) Xj(2) 35 … … Xi Xj(q) Xj(1) Xj(q) Xj(2) Treewidth
Transformation to a nice tree decomposition • Step 3: Turn binary nodes in join nodes Xi Xi Xj(1) 36 Xj(2) Xi Xi Xj(1) Xj(2) Treewidth
Transformation to a nice tree decomposition • Step 4: Nodes with one child get a series of introduce and forget nodes Xi Xi Above, introduce vertices in Xi that are not in Xj Xj Below, forget vertices in Xj that are not in Xi 37 Xj Treewidth
Transformation to a nice tree decomposition • Step 5: Ensure that leaf bags have size 1, by v adding introduce nodes: v 1 2 … vr v 1 v 2 … vr … v 1 v 2 38 v 1 Done! Treewidth
Define G(i) • Nice tree decomposition. • For each node i, G(i) subgraph of G, formed by all nodes in sets Xj, with j=i or j a descendant of i in tree. – Notate: G(i) = ( V(i), E(i) ). 39 Treewidth
Leaf nodes • Let i be a leaf node. Say Xi = {v}. v G(i) is a graph with one vertex 40 Treewidth
Join nodes • Let i be a join node with children j 1, j 1. • Example of how G(i) is build from G(j 1) and G(j 1): + 41 = Treewidth
Introduce nodes • Let i be a node with child j, with Xi = Xj È {v}. • One new `terminal’ vertex which can only be adjacent to other terminal vertices 42 v Treewidth
Forget nodes • Let i be a node with child j, with Xi = Xj - {v}. • Same graph; one terminal vertex now is a normal vertex 43 v v Treewidth
Maximum weighted independent set on graphs with treewidth k • For node i in tree decomposition, S Í Xi write – R(i, S) = maximum weight of independent set W of G(i) with W Ç Xi = S, • – ¥ if such W does not exist • We now see how to compute a table R(i, …) for all types of nodes 44 Treewidth
Leaf nodes • Let i be a leaf node. Say Xi = {v}. • R(i, {v}) = w(v) • R(i, Æ ) = 0 v G(i) is a graph with one vertex 45 Treewidth
Join nodes • Let i be a join node with children j 1, j 2. • R(i, S) = R(j 1, S) + R(j 2, S) – w(S). + 46 = Treewidth
Introduce nodes • Let i be a node with child j, with Xi = Xj È {v}. • Let S Í Xj. • R(i, S) = R(j, S). • If v not adjacent to vertex in S: R(i, SÈ{v})=R(j, S) + w(v) • If v adjacent to vertex in S: R(i, S È {v}) = – ¥. 47 v Treewidth
Forget nodes • Let i be a node with child j, with Xi = Xj - {v}. • Let S Í Xi. • R(i, S) = max (R(j, S), R(j, S È {v})) 48 v v Treewidth
Maximum weighted independent set on graphs with treewidth k • For node i in tree decomposition, S Í Xi write – R(i, S) = maximum weight of independent set W of G(i) with W Ç Xi = S, – ¥ if such W does not exist • Compute for each node i, a table with all values R(i, …). • Each such table can be computed in O(2 k) time when treewidth at most k. • Gives O(n) algorithm when treewidth is (small) constant. 49 Treewidth
Frequency assignment problem • Given: – Graph G=(V, E) – Frequency set F(v) Í N for all v Î V – Cost function • c(e, r, s) , e = {v, w}, r a frequency of v, s a frequency of w • Question – Find a function g with • For all v Î V: g(v) Î F(v) • The total sum over all edges e={v, w} of c(e, g(v), g(w)) is as small as possible 50 Treewidth
Frequency assignment when treewidth is small • Suppose sets F(v) are small • Suppose G has small treewidth • Algorithm exploits tree decomposition What tables are we computing? – Leaf: trivial – Introduce: … – Forget: projection – Join: sum but subtract double terms 51 Treewidth
General method • Compute a tree decomposition – E. g. , with minimum degree heuristic – Make it nice – Use dynamic programming • Works for many problems – Courcelle: those that can be formulated in monadic second order logic – Practical: TSP, frequency assignment, problems on planar graphs like dominating set, probabilistic inference 52 Treewidth
A lemma • Let ({Xi | i Î I}, T) be a tree decomposition of G. Let Z be a clique in G. Then there is a j Î I with Z Í Xj. – Proof: Take arbitrary root of T. For each v Î Z, look at highest node containing v. Look at such highpoint of maximum depth. 53 Treewidth
A heuristic for treewidth Works often well The minimum degree heuristic • If G has one vertex: take a tree decomposition with one bag. Otherwise • Recursive step: In practice: – Take vertex v of minimum degree iterative, not recursive – Make neighbors of v a clique – Remove v, and recurse on rest of G – Add v with neighbors to tree decomposition N(v) 54 v N(v) Treewidth
Other heuristics • Minimum fill-in heuristic – Similar to minimum degree heuristic, but takes vertex with smallest fill-in: • Number of edges that must be added when the neighbours of v are made a clique • Other choices of vertices, refining, using separators, … 55 Treewidth
Representation as permutation • A correspondence between tree decompositions and permutations of the vertices – Repeat: remove superfluous leaf bag, or take vertex that appears in 1 leaf bag and no other bag – Make neighbours of v = p(1) into a clique; recursively make tree decomposition of graph – v; add bag with v and neighbours • Used in heuristics, and local search methods (e. g. , taboo search, simulated annealing) and genetic algorithms 56 Treewidth
Connection to Gauss eliminating • Consider Gauss elimination on a symmetric matrix • For n by n matrix M, let GM be the graph with n vertices, and edge (i, j) if Mij ¹ 0 • If we eliminate a row and corresponding column, effect on G is: – Make neighbors of v a clique – Remove v 57 Treewidth
Application: Probabilistic networks • Lauritzen-Spiegelhalter algorithm for inference on probabilistic networks (belief networks) uses a tree decomposition of the moralized form of the network • Underlying several modern decision support networks 58 Treewidth
59 Treewidth
Conclusions • Dynamic programming for graphs with treelike structure • Works for a large collection of problems, as long as there is (and we can find) such a structure… 60 Treewidth