A Faster Tree-Decomposition Based Algorithm for Counting Linear Extensions

Kustaa Kangas, Mikko Koivisto, Sami Salonen · DOI

Introduction

Counting the linear extensions (#LE) of a partially ordered set (poset) is a fundamental problem in computer science. It involves determining the number of total orderings consistent with a given partial order, a task equivalent to finding the number of valid topological sorts. While #LE has critical applications in sequence analysis and graphical model learning, the problem is #P-complete, making efficient general-purpose algorithms unlikely.

Research has pivoted toward parameterized algorithms that leverage specific structural properties of the input. One such property is the treewidth ($t$) of the poset's cover graph. Previous state-of-the-art algorithms for this parameter operated in $O(n^{t+4})$ time. This paper introduces Countle, a new algorithm that improves this complexity to $\tilde{O}(n^{t+3})$ and addresses practical performance variance through machine learning.

Methodology: The Countle Algorithm

The core of Countle is a dynamic programming (DP) framework executed over a "nice" tree decomposition of the poset's cover graph. The primary innovation lies in the treatment of "join nodes"—points in the tree where results from two independent branches must be merged.

In traditional DP on tree decompositions, the join step often becomes a computational bottleneck. The authors demonstrate that this step can be mathematically framed as a multidimensional convolution. By representing DP tables as multivariate polynomials, the algorithm can utilize fast multiplication techniques, such as Kronecker substitution and the FLINT library. This algebraic approach reduces the complexity of the join operation, leading to the overall theoretical speedup to $\tilde{O}(t! n^{t+3})$.

Meta-Algorithmic Optimization

A significant finding of this research is that treewidth is a "blunt instrument" for predicting performance. Even among tree decompositions of the same optimal width, the specific "shape" of the tree can cause running times to vary by an order of magnitude. To solve this, the authors implemented two selection strategies:

  1. Machine Learning Selector: A multivariate linear regression model trained on structural features (e.g., bag sizes, node depths) to predict the most efficient decomposition.
  2. Memory Heuristic: A handcrafted cost function that estimates the memory requirements of each DP step, serving as a proxy for time complexity.

Experimental Results

The algorithm was evaluated using "grid trees"—synthetic posets created by joining $t$-by-$t$ grids. The experiments covered instances with $n$ up to 199 for $t=2$ and $n=59$ for $t=4$. For the machine learning component, the authors collected a dataset of measured running times across 50 different optimal-width tree decompositions for each poset instance.

Performance Comparison

Countle demonstrated a clear empirical advantage over the previous leading inclusion-exclusion algorithm, VEIE. For $t=2$ and $n=100$, Countle completed the task in approximately 20 seconds, whereas VEIE required nearly 200 seconds.

Impact of ML Selection

The machine learning selector proved highly effective, identifying tree decompositions that were significantly faster than the median. For $t=2$ instances, the selector provided nearly a 10-fold speedup compared to a random choice of an optimal-width tree.

Limitations and Future Outlook

Despite its efficiency, Countle is currently constrained to small treewidths ($t \leq 3$). As $t$ increases to 4 and beyond, the $n^t$ factor in the complexity grows rapidly, often making general exponential-time algorithms more competitive. Additionally, the ML model's predictive accuracy showed some degradation at higher treewidths, suggesting a need for more sophisticated feature engineering, such as incorporating the count of compatible orderings within individual "bags."

A remaining theoretical challenge is whether the complexity can be further reduced to $\tilde{O}(n^{t+2})$, which would match the time required to compute the tree decomposition itself.

Summary updated

BibTeX
@article{kangas2020faster,
  author = {Kustaa Kangas and Mikko Koivisto and Sami Salonen},
  title = {{A Faster Tree-Decomposition Based Algorithm for Counting Linear Extensions}},
  journal = {Algorithmica},
  year = {2020},
  doi = {10.1007/s00453-019-00633-1},
}
Figure