PC-tree Data-Structure
- PC-tree is an undirected tree structure that encodes circular orders using P-nodes and C-nodes to enforce consecutivity constraints among elements.
- The update algorithm efficiently enforces consecutivity in O(p + |R|) time by labeling nodes, identifying terminal paths, and performing reordering and merging.
- Empirical evaluations demonstrate that PC-trees outperform traditional PQ-trees with 2–4× speedup in planarity testing and related graph applications.
A PC-tree is an undirected tree-based data structure that encodes sets of circular orders on a finite ground set , subject to constraints that designated subsets of must appear consecutively. By construction, a PC-tree is formed from leaf nodes, which are bijectively mapped to elements of , and inner nodes, which may be P-nodes (permutable) or C-nodes (circular). Consecutivity constraints are enforced via a single uniform update procedure, endowing the PC-tree with both conceptual simplicity and practical efficiency in comparison to PQ-trees, which encode linear orders and require more intricate update logic. PC-trees are predominantly utilized in planarity testing and related applications.
1. Structure and Formal Definition
Let be a finite ground set, interpreted as the token set whose circular orderings are represented by the PC-tree. The PC-tree satisfies the following structural constraints:
- No inner node has degree 2; such nodes are implicitly contracted.
- Inner nodes are partitioned as follows:
- P-nodes, for which the cyclic order of the incident edges may be permuted arbitrarily.
- C-nodes, for which incident edges are arranged in a cyclic order that may only be globally reversed.
- Leaves are in bijective correspondence with .
Given a selection, for each P-node, of a permutation of its incident edges, and for each C-node, a choice between its cyclic order and its reverse, one obtains a circular permutation of by reading off the leaf labels in a boundary walk. The set of all such circular permutations is denoted . Any transformation that replaces with and preserves is valid. Under update operations, remains a PC-tree, and the invariants described above are preserved (Fink et al., 2021).
2. Node Types and Representation of Circular Orders
Each node type in the PC-tree structure serves a distinct role in encoding the constraint space:
- Leaves: Each corresponds bijectively to an element of .
- P-nodes: Allow full permutation of their neighboring subtrees, encoding unconstrained groupings.
- C-nodes: Enforce a cyclic grouping, restricting rearrangement to only a global reversal of the order of attached subtrees.
Reordering leaves at P-nodes and reversing the cyclic order at C-nodes enable the PC-tree to generate all valid circular orders of consistent with the imposed consecutivity constraints (Fink et al., 2021).
3. Update Algorithm: Enforcing Consecutivity Constraints
The principal operation on a PC-tree is to update the tree so that a subset appears consecutively in every represented circular order. This is accomplished by the Update(T, R) algorithm, which follows these steps:
- Labeling: Each node is labeled as full (all but at most one neighbor are full), empty (similarly, all but one are empty), or partial (otherwise).
- Terminal Path Discovery: Identify the unique path of terminal edges (those separating subtrees containing at least one full versus empty leaf) with endpoints and .
- Reordering/Flipping: Along the terminal path, for each P-node, permute incident edges to make full neighbors contiguous; for each C-node, reverse the cyclic order if necessary.
- Splitting: Each node on the terminal path is split into "full" and "empty" nodes, partitioning incident edges.
- Central C-node Insertion: Remove terminal path edges and insert a new central C-node that reconnects the split nodes in a cyclic order.
- Contraction and Merging: Merge adjacent C-nodes, contract degree-2 inner nodes to maintain invariants (Fink et al., 2021).
Each update executes in time, where is the length of the terminal path, and is the size of the restricted set. Applying restrictions takes time overall.
4. Implementation Techniques
Two principal implementation paradigms are recognized:
Hsu & McConnell Template-Based (HsuPC)
- Utilizes a circular doubly-linked list of half-edges (arcs) around each C-node.
- No explicit C-node objects; C-nodes are implicitly represented by the boundaries of their arcs.
- Block-spanning pointers enable merging of contiguous full blocks in .
- Full/partial detection, reordering, splitting, and merging as per the canonical update.
- Optimizations include timestamps on nodes to avoid costly tree traversals and refined handling of root cases (Fink et al., 2021).
Union-Find Based (UFPC)
- Each C-node is an explicit entry in a Union-Find structure, and incident child pointers reference this entry.
- Merging C-nodes is delegated to union operations, facilitating efficient identity management.
- The tree is stored as a classic child-sibling doubly-linked structure, minimizing pointer-chasing overhead.
- Parent lookup is amortized , yielding an overall update time of , with superior cache locality leading to substantially faster practical performance (Fink et al., 2021).
5. Empirical Evaluation and Performance Analysis
Experimental comparisons utilized test suites such as SER-POS (possible restrictions, , ), SER-IMP (impossible restrictions from non-planar cases), and DIR-PLAN (planarity test restrictions, up to , ). Implementations compared included HsuPC, UFPC, the OGDF PQ-tree, and other publicly available PQ- and PQR-tree solvers.
Results demonstrated:
- Both PC-tree implementations (HsuPC, UFPC) run in time linear in —independent of —whereas some PQ implementations exhibit -dependent scaling.
- On DIR-PLAN, median update-time ratios (relative to OGDF) were: HsuPC ~0.45 ( speedup), UFPC ~0.25 ( speedup).
- UFPC outperforms HsuPC for larger restrictions and longer terminal paths (for ).
- Table:
| Implementation | Speedup vs. OGDF |
|---|---|
| HsuPC (PC-tree) | 2.2× |
| UFPC (PC-tree) | 4.1× |
| OGDF (PQ-tree) | 1.0× |
| Gregable (PQ-tree) | 1.8× |
6. Comparison with PQ-Trees
PC-trees and PQ-trees represent equivalent abstract constraints but differ in design and operational complexity:
- Update Mechanisms: PC-trees use a single split+merge update, while PQ-trees require nine template-driven case analyses with recursive matching.
- Implementation Burden: PC-trees avoid complex recursion and case distinctions but require careful handling of the central C-node and immediate contraction/merging to maintain invariants.
- Asymptotic Runtime: Both are theoretically linear in ; PC-trees offer smaller constant factors.
- Empirical Performance: State-of-the-art PC-tree implementations (notably UFPC) are $3$– faster than leading PQ-tree packages in large-scale benchmarks (Fink et al., 2021).
7. Practical Implementation Guidelines
Guidance for effective PC-tree engineering includes:
- Employ timestamps or generation counters to prevent redundant post-update clean-up traversals.
- When adopting the Hsu & McConnell approach, maintain block-spanning pointers for merging of full blocks around C-nodes.
- For Union-Find-based approaches, use explicit C-node objects for identity and unification.
- Store the tree using child-sibling doubly-linked lists to economize on pointer management and enhance cache coherence.
- Pay particular attention to root node edge cases in labeling and terminal path computation.
- Check for impossible restrictions early (flagging nodes with terminal edges or conflicting apexes).
- After central C-node insertion, immediately contract all degree-2 inner nodes and merge adjacent C-nodes to uphold invariants.
- Rigorously test on sequences from planarity testing, both feasible and infeasible, to validate correctness.
- Profile performance on synthetic random planar graphs to optimize low-level data layout and pointer management for target hardware (Fink et al., 2021).