GenerateRandomSearch

Degree Sequence Generator

Not every list of numbers can be the degrees of a graph. Some fail for an easy reason — the degrees sum to an odd number, and every edge contributes two — and others fail for a reason you cannot see by looking. Havel–Hakimi settles it constructively: connect the hungriest node to the next hungriest, cross them off, repeat. When it succeeds you get an actual graph, and this page recounts that graph's own degrees to confirm they are the sequence you asked for.

What this generator does

Produces a degree sequence — about half taken from a real graph, half generated freely — and runs Havel–Hakimi to decide whether any simple graph realises it. When one does, the graph is built and its degrees are counted back from its own edge list, with self-loops and repeated edges rejected.

How to use this tool

  1. Choose how many nodes the sequence should describe.
  2. Generate a sequence and decide for yourself whether a graph could have it.
  3. Read the reduction: each line connects the hungriest node to the next few.
  4. Compare the verdict, then generate again — roughly half the sequences are not graphic.

Understanding the controls

How many nodes
Between 4 and 12. The sequence always has one entry per node, sorted from largest to smallest.
Seed
Any word reproduces the same sequence and the same verdict.

Common use cases

  • Teaching Havel–Hakimi with both outcomes actually occurring
  • Checking whether a proposed set of connection counts is possible at all
  • Test instances for a degree-sequence implementation
  • Showing why an odd degree sum is immediately impossible
  • Setting a reproducible exercise from a seed

How this generator works

Havel–Hakimi sorts the remaining demands, takes the largest, and joins that node to the next few largest, reducing each by one. If a node ever needs more edges than there are nodes left, or a target has no capacity, the sequence is not graphic. Two cheap tests run first: no degree may exceed one less than the node count, and the degrees must sum to an even number, because each edge adds exactly two.

Randomness and fairness

The sequence is random; whether it is graphic is decided constructively and, where it is, the resulting graph is checked. A seed reproduces the sequence exactly and is therefore explicitly not cryptographically secure. Without a seed the browser's cryptographically secure generator is used.

For how randomness is produced across the whole site, see how Generate Random works.

Limitations and good to know

  • Simple graphs only — allowing repeated edges or self-loops makes almost every even-sum sequence realisable.
  • One graph is built when several non-isomorphic ones may share the sequence.
  • The reduction is shown for the sorted sequence, which is not always the order you would work in by hand.
  • Twelve nodes is the ceiling, which keeps the reduction readable rather than long.
  • Sequences are not stored between visits; seed one you want again.

Privacy and your data

Everything is computed in your browser. Nothing about the sequence or your seed is transmitted or kept.