arXiv:2610.38586cs.DSOct 2026

Manuscript Offprint

arXiv:2610.38586

Estimating the number of nodes and paths in a DAG by following a random path

Günter Rote

Abstract

We investigate a simple method to compute an unbiased estimate of the number of nodes of a directed acyclic graph (DAG) by following a random directed path. This method is due to Leonard Pitt from 1987, and it generalizes a method of D. E. Knuth from the 1960s for estimating the size of a rooted tree. A slight variation makes it possible to estimate the number of source-sink paths.

We extend the algorithm to use many “agents” that walk cooperatively through the graph. This extension unifies and generalizes several methods that have been proposed for approximately counting the nodes of a tree.

Keywords. Approximate counting, random walk, importance sampling, polytopes

MSC2020 classification.

05C85 Graph algorithms, 05A Enumerative combinatorics, 62D Statistical sampling

Table of Contents

1Problem statement and the Path Sampling algorithm (Algorithm P)2
1.1Weighted selection3
1.2No backward proportions: counting paths4
1.3Arbitrary arc weights4
1.4Analysis of the expectation5
2Experiments6
2.1The permutation DAG6
2.2Cubes and Klee-Minty cubes7
3Computing the variance of X9
4Importance Sampling10
5Employing a team of agents11
5.1The Team Sampling family of algorithms (TS)11
5.2Bucket Sampling (Algorithm BS)12
5.3Crowd Sampling (Algorithm CS)13
5.4Correctness of the Team Sampling scheme15
5.5Generalized Condensation17
5.6The variance for Team Sampling strategies17
5.7Relation to dynamic programming18

*Institut für Informatik, Freie Universität Berlin, Germany, rote@inf.fu-berlin.de, https://orcid.org/0000-0002-0351-5945

6 Extensions and potential applications 19 6.1 Extension to arc costs 19 6.2 Some applications 19 6.2.1 Vertices of a polytope 19 6.2.2 Triangulations of a planar point set 20 6.2.3 Linear extensions of a two-dimensional partial order 20 6.2.4 Pattern-avoiding permutations 20 6.2.5 Polyominoes 21 6.2.6 Maximal sets of an independence system 21 6.3 Graphs with cycles 22 7 Conclusion 22 7.1 Choice of forward and backward proportions 22 7.2 Provable approximation quality? 22 A Importance Sampling for Klee-Minty cubes 25 A.1 Importance Sampling by the size of the reachable set 26 B Details about implementing Klee-Minty cubes 26 C Purdom's partial backtracking method 28 D Index of important notation 28

References (35)