320 likes | 431 Views
Constant Time Generation of Linear Extensions. Akimitsu Ono Shin-ichi Nakano Gunma Univ. Input Partial ordering P. Out put Complete List of Linear Extensions of P. 1. 2. 3. 4. 1. 3. 4. 2. 1. 2. 1. 3. 2. 4. 3. 1. 4. 2. 3. 4. 3. 1. 2. 4. 3. 4. 1. 2.
E N D
Constant Time Generation of Linear Extensions Akimitsu Ono Shin-ichi Nakano Gunma Univ. Input Partial ordering P Out put Complete List of Linear Extensions of P 1 2 3 4 1 3 4 2 1 2 1 3 2 4 3 1 4 2 3 4 3 1 2 4 3 4 1 2
Generation Problems Given a class C of objects we wish to enumerate efficiently every object in C without duplications Application: Test data
Basic Enumeration Algorithm 1 Define a dictionary 2 Design two methods find-first-One find-next-of(x) Algorithm Enumeration x = Find-first-One while x != NIL do Output x x = find-next-of (x) Based on this technique many enumeration algorithms have designed.
Improvement (Combinatorial) Gray Code 0000 0001 0011 0010 0110 0111 0101 0100 1100 1101 1111 1110 1010 1011 1001 1000 0000 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 In general, the output of enumeration algorithmis huge and dominates therunning time. If we only output the difference of the objects, then we can improve the running time a lot. O(n) time/each O(1) time/each
Hamiltonian Path Vertex ----- Object obj obj obj obj obj obj
Hamiltonian Path Vertex ----- Object Edge ----- difference is constnat obj obj obj obj obj obj
Hamiltonian Path Vertex ----- Object Edge ----- difference is constnat Hamiltonian Path ----- dictionary obj obj obj obj obj obj
Unfortunately Hamiltonian Path may not exist! Vertex ----- Object Edge ----- difference is constnat No Hamiltonian Path ----- No dictionary obj obj obj obj obj obj
Idea: However A Spanning Tree always exists! obj obj obj obj obj obj
Our Enummeration Algorithm obj 1 Define a spanning tree 2 Design two method find-root find-children-of(x) obj obj obj obj obj obj Algorithm find-children-of(x) Output(x) as a difference find-children-of(x) for each child xi do find-children-of(xi) Algorithm enumeration x = find-root find-children-of (x) If we can find k children in O(k) time, then we can find each object O(1) time for each
Our Enumeration Algorithms Based on this technique (output only difference) + (tree structure) we have designed many enumeration algorithms. Biconnected plane triangulations ICALP2001 Triconnected plane triangulations COCOON 2001 Floorplan ISAAC 2001 Planted tree IPL 2002 Free tree WG2004 Linear extension This Talk plane graph
Linear Extensions Many scheduling problems with precedence constraints are modeled by a linear extension of a partial ordering Input Partial ordering P Out put A Linear Extension of P (All arrow go right!) 1 2 3 4 job job 1 2 job job Given a partial ordering P, one can compute a linear extension of P in O(n+m) time. See page 549 of 3 4
Generating All Linear Extensions Input Partial ordering P Out put Complete List of Linear Extensions of P 1 2 3 4 1 3 4 2 1 2 1 3 2 4 3 1 4 2 3 4 3 1 2 4 3 4 1 2
Known Enumeration Algorithms for Linear Extensions • Well 71 O(n)time / each • Knuth, Szwarcfiter 74 O(m+n)time / each • Vorol and Rotem 81 O(n)time / each • Pruesse and Ruskey 94 O(1)time / each on average • This Talk O(1)time / each (worst case)
Pruesse and Ruskey 94 1 2 3 4 Input Partial ordering P 1 3 2 4 1 2 3 1 2 4 1 3 4 2 3 4 3 1 4 2 3 4 1 2
Pruesse and Ruskey 94 If we can find a Hamiltonian Path then we can output each in O(1) time. However,….. 1 2 3 4 Input Partial ordering P 1 3 2 4 1 2 3 1 2 4 1 3 4 2 3 4 3 1 4 2 3 4 1 2
1 1 2 2 3 3 4 4 1 1 3 3 2 2 4 4 3 3 1 1 2 2 4 4 1 1 3 3 4 4 2 2 3 3 1 1 4 4 2 2 3 3 4 4 1 1 2 2 Pruesse and Ruskey 94 Input Partial ordering P 1 2 3 4
1 1 2 2 3 3 4 4 1 1 3 3 2 2 4 4 3 3 1 1 2 2 4 4 1 1 3 3 4 4 2 2 3 3 1 1 4 4 2 2 3 3 4 4 1 1 2 2 Pruesse and Ruskey 94 G X K2 Input Partial ordering P 1 2 3 4 Hamiltonian ! O(n) time for Trace Output O(1) time/each
Our Algorithm Define A sequence of linear extensions for each A linear extension P 3 1 2 4 Parent of P 1 3 2 4 Root 1 2 3 4 within n step we always reach the Root
Family Tree of Linear Extensions 1 2 3 4 1 3 2 4 1 3 4 2 3 1 2 4 3 1 4 2 3 4 1 2
Our Algorithm 1 2 3 4
Our Algorithm Root 1 2 3 4 1 3 2 4 1 3 4 2 Child of Root
Our Algorithm 1 2 3 4 1 3 2 4 1 3 4 2 3 1 2 4 3 1 4 2 3 4 1 2
Example 123456 Input Partial ordering P 132456 124356 123546 123564 312456 132546 132564 4 1 2 135246 135264 135624 6 3 5 315246 312546 351264 356124 351246 315264 351624 312564 315624
How can we findchildren #Type 1 Child 0 #Type 2 Child 3 #Type 3 Child 0 123456 Input Partial ordering P 132456 124356 123546 123564 312456 132546 132564 4 1 2 135246 135264 135624 6 3 5 315246 312546 351264 356124 351246 315264 351624 We can find k children in O(k) time 312564 315624
Running Time Preprocessing find root linear extension O(m+n) time Then trace the tree in O(n) time O(1) time / each on average
Odd-EvenTravarsal Algorithm find-children-of(x) If depth isodd Output(x) for each child xi do find-children-of(xi) If depth iseven Output(x) 1 123456 3 4 20 10 132456 124356 123546 123564 11 5 2 312456 132546 132564 7 16 135246 135264 13 135624 8 15 6 19 315246 312546 351264 14 356124 351246 9 315264 351624 17 12 312564 18 315624
Running Time Preprocessing find root linear extension O(m+n) time Then O(1) time / each on average ( in worst case)
Summary A simple enumeration algorithm for linear extensions Preprocessing find a linear extension O(m+n) time then trace the tree in O(n) time Output O(1) time / each
Future Works Can we estimate # of descendant objects in the tree without constructing the tree? load balancing
Thank you for your attention! Give me questions and suggestions!