Treewidth I (Algorithms and Networks)
Total Page:16
File Type:pdf, Size:1020Kb
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 = + 1 1 1 1789-1854 R R1 R2 = + R R1 R2 R1 R2 R1 Two resistors in series R2 Two resistors in parallel 3 Treewidth Repeated use of the rules 6 6 5 2 2 1 7 Has resistance 4 1/6 + 1/2 = 1/(1.5) 1.5 + 1.5 + 5 = 8 1 + 7 = 8 1/8 + 1/8 = 1/4 4 Treewidth 5 6 6 5 2 2 1 7 A tree structure tree A 5 6 P S 2 P 6 P 2 7 S Treewidth 1 Carry on! • Internal structure of 6 6 5 graph can be forgotten 2 2 once we know essential information 1 7 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 e.g.: – Trees NP-complete – Series parallel graphs • 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 x1, … , xr: A(v) = max{ w(v) + B(x1) + … + B(xr) , A(x1) + … A(xr) } B(v) = A(x1) + … A(xr) 10 Treewidth Linear time algorithm • Compute A(v) and B(v) for each v, bottom- up. – 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 x1, … , xr: – C(v) = the minimum of: • w(v) + E(x1) + … + E(xr) • C(x1) + … + C(xi-1) + D(xi) + C(xi+1) + … + C(xr), over all i, 1 ≤ i ≤ r. – D(v) = w(v) + E(x1) + … + E(xr) – E(v) = min { w(v) + E(x1) + … + E(xr), C(x1) + … + 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 • A 2-terminal graph is a graph = ( , ) with two special vertices and , its terminals. • A 2-terminal (multi)-graph is series parallel , when it is: – A single edge ( , ). – Obtained by series composition of 2 series parallel graphs – Obtained by parallel composition of 2 series parallel graphs 16 Treewidth Series composition s1 s1 s2 + s2s2=t 1 t1 t2 t2 17 Treewidth Parallel composition s s 1 2 s1s1=s 2 + t t 1 2 t1t1=t 2 18 Treewidth 19 6 6 5 2 2 1 7 Series Parallel Series Parallel Graphs 5 havean 6 P S 2 P P 6 SP 2 - tree 7 S Treewidth 1 5 ( ) • Associate to each node of SP 6 2 tree a 2-terminal graph ( ). P S S 6 2 P P 5 7 1 6 2 6 2 20 Treewidth Maximum weighted independent set for series parallel graphs ( ), say with terminals s and t ( ) = maximum weight of independent set S of • () with s ∈ S, t ∈ S • () = maximum weight of independent set S of () with s ∉ S, t ∈ S • () = maximum weight of independent set S of () with s ∈ S, t ∉ S • () = maximum weight of independent set S of () with s ∉ S, t ∉ S • 21 Treewidth Maximum weighted independent set of series parallel graphs 2 • Computing AA, AB, BA, BB for – Leaves of SP-tree: trivial – Series, parallel composition: case analysis, using values for sub-sp-graphs ( 1), ( 2) – E.g., series operation, terminal between 1 and 2 ( ) = max { ( 1)푠+ ( 2) – ( ), ( 1) + ( 2) } • 푠 (1) time per node of SP-tree: ( ) total. 22 Treewidth • Many generalizations • Many other problems • Other classes of graphs to which we can assign a tree-structure, including – Graphs of treewidth , for small . 23 Treewidth Idea of treewidth (intuition) -terminal graph: = ( , , ) | | = • Operations on -terminal graphs with • – Take a 1-terminal graph with one vertex – Add a new terminal vertex with edges only ≤ to (some of) the terminal vertices – Make a terminal vertex `normal’ – Join two -terminal graphs by `gluing’ • Treewidth is (plus/minus 1) number of terminals needed to build graph 24 Treewidth Join (“gluing”) = + 25 Treewidth Tree decomposition g A tree decomposition: a h – Tree with a vertex set b c associated to every node. f e – For all edges , d a a g : there is a set containing c f a g h both and . ∈ b c f – For every : the nodes that contain form a c d connected subtree.∈ e 26 Treewidth Tree decomposition g A tree decomposition: a h – Tree with a vertex set b c associated to every node. f e – For all edges , d a a g : there is a set containing c f a g h both and . ∈ b c f – For every : the nodes that contain form a c d connected subtree.∈ e 27 Treewidth Treewidth (definition) g a h • Width of tree b c f decomposition: d e max | X | −1 a a g i∈I i b c c f a f g h • Treewidth of graph : ( )= minimum c d width over all tree e a b c decompositions of . e f d g h 28 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 • Choose a root a = { }, • Take and for each other node : b e = { , ( )} c a with these bags d gives a tree • decomposition of b a e a width 2 c b d b 30 Treewidth Algorithms using tree decompositions • Step 1: Find a tree decomposition of width bounded by some small . – Heuristics. – ( ( ) ) in theory. – Fast ( ) algorithms for = 2, = 3. – By construction, e.g., for trees, sp-graphs. • Step 2. Use dynamic programming, bottom- up on the tree. 31 Treewidth Separator property w i v If both v and w not in Xi, then v and w are not adjacent 33 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 = 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: Xi Xi Xi Xj(q) Xi … Xj(1) Xj(2) … Xj(q) Xj(1) Xj(2) 35 Treewidth Transformation to a nice tree decomposition • Step 3: Turn binary nodes in join nodes Xi Xi Xj(1) Xj(2) Xi Xi Xj(1) Xj(2) 36 Treewidth Transformation to a nice tree decomposition • Step 4: Nodes with one child get a series of introduce and forget nodes Xi Above, Xi introduce vertices in Xi that are not in Xj Xj Below, forget vertices in Xj that are not in Xi Xj 37 Treewidth Transformation to a nice tree decomposition • Step 5: Ensure that leaf bags have size 1, by adding introduce nodes: v1 v2 … vr v1 v2 … v1 vr v2 … vr … Done! v1 v2 v1 38 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 j1, j1. • Example of how G(i) is build from G(j1) and G(j1): = + 41 Treewidth Introduce nodes • Let i be a node with child j, with Xi = Xj ∪ {v}. v • One new `terminal’ vertex which can only be adjacent to other terminal vertices 42 Treewidth Forget nodes • Let i be a node with child v j, with Xi = Xj − {v}. v • Same graph; one terminal vertex now is a normal vertex 43 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.