Advanced maths

Graphical degree sequence calculator with Havel–Hakimi steps

Decide whether a degree list can belong to an undirected simple graph, showing Havel–Hakimi reductions and one labeled edge realization.

Your numbers

Use 1–40 whole nonnegative degrees. Each must be smaller than the number of entries. Entry positions label vertices 1,2,…; include zero-degree isolates explicitly.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

A list of degrees is graphical when some undirected simple graph has exactly those vertex degrees. This page applies Havel–Hakimi reductions while tracking original vertex labels, so a successful result also supplies one edge list. An odd total degree or an impossible residual-neighbor demand gives a negative decision. Zero-degree vertices remain in the declared graph even though they do not appear as endpoints in its edge table.

THE FORMULARepeatedly remove the largest residual degree d and subtract one from the next d largest residual degrees; a graphical simple sequence reduces to zero.

A worked example

The list (3,3,2,2,2) is graphical. One returned realization has edges 1–2, 1–3, 1–4, 2–5, 2–3 and 4–5. Counting incident edges gives degrees three at vertices one and two and degree two at each other vertex. The six edges also agree with the degree-sum identity (3+3+2+2+2)/2=6. This is one realization; the degree list does not uniquely determine every adjacency.

Good to know

Supports 1–40 degrees, with each a whole number between zero and vertex count minus one. Graphs are undirected and simple: no self-loops or parallel edges. An invalid degree range is rejected as input, while a well-formed but nongraphical list receives a negative result. The construction is deterministic under vertex-label ties but is not a count of possible realizations, a connected-realization solver or an isomorphism classification.

An even degree sum is necessary but does not finish the test

Every undirected edge contributes one degree at each endpoint, so the sum must be even. That test alone misses other obstructions. The sequence (3,3,1,1), for example, has even sum eight and each degree lies within the individual range for four vertices. Yet the two degree-three vertices would each need to meet every other vertex, forcing the remaining degrees to be at least two. Havel–Hakimi exposes the impossible residual requirement.

During a reduction, the removed vertex is connected to vertices with the largest remaining demands. Original labels are kept separately from the sorted residual list, so moving a row during sorting does not rename the graph. The construction can then be checked directly by counting the degree of every original vertex. Returning only the sorted reductions without that label bookkeeping would make a plausible edge table harder to reconcile with the entered order.

One five-vertex simple realization gives degrees three three two two two12345Degrees: 3,3,2,2,2Six simple edgesSum of degrees: 12
Edges 1–2,1–3,1–4,2–5,2–3,4–5 reproduce the input degrees (3,3,2,2,2). There are six edges and the degree sum is twelve. Crossing drawn segments do not introduce an extra graph vertex.

The Shortest path calculator for a weighted graph edge list optimizes routes after the graph edges are known; a degree sequence alone does not determine those routes.

A degree list does not promise connectivity or a unique network

Different graphs can share the same degree sequence, and a successful construction is not generally a unique answer. A routine that makes a different deterministic tie choice may return another equally valid realization. The relevant check is whether the edge set is simple and reproduces every requested degree, rather than whether it matches one particular drawing. This implementation performs that degree check before presenting its successful result.

Isolates illustrate the limits of an edge list particularly clearly. For degrees (0,0,0), the answer is a valid three-vertex graph with no edges, not an empty input and not a connected graph. Likewise, a failed intermediate reduction does not license displaying the partially built edges as a complete solution. The page clears that partial realization and reports the obstruction. Directed degree pairs, multigraph degrees and loop-permitting sequences have different criteria and are outside the simple-graph model used here.

A few questions, answered

Can the edge list omit an isolated vertex?

It has no incident edge row, but the vertex is still present because its zero appears in the degree input. The declared vertex count includes every entry.

Does the algorithm tell me how many graphs realize the sequence?

No. It decides realizability and constructs one labeled example. Counting nonisomorphic or labeled realizations is a separate combinatorial problem.

Find your calculator

Start typing to explore the library.