How this calculation works
Count the simple undirected graphs realizing a degree list on fixed labeled vertices, and return one realization when the count is positive.
Choose d₀ neighbors of vertex 0, decrement their residual degrees and recurse on the remaining labels. Sum the counts of all valid choices.A worked example
The labeled degree list 2,2,2,2 has three realizations: the three distinct four-cycles on labels 0–3. One witness uses 0–1, 0–2, 1–3 and 2–3.
Good to know
1–10 labeled degrees; each integer lies in 0…n−1. Exact counting with a two-million-state cap; no loops or multiple edges.
Reference: NetworkX: graphical sequences and Erdős–Gallai (opens in a new tab) ↗
Counting graphs on fixed labels
A degree sequence records how many neighbors each vertex must have, but usually does not determine its edges uniquely. This calculator counts every simple undirected graph meeting those requirements on the supplied fixed labels. It also returns one edge list so a positive count can be checked constructively.
Label identities matter throughout. Swapping two equal-degree vertices may produce another counted graph if the edge set changes, even when the resulting drawings are isomorphic. This is therefore a labeled realization count, not a count of graph shapes up to relabeling and not merely a yes-or-no graphicality test.
Compare this with the Graphical degree sequence calculator with Havel–Hakimi steps. Count labeled simple realizations rather than only decide graphicality or return one Havel–Hakimi witness.
Entering a degree for every vertex
The first degree belongs to vertex zero, the second to vertex one, and so on. Enter one to ten nonnegative integers separated by spaces or commas. Each degree must be smaller than the total number of entries, since loops are disallowed and a vertex can meet each other vertex at most once.
Include zero-degree vertices explicitly. They remain fixed isolated labels and cannot receive edges during reconstruction. Preserve the list order when comparing the witness with your source data. Sorting an input preserves the total labeled count under a corresponding relabeling, but changes which named vertex receives which specified degree.
The three realizations of four twos
In the default list every vertex has degree two. On four vertices, a simple graph satisfying that condition must be a four-cycle. There are three distinct edge sets on the four fixed labels, even though all three represent the same unlabeled cycle shape. The returned count is therefore three rather than one.
The displayed witness joins zero to one and two, and joins three to one and two. Each label has exactly two incident edges, and there are four edges in total. This also checks the degree-sum identity: the four degrees sum to eight, twice the number of retained undirected edges.
Counting by the next vertex's neighbors
For the first remaining vertex with residual degree d, the algorithm chooses every d-element subset of eligible remaining labels as its neighbors. It removes that vertex, decrements those neighbors' residual requirements and recursively counts completions. Different choices describe different incident edge sets, so their completion counts can be added.
Every final graph has exactly one such first-neighbor choice, making the branches disjoint and exhaustive. Memoizing residual degree lists reuses equivalent continuation problems. The implementation keeps their ordered positions, rather than quotienting them by graph isomorphism, and uses arbitrary-precision counts to avoid rounding large integer totals.
Rejecting impossible residual requirements
A residual list with an odd degree sum cannot be realized because every undirected edge contributes two to that sum. Negative requirements or a degree exceeding the remaining number of possible neighbors also make a branch impossible. These cheap checks prevent exploring edge assignments that cannot reach a valid graph.
The search additionally applies the Erdős–Gallai inequalities to sorted copies of residual degrees. These inequalities decide graphicality for simple undirected degree sequences. They are pruning conditions inside the exact counting recurrence, not a formula for the count itself; a sequence can pass graphicality while still admitting many different labeled realizations.
Verifying the returned edge list
For a positive result, count how many returned edges touch each label and compare that vector directly with the input. Each edge should join distinct labels, and no unordered pair should repeat. The total number of edges must equal half the input degree sum, supplying another independent arithmetic check.
Only one witness is returned, even if the realization count is large. It is a representative completion, not a uniformly random graph from the full set. A zero count reports that no realization exists after a completed computation; it does not mean the program found an empty graph for a nonzero degree list.
Scope, resource errors and small checks
The calculator supports up to ten labeled vertices and a bounded exact search. If the state cap is reached, it raises a resource error rather than returning an approximate count or a false zero. Directed degrees, multigraphs, forbidden pairs and connected-only realization counts require different models and are not inferred from this input.
An all-zero list has exactly one realization: the graph with no edges. An all-(n−1) list also has one: the complete graph. A single odd entry among otherwise zero entries is impossible. These reference cases help distinguish data-entry problems from the important labeled-versus-unlabeled interpretation before analyzing a more complicated sequence.
A few questions, answered
Why do four degree-two vertices give three rather than one?
The three four-cycles have different edge sets on fixed labels, although they share one unlabeled shape.
Does the tool count only connected realizations?
No. Every simple labeled realization is counted, whether connected or disconnected.
Is one returned graph a random sample?
No. It is a reconstructed valid witness, without a uniform sampling guarantee.
Can I use degrees from a multigraph?
Only if you intend simple-graph realizations; loops and repeated edges are excluded here.