Skip to content

How many dependency charts (DAGs) are possible when each item depends on at most two or three others

ExplainerOctober 15, 2026updated Nov 21, 202623 min

The first exact counts of bounded-parent Bayesian-network structures (dependency charts, labeled DAGs) beyond the seven nodes of the printed table, with a proof of how fast they grow; a remainder pattern I conjectured was then proved by Roberto Blanco Gómez.

For readers in
opens a short section on what this result means in that field

In brief

These are the first exact counts of bounded-parent Bayesian-network structures beyond nodes: the printed table stopped at 7, and mine run to . I also proved how fast the counts grow, for every cap on the number of parents. A remainder pattern I posted as a conjecture in the OEIS was proved three months later by another mathematician, Roberto Blanco Gómez.

A dependency chart has an arrow from item A to item B when B depends directly on A, and no chain of arrows may loop back. The counts are for charts in which every item has at most two such arrows coming in, or at most three (I call that limit the cap). They are A397711 and A397712 in the OEIS, the public catalogue of number sequences, and they give the number of possible structures of a Bayesian network with that cap.

In the animation below, each dot is an item. The highlighted bar at four dots marks the first size where the cap removes charts.

Animation, no sound. Four dots labelled A to D get arrows one at a time. Each dot has 2 parent slots that fill as arrows arrive. An arrow into a dot whose slots are full is refused and fades, and an arrow that would close a loop is refused and fades. Then bars on a log scale show how many such charts exist for 1 to 7 dots: 1, 3, 25, 443, 13,956, 695,902, 50,741,797. The bar for 4 dots is highlighted. Under the prime sizes 2, 3, 5, 7 a mark shows that the count leaves remainder 1 on division by that size.

Arrows are added one at a time, and each dot may have at most 2 parents: an arrow past the cap, or one that would close a loop, is refused. Then the number of such charts for 1 to 7 dots (OEIS A397711), with the proved remainder 1 at prime sizes.

What was counted

Throughout this page, an arrow from item A to item B means B depends on A, so A is one of B's parents. The cap limits how many arrows may point into any one item. The items carry names, item 1, item 2 and so on, so an arrow from item 1 to item 2 and an arrow from item 2 to item 1 count as two different charts. The cap is on direct parents only, and a chart with a redundant shortcut arrow counts separately from the chart without it.

With two items there are 3 charts: no arrow, an arrow from item 1 to item 2, or an arrow from item 2 to item 1. With three items there are 25, and the cap of two changes nothing yet, because no item has more than two others to depend on. The cap first matters at four items. There are 543 charts with no cap, and in 100 of them some item has all three others as parents, which leaves 443.

How much the cap shrinks the number of charts

Here are the counts with no cap, which were already in the OEIS, next to the counts with a cap of three (A397712) and a cap of two (A397711):

Charts on 1 to 8 items with no cap (OEIS A003024)

1, 3, 25, 543, 29281, 3781503, 1138779265, 783702329343

Charts on 1 to 8 items with a cap of three (OEIS A397712)

1, 3, 25, 543, 26566, 2556342, 435055552, 120754619365

Charts on 1 to 10 items with a cap of two (OEIS A397711)

1, 3, 25, 443, 13956, 695902, 50741797, 5111573805, 681834525328, 116541746850536

The share a cap of two keeps drops fast: about 1 chart in 22 at seven items, and about 1 in 153 at eight. At 20 items the count with no cap has 73 digits and the count with a cap of two has 41, so the cap keeps about 1 chart in 6 × 10³¹ (6 followed by 31 zeros).

Where the counts are used

A Bayesian network is built on a chart like this: one dot per variable, and the model gives each variable's probabilities in terms of its parents. A small example has arrows from "it rained" and "the sprinkler ran" into "the grass is wet", so the model gives the chance of wet grass for each combination of rain and sprinkler. Learning such a network from data means choosing the chart as well as the probabilities. One common approach gives candidate charts a score for how well they fit the data and looks for charts that score well. To keep this manageable, programs often cap the number of parents per variable, sometimes at two or three. For a search that works directly over charts with the cap as its only restriction, the counts on this page give the size of the space it searches.

The search itself does not need that number to run, but two narrower tasks use counts of this kind. One is drawing capped charts at random with every chart equally likely, which is one way to make test cases for learning methods; published samplers for this compute counts of this kind along the way. (The 2017 table credited below was made to draw these same charts at random with every chart equally likely, as the dependency structures of acyclic CP-nets, a kind of preference model.) The other is setting structure priors, the weights a learning method puts on charts before it sees data, which Eggeling and co-authors (2019) build from counts of this kind.

Different charts can describe exactly the same patterns in data. The simplest case is a single arrow from A to B against a single arrow from B to A: both say only that A and B are related. From observational data alone, without extra assumptions, a learning method cannot choose between such look-alikes, so the number of models this kind of data can tell apart is smaller than these counts. Experiments, or extra assumptions about how the data were produced, can separate some of them. I did not count the groups of look-alikes.

Some learning methods search through orderings of the items instead of through charts, which counts a chart once for every ordering it fits; the section for specialists gives the numbers.

For readers in machine learning:what this looks like in machine learning terms, and where the comparison stops

In the language of probabilistic graphical models, the count with a cap of k is the number of Bayesian network structures on n labelled variables in which every variable has at most k parents: the bounded parent sets that exact structure-learning algorithms assume. It is the size of the search space for structure learning that rates candidate charts, under that standard restriction. The structure-learning literature (Friedman and Koller; Koivisto and Sood) describes that space as growing roughly like n to the power k·n (two to the power k·n·log n, with the logarithm to base two), and the paper proves the growth law with its linear term. Where the comparison stops: these are counts of charts, not of the groups of look-alike charts that data cannot tell apart, and no learning algorithm was run.

How the counts were found and checked

I chose the question, directed and checked the work, and decided what was published. Claude agents (Claude is an AI model made by Anthropic) ran the searches and computations and, under my direction, derived the recurrences and the growth results with their proofs.

The exact counts are in the OEIS (the On-Line Encyclopedia of Integer Sequences, a public catalogue that gives each number sequence an ID starting with A): A397711 for a cap of two, through items, and A397712 for a cap of three, through items. They are the first OEIS entries for these counts and the first enumeration of them beyond items. A 2017 paper had printed them for up to items, and a 2019 paper gave a formula for them without listing values; both are credited below.

Claude agents computed the counts four ways, all with programs written within the project. Two programs build capped charts one at a time and test each for loops; that only works for small sizes, and they reach 5 and 8 items. The other two are formulas: the level formula explained in the next section, and a recurrence that builds each chart by setting aside the items that depend on nothing. All four agree at every size each one reached. In July the two formulas were compared up to 13 items; the public check script for the paper now compares them up to 30, and compares a third formula, the published recurrence below, with the level formula at every size up to 100.

Three checks use values or methods from outside the project. The level formula, given a cap of one or no cap, reproduces the two sequences that were already in the OEIS. In October 2026 a program written from the recurrence published by Eggeling, Viinikka, Vuoksenmaa and Koivisto in 2019, which works for any cap, reproduced every value in the table, in all (the table starts at 0 items, with one empty chart, and runs to 100). And the one earlier table known to me agrees with ours: Allen, Goldsmith, Justice, Mattei and Raines printed these counts for up to items in a 2017 paper on generating random preference networks (JAIR). Claude's searches in July 2026 missed that table; a literature check in October found it.

For the paper, the published recurrence was then run much further: exact counts up to items with a cap of two or three, and up to 2,000 with a cap of four. The count for items with a cap of two has more than 14,000 digits. All of it is exact whole-number arithmetic on a laptop: the run for a cap of two, every count up to 2,500 items, took under five minutes. A single check script in the public record, which needs nothing beyond standard Python, reruns every number in the paper in about a minute: the formulas, the brute-force counts for small sizes, other authors' published recurrences, the growth bounds and the remainder patterns.

How the formula works

The formula sorts the items into levels. Items with no parents form level 1. An item goes on level 2 if the longest chain of arrows ending at it has one step, on level 3 if it has two steps, and so on. So every item above level 1 has at least one parent on the level just below it, and all its parents on lower levels. Going the other way, any choice of parents that follows this rule gives a chart with no loop (every arrow points up) and with exactly these levels (each item has a parent one level down).

With three items it works like this:

  • All three on level 1: no arrows, 1 chart.
  • One item on level 1 and two on level 2: 3 ways to pick the level-1 item, and each level-2 item must have it as a parent. That is 3 charts.
  • Two items on level 1 and one on level 2: 3 ways to pick the pair. The top item has one of the pair, the other, or both as parents. That is 9 charts.
  • One item on each of three levels: 6 orders. The middle item's parent is the bottom one, and the top item must have the middle one and may or may not also have the bottom one. That is 12 charts.

The total is 1 + 3 + 9 + 12 = 25, the count above. With four items the cap starts to matter. Put three items on level 1 and one on level 2: there are 4 ways to pick the top item, and it takes one or two of the three below as parents, 6 choices, so 4 × 6 = 24 charts. Without the cap it could also take all three, 7 choices and 28 charts. This is one of several splits where the cap binds; across all of them it removes the 100 charts counted earlier.

A project planner will recognise the levels. If every task takes one day and any number of tasks can run at once, an item's level is the earliest day it can be finished, and the number of levels is the length of the critical path, the longest chain of dependencies in the chart.

Every chart has exactly one way of splitting its items into levels, so nothing is missed or counted twice. Once the levels are fixed, the cap only limits how many parents each item picks, so each item chooses on its own and the count for one split is a product. The formula adds those products over all splits. A program does this for all sizes at once; it produced every count up to 100 items, the largest with 350 digits, in 1.5 seconds. The method is a standard one; the exact formula is in the section for specialists.

Remainder 1 at prime sizes

Divide each count by the number of items and look at the remainder. When the number of items is prime, the remainder is always 1, for every cap and with no cap: with five items, 13,956 divided by 5 leaves 1. That gives a cheap test for any program that counts charts like these: a count at a prime size that leaves any other remainder is wrong (a wrong count can still pass by chance, so passing proves little). The proof renames the items around a circle and is told step by step in the from-the-start explainer, and in brief in the section for specialists.

A second pattern for a cap of two, proved by Roberto Blanco Gómez

With a cap of two the remainders follow a rule at every size from 3 on, prime or not. An odd number of items, from 3 on, leaves remainder 1. An even number, from 4 on, leaves one more than half the number of items: 443 divided by 4 leaves 3. (With two items the remainder is 1, so the even rule starts at 4.) I noticed the rule in remainders that Claude agents computed under my direction, checked it at every size from 3 to , and listed it in the OEIS entry as a conjecture. It depends on the cap: with a cap of three it first fails at six items, which leave remainder 0, not 4, and nine items leave 7, not 1.

In October 2026 Roberto Blanco Gómez proved that the rule holds for every size, in a preprint linked from the OEIS entry (the preprint has not yet been refereed by a journal). He also proved a version for every cap: take the count, subtract 1, and multiply by the least common multiple of the whole numbers from 1 up to the cap (2 for a cap of two, 6 for a cap of three). The number of items always divides the result. Claude agents working under my direction re-checked his work by computer: the recurrence his proof starts from (the one published by Eggeling and co-authors) reproduces all values in the table, and new code written from his statements confirms the rule up to items. The proof and these checks are described on their own page, and both remainder arguments are explained from the start on the page below.

How fast the number grows

Counts like these grow very fast, and the natural question is how fast, the kind of question analytic combinatorics and asymptotic analysis study. My paper answers it for every cap. Roughly, the number of charts on n items with a cap of k grows like n to the power k·n. The theorem also pins down the next term. In natural logarithms,

log (count) = k·n·log n − (k − 1 + log((k − 1)!))·n + error,

where the error grows no faster than a constant times √n·log n, which is tiny next to the first two terms. For a cap of two the formula reads 2n·log n − n. The paper also traps the cap-two count between two simple products: it is at least n!·(n − 1)! and at most (n + 1)n − 1·(n − 1)!.

The exact counts up to items point to an error much smaller than the proof guarantees. It seems to behave like a constant times the cube root of n, and for caps two, three and four the fitted constant matches, to within 0.002, one built from the Airy function, a function that also turns up in optics and quantum mechanics. Cube-root terms of this kind have been proved for two other families of DAGs. For these charts it is still a conjecture.

The paper, "Labeled acyclic digraphs with bounded in-degree", also gives a new recurrence that sets aside the items that depend on nothing and keeps track of how many more parents each remaining item may take. That lets it count charts in which different items have different caps, which the earlier recurrences do not do. I submitted the paper to a journal in November 2026, and it is under review. The submitted version is public as a preprint on aiXiv (not peer reviewed; aiXiv is not affiliated with arXiv). Its code and outputs are public in a Zenodo record.

For specialists: the entries, the formula, the methods, prior work, the order count, Markov equivalence and growth

The object is labeled DAGs on n nodes with every in-degree at most a fixed cap k: vertex-labeled, so isomorphic DAGs with different labelings count separately. "Dependency chart" is this page's plain-language name, not a standard term. Entries: A397711 (k = 2, n = 0 to 100), A397712 (k = 3, n = 0 to 30), and the triangle A395247 by exact maximum in-degree, added at an OEIS editor's request. The entries start at n = 0 with a(0) = 1 (the empty graph); the lists in the body start at n = 1. The k = 3 terms from n = 0 begin 1, 1, 3, 25, 543, 26566, 2556342, 435055552, 120754619365, 51350946391960. For k = 1 the count is (n+1)^(n-1), labeled rooted forests (A000272 shifted); for unbounded k it is Robinson's A003024.

Level decomposition (stated in the A397711 entry). Classify nodes by height, the length of the longest directed path ending at the node. Every node above the bottom level takes all its parents from earlier levels, with at least one on the previous level; conversely every digraph built this way is a DAG with exactly these heights. Only in-degrees are constrained, so given the levels, parent choices are independent:

a_k(n) = sum over compositions (m_1, ..., m_L) of n of
         n! / (m_1! ... m_L!) * prod_{j=2..L} F_k(m_{j-1}, m_1 + ... + m_{j-2})^(m_j)
 
F_k(p, q) = sum_{i=1..k} [ C(p+q, i) - C(q, i) ]

F_k(p, q) counts parent sets of size at most k drawn from p + q earlier nodes with at least one among the p on the previous level; for k = 2 it is p + pq + C(p, 2). The sum has 2^(n-1) terms, so it is evaluated as a dynamic program over (nodes placed, size of the last block): O(n²) states, each built from O(n) choices of the next block size, so O(n³) big-integer operations for fixed k (arithmetic operations, not bit complexity). The height decomposition is a standard

device. Kuipers and Moffa (2015) use the same layers to sample DAGs: their Section 7.4 gives the summand above for at most K parents per node, and their Section 7.3 recursion, for at most K children, gives these counts after edge reversal and a sum. The root-layering of Talvitie, Vuoksenmaa and Koivisto (UAI 2019, PMLR 115, 2020) is the same partition, and their recurrence (7), with weight 1 on parent sets of size at most k, accumulates the same sum. Neither paper states the total as a count of DAGs or lists its values.

Methods: an edge-subset brute force with a DFS cycle test (Python, n ≤ 5, also run with k = 3); a backtracking search that assigns capped parent sets node by node, with incremental transitive-closure bitmasks for cycle detection (C, n ≤ 8, about 100 seconds at n = 8); the level sum; and a Robinson-style inclusion-exclusion over sets of sources. Under a parent cap, removing sources does not factor, since the remaining nodes may still take parents among the removed ones, so for k = 2 the recurrence carries the state (n₀, n₁, n₂), the numbers of remaining nodes with 0, 1 or 2 parent slots left. All four agree for n ≤ 5, three for n ≤ 8, and the level sum and the source recurrence for n ≤ 13 in July (the paper's public check script now compares them for n ≤ 30). The source recurrence is the one written in July; the sink recurrence below, which factors under a cap, was used for the October recheck. The level sum reproduces A000272(n+1) for k = 1 and A003024 for unbounded k, both for n ≤ 8, and matches the edge brute force for k = 3 up to n = 5. The sink recurrence a(n) = sum_{j=1..n} (-1)^(j+1) C(n, j) f(n-j)^j a(n-j), with f(m) = sum_{i=0..k} C(m, i), which is Corollary 4 of Eggeling, Viinikka, Vuoksenmaa and Koivisto (AISTATS 2019), reproduced all of n = 0 to 100 for k = 2 in October 2026, and the paper's check script compares it with the level sum for n ≤ 100 at k = 2 and 3.

Prior work and searches. In July: the OEIS for the initial terms in several windows (k = 2 and k = 3) and by keyword; web searches for the exact values next to Bayesian-network and in-degree terms; a full-text arXiv search (math papers) for one value; and phrase searches ("number of DAGs" or "acyclic digraphs" with "at most two parents" or "in-degree at most 2" and the value 443; Bayesian networks with "bounded indegree" and "number of structures"). The one counting result found was Chen and Pearl, UCLA technical report R-430, "Random Bayesian networks with bounded indegree", which works with the order-fixed model (a product over nodes), not the DAG count. A literature check in October found the earlier tabulation: Allen, Goldsmith, Justice, Mattei and Raines (JAIR 59, 2017), Theorem 18 and Table 1, give the counts for n ≤ and every cap, by a recurrence over Steinsky's DAG codes, for uniform generation of acyclic CP-nets; their entries equal ours. Eggeling et al. (above) give the recurrence without values.

Order count. The number of pairs (DAG with in-degree at most 2, topological order) is a one-line product, since each node picks its parents independently from the nodes before it:

B(n) = n! * prod_{j=1..n} (1 + (j-1) + C(j-1, 2))
     = 1, 1, 4, 48, 1344, 73920, 7096320, 1092833280, ...   (n = 0, 1, 2, ...)

B(n)/n! is the number of DAGs compatible with one fixed order. B(n)/a(n) is the mean number of linear extensions per DAG: 5.30 at n = 5, 333 at n = 10, about 1.7 × 10^8 at n = 20 and about 4.2 × 10^24 at n = 40. This mean measures the total overcount, not the bias. Under the uniform distribution on (order, DAG) pairs, a DAG's probability is proportional to its number of linear extensions, which ranges from 1 (for example, a directed Hamiltonian path) to n! (the empty DAG); the spread of that distribution under the cap was not computed. Order MCMC (Friedman and Koller, UAI 2000) and the exact method of Koivisto and Sood (JMLR 2004), which sums over orders under an order-modular prior, carry this weighting by design; it is known in that literature and is not a finding of this page.

Markov equivalence. Two DAGs are Markov equivalent when they encode the same conditional independences, which happens exactly when they have the same skeleton and the same v-structures. Without further assumptions, and in particular for linear structural models with Gaussian noise of unrestricted variances, observational data cannot distinguish Markov-equivalent DAGs. Interventional data can separate some of them, and so can restricted model classes, such as linear models with non-Gaussian noise or Gaussian noise with equal error variances. Every DAG in a class has the same multiset of in-degrees, which follows from Chickering's covered-edge result (1995), so the cap means the same thing for every member of a class. The number of classes under a cap was not computed.

Prime case: for prime p, a_k(p) ≡ 1 (mod p) for every k. The cyclic group of order p acts by relabeling and preserves acyclicity and every in-degree, so it acts on the set; orbits have size 1 or p; a DAG fixed by the p-cycle with an edge i → i+d contains the directed cycle i → i+d → i+2d → ⋯ → i, so only the empty DAG is fixed. For k = 2 the entry conjectured a(n) ≡ 1 (mod n) for odd n ≥ 3 and a(n) ≡ n/2 + 1 (mod n) for even n ≥ 4, checked for n ≤ . Further examples: 695,902 ≡ 4 (mod 6) and 5,111,573,805 ≡ 5 (mod 8). For k = 3 the even case first fails at n = 6, where a(6) ≡ 0 (mod 6), and the odd case at n = 9: a(9) ≡ 7 (mod 9). Nothing is conjectured here for k ≥ 3. In October 2026 Roberto Blanco Gómez proved the k = 2 statement for all n (preprint on Zenodo, linked from A397711), and for every k ≥ 1 and n ≥ 1 that n | lcm(1, …, k)·(a_k(n) − 1). His proof of the general statement is an induction over the recurrence over sinks (nodes that are nobody's parent; this is the recurrence of Eggeling et al. above), and the even case for k = 2 uses Burnside's lemma. For k = 3 the multiplier is 6, which is why a_3(9) ≡ 7 (mod 9) is allowed.

Growth (natural logarithms). For every fixed k ≥ 2, my paper proves log a_k(n) = k n log n − (k − 1 + log((k − 1)!)) n + O(√n log n), and for k = 2 the bounds n!(n − 1)! ≤ a_2(n) ≤ (n + 1)^(n−1) (n − 1)!, whose ratio is e^(n + O(log n)). The leading term is elementary: one fixed order of the nodes gives a lower bound and one parent set per node an upper bound. Exact values by the sink recurrence, for n ≤ at k = 2 and 3 and n ≤ 2,000 at k = 4, suggest that the true error is of order n^(1/3), with coefficient 3α₁((k − 1)²/2)^(1/3), where α₁ = −2.33810… is the largest zero of the Airy function; least-squares fits give the coefficient of n^(1/3) to within 0.002 of this value for k = 2, 3 and 4. Factors e^(c n^(1/3)) are proved for compacted binary trees and relaxed k-ary trees. The paper states this as a conjecture. It also explains the slow drift of a_2(n+1)/(n² a_2(n)), which rises from 2.285 at n = 20 to 2.522 at n = 90 toward its limit e.

This page is the current account of the counts, their uses and their growth. The remainder arguments are told in full on the from-the-start explainer, which writes the cap as r where this page writes k. The July post is the dated record of the counts as they stood then, in project-planning terms, as tasks that wait on at most two or three others: Counting dependency charts where each task waits on at most two or three others.

Revision history

  1. 2026-11-21 · revised

    The paper on these counts, in the version submitted to a journal, is now public as a preprint on aiXiv (not peer reviewed; aiXiv is not affiliated with arXiv), and the page links it.

  2. 2026-11-20 · corrected

    The heading again says the pattern was proved by Roberto Blanco Gómez; the sentence below it says that the proof is a preprint, not yet refereed. The page now leads with the first exact counts beyond the printed table, states the remainder rule from its starting sizes, credits the recurrence the re-check used to Eggeling and co-authors, gives the full role of Claude, links the OEIS entries and the preprint, and leaves the remainder arguments to the from-the-start explainer.

  3. 2026-11-16 · revised

    Said that the largest counts ran on a laptop in under five minutes and that one public script reruns every number in the paper in about a minute; linked the levels of the formula to the critical path of a project; named analytic combinatorics; added a door for readers from machine learning (Bayesian network structures and the structure-learning search space).

  4. 2026-11-15 · revised

    The paper on these counts has now been submitted to a journal and is under review, and the page links its code and outputs on Zenodo.

  5. 2026-11-14 · revised

    Updated with the new results: exact counts far past the published tables, a proof of how fast the number of charts grows, the source recurrence for mixed caps, and Roberto Blanco Gómez's proof of the cap-two remainder rule together with his statement for every cap.

  6. 2026-11-12 · corrected

    A heading called the cap-of-two pattern proved; a proof has been posted but not refereed, and the heading now says so. The page also no longer calls a cap of two or three parents the usual restriction in Bayesian-network learning, and it says that the earlier table was made for acyclic CP-nets, whose dependency structures are the same charts.

  7. 2026-11-12 · status-change

    Listed after a best-version panel: three independent drafts, blind judging and a final accuracy audit.

  8. 2026-11-10 · corrected

    Several statements were corrected: the average number of orders per chart is now described as the total overcount, not the size of the bias toward charts that fit many orders; the method of Koivisto and Sood is described as summing over orders; the growth fits, which did not hold up, are replaced by proved bounds; the limit on telling look-alike charts apart is scoped to observational data; and the recurrence of Eggeling and co-authors is credited in the main text.

  9. 2026-10-29 · corrected

    The page said my searches found no earlier count of these charts, as if none existed. A 2017 paper by Allen, Goldsmith, Justice, Mattei and Raines prints them for small sizes; the page now credits it and says that A397711 and A397712 are the first OEIS entries for these counts, with values far past that table.

How to cite this

Tyler Satchel Orden (2026). How many dependency charts (DAGs) are possible when each item depends on at most two or three others. Cyborg Mathematics. https://cyborgmathematics.com/writing/explainer-counting-dependency-charts (updated November 21, 2026)

This page has no DOI of its own. Cite the URL and the date; the revision history above keeps a dated citation meaningful.

BibTeX
@misc{orden2026explainercountingdependencycharts,
  author       = {Tyler Satchel Orden},
  title        = {How many dependency charts (DAGs) are possible when each item depends on at most two or three others},
  year         = {2026},
  howpublished = {Cyborg Mathematics},
  url    = {https://cyborgmathematics.com/writing/explainer-counting-dependency-charts}
}

See also