Presentation is loading. Please wait.

Presentation is loading. Please wait.

PC-Trees vs. PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting.

Similar presentations


Presentation on theme: "PC-Trees vs. PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting."— Presentation transcript:

1 PC-Trees vs. PQ-Trees

2 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting the terminal path Observations on PC-trees

3 3 Q P 1 2 3 56 Q 4 1 2 3 4 5 6 1 1 0 0 0 0 0 1 1 0 0 0 1 1 1 1 0 0 0 0 0 1 1 1 PQ-trees and the COP

4 4 Circular Ones Property (CLOP) Does there exist a column order such that either –the 1’s in each row are consecutive or –the 0’s in each row are consecutive It would be easy to see if you wrap around the column indices in a circle.

5 5 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting the terminal path Observations on PC-trees

6 6 PC-Trees A PC-tree is an un-rooted tree with two types of nodes P and C. Neighbors of a P-node can be permuted arbitrarily (Note that here we did not say “children” because there is no specific root). Neighbors of a C-node obey a clockwise order, which can only be inverted. Each C-node is associated with a circular link-list.

7 7 PQ-trees → PC-trees Q1Q1 P 1 2 3 Q2Q2 56 4 1 2 3 5 6 4 Root C1C1 P C2C2 If you consider the order of the parent and children of a Q-node in a cyclic fashion, its clockwise order can only be inverted, which is the spirit of a C-node

8 Cycle View of PC-trees 8 5 6 P 12356 4 C C P 1 4 2 3

9 9 PC-trees and the circular ones property PC-trees can record all feasible circular permutations of the column indices 2 P 1 3 56 4 1 2 3 4 5 6 1 1 0 0 0 0 0 1 1 0 0 0 1 1 1 1 0 0 0 0 0 1 1 1 1 0 0 0 1 1 C C 1, 5, 6 are consecutive

10 10 Rotation of PC-trees 1 2 3 56 4 C Root C P 2 3 56 4 C C P 1 The “root” concept is not important for PC-trees. It is there to maintain the parent-children relation for efficiency.

11 11 PC-trees and the consecutive ones property PC-trees can also be used to record all feasible permutations for consecutive ones (fix the first column to be 1) P 1 2 3 56 4 1 2 3 4 5 6 1 1 0 0 0 0 0 1 1 0 0 0 1 1 1 1 0 0 0 0 0 1 1 1 C C

12 12 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting the terminal path Observations on PC-trees

13 13 The PC-tree algorithm 1.Node labeling (up to the LCA) The same as in PQ-tree. Process according to the depth of the tree (the deepest first) 2.Tree splitting Create a new C-node This is also an online algorithm (rows are processed as they are given), but without any templates

14 14 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting the terminal path Observations on PC-trees

15 15 Objective: Find a path that separates the full subtrees from the empty onesObjective: Find a path that separates the full subtrees from the empty ones –Sufficient to find the two end nodes of this path By changing the root, some parent-child relations have to be changedBy changing the root, some parent-child relations have to be changed Terminal NodeTerminal Node –A partial node whose children are either empty or full relative to some rooting Our approach: Finding a separating path empty full

16 16 Key observations at every iteration There are at most two terminal nodes –There is a unique tree path between these two nodes Full children of C-nodes on the path can be correctly flipped to one side, and empty ones to the other side

17 17 The unique terminal path between two terminal nodes u, u’ (I) um u' empty full Flippable C-node R Case 1. u, u’ and R are not on a path

18 18 The unique terminal path between two terminal nodes u, u’ (II) u u' R empty full Case 2. u, u’ and R are on a path, u’ is the LCA When you reach u’, no more full nodes to be processed

19 19 Forbidden structures on PC-trees Whenever you have such a collection of subtrees, the matrix does not satisfy the CLOP (and hence, does not satisfy the COP). –Why? 1, 3, 5 have to be next to each other. –WLOG, assume the order is 135 where 3 is between 1 and 5. But then, there is no place for 4, which needs to be to the left or right of 3.345612 Where 1, 3, 5 are distinct and consecutive

20 20 Forbidden structures on PC-trees3456 1. Three terminal nodes 2. Non-flippable C-node12 Where 1, 3, 5 are distinct When three parents are on a path The following two cases are forbidden for matrices satisfying the CLOP

21 21 Key observations at every iteration There are at most two terminal nodes –There is a unique tree path between these two nodes Full children of C-nodes on the path can be correctly flipped to one side, and empty ones to the other side

22 22 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting the terminal path Observations on PC-trees

23 23 The unique terminal path between two terminal nodes um u' empty full

24 24 The path splitting operation m m Duplicate each P-node that has both a full subtree and an empty subtree

25 25 Connecting to the new C-node (I) - using the “full side” as an example um u' All P-nodes on the path connects directly to the new node –obeying the order on the path All C-nodes on the path are deleted. Their children connect directly to the new node –obeying their original order as well as path order

26 26 Connecting to the new C-node (II) C PP CC 154278 6 3 P P 154278 6 3

27 A Graphical Illustration of the PQ-Tree Operations vs. the PC-Tree Operations For this example, we only demonstrate the flipping process (but not the merge operation)

28 28 Template Matching of PQ-trees (I) P Q P PP Q P Q

29 29 Template Matching of PQ-trees (II) P Q P PP Q P Q V Here, we only consider the flipping operation and not the tree merging

30 30 Column Ordering of PQ-trees P Q P PP Q P Q 1 23 4 56 7 8 9 10 1112 13 14 15 16 17 18

31 31 P Q P PP Q P Q 7 5 4 6 3 2 89 1112 15 14 13 16 10 17 18 1

32 32 What has been accomplished by the flipping ? P Q P PP Q P Q P Q P PP Q P Q

33 33 Another look at the result of the flipping operation m u u’ P Q P PP Q P Q

34 34 The corresponding PC-Tree Operation P4P4 P1P1 P3P3 P2P2 P5P5

35 35 LCA: The least common ancestor of full leaves 1.LCA is a full node: No tree modification necessary 2.LCA is a partial node: A child Q-node is created with the full children arranged consecutively (there can be many cases, one example is shown below) The PQ-tree after the modification

36 36 An example for a PC-tree operation equivalent to a template conversion

37 37 Complexity Analysis Want to show the cost is proportional to the # of 1’s in the row (i.e. # of full leaves). 2-child with parent pointers for each C-node. –Can only keep parent pointer for two “end” nodes –Keep a cycle for each C-node as a double linked list –Internal node of the cycle find parent through neighbors! virtual real

38 38 How to pass the full node information to the parent? If a full node has a parent pointer, easy If this node is on a cycle, then inform its two neighbors –This would help form consecutive segments of full nodes When every full node of a cycle does that (note that they become full at different time), you should get a consecutive list of full nodes of the cycle

39 39 How many edges and links are traversed? Edges emanating from full nodes Edges in terminal path um u' empty full

40 40 The cost of link traversal within a C-node For each internal node of a C-node, inform its two neighbors when it becomes full or partial. –Since full children of a C-node must be consecutive, it is easy to check at the end whether this C-node is full or partial –There can be at most two neighboring children of the C-node being partial

41 41 Traversing the full nodes Every P-node should have has least two children. Traversal of every full C-node is  # of full nodes in the cycle. So the traversal cost of a full tree is  2 x (# of full leaves)

42 42 A potential problem: what if a cycle contains very few full nodes? The cost of forming this cycle (traversing through empty P-nodes in the cycle) is not proportional to the number of full nodes. u u'

43 43 Charging the Traversal of P-nodes in the terminal path separately Every time a P-node is traversed in forming the cycle, its two neighboring tree edges become cycle links Once a tree edge becomes a cycle link, it remains as a link. –Each tree edge can be converted to a link at most once! Link traversal  # of full subtrees

44 44 The cost of path splitting (I) Instead of connecting the new C-node to each of its children, go around the boundary of the C-node to form its cycle. C P P C C 154278 6 3 P P 154278 6 3 Each P-node that has both a full subtree and an empty subtree is duplicated

45 45 Path splitting and the new C-node The terminal path The new C-node Cost = path traversal + # of P-node duplication

46 46 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting the terminal path Observations on PC-trees

47 47 Final observations (I) At every iteration, we determine a unique path that separates the tree into “two parts” (for circular ones, the root is immaterial).

48 48 The circle view

49 49 Final observations (II) The two terminal nodes actually give the two “cuts” in terms of the column partition (when the new row is placed into the current partition).


Download ppt "PC-Trees vs. PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting."

Similar presentations


Ads by Google