Graph Degree Sequence Validator
Erdős–Gallai Theorem · Havel-Hakimi Algorithm · Graph Realization
Enter a sequence of integers to determine if it is a valid graphical degree sequence using the Erdős–Gallai theorem, then construct a realization via Havel-Hakimi.
Quick Examples
Checks & Properties
Erdős–Gallai Condition Table
For each k, the inequality ∑i=1k di ≤ k(k−1) + ∑i=k+1n min(di, k) must hold.
| k | Left: ∑ di | Right: k(k-1)+∑min | Satisfied? |
|---|
Havel-Hakimi Construction Steps
Sort descending, connect the highest-degree vertex to the next d vertices, remove it, repeat.
| Step | Current Sequence | Edges Added | Remaining |
|---|
Graph Realization — Edge List
Graph Visualization
What Is a Degree Sequence?
In graph theory, a degree sequence is the list of degrees of all vertices in a graph, typically written in non-increasing order. The degree of a vertex is the number of edges incident to it. For example, a graph with five vertices connected as a cycle-like structure might have the degree sequence [3, 3, 2, 2, 2], indicating two vertices of degree 3 and three of degree 2.
Degree sequences serve as a compact fingerprint for graphs. They encode important structural information about connectivity, regularity, and possible topologies without specifying which vertices are connected to which.
Graphical Sequences: What Makes a Sequence Valid?
A sequence of non-negative integers is called graphical (or a graphic sequence) if it can be realized as the degree sequence of some simple graph — a graph with no self-loops and no multiple edges between the same pair of vertices. Determining graphicality is a fundamental problem in combinatorics.
Not every sequence qualifies. For instance, [3, 3, 2] is not graphical because there are only 3 vertices but the highest degree is 3, which would require connections to 3 other vertices — impossible in a 3-vertex graph. The sequence [1, 1, 1] fails because the sum (3) is odd, violating the Handshaking Lemma.
The Erdős–Gallai Theorem
The Erdős–Gallai theorem, proved by Paul Erdős and Tibor Gallai in 1960, provides a complete characterization of graphical sequences. A non-increasing sequence d₁ ≥ d₂ ≥ … ≥ dₙ of non-negative integers is graphical if and only if:
- Even sum: The sum d₁ + d₂ + … + dₙ is even (Handshaking Lemma requirement).
- Erdős–Gallai inequalities: For each k = 1, 2, …, n:
∑i=1k di ≤ k(k−1) + ∑i=k+1n min(di, k)
The right-hand side counts the maximum possible edges: k(k-1) is the most edges within the first k vertices (a complete graph among them), and ∑ min(di, k) counts how many edges the remaining vertices can contribute to the first k vertices without exceeding their own degrees or k.
The Havel-Hakimi Algorithm
The Havel-Hakimi algorithm, independently proposed by Vašek Chvátal and others and formalized by Havel (1955) and Hakimi (1962), provides a constructive approach: it not only checks graphicality but also builds an actual graph realizing the sequence.
The algorithm proceeds iteratively:
- Sort the degree sequence in non-increasing order.
- If the first element is 0, the sequence [0, 0, …, 0] is trivially graphical (empty graph). Done.
- Take the first element d₁. Connect vertex 1 to the next d₁ vertices.
- Reduce the degrees of those d₁ vertices by 1. Remove vertex 1.
- If any degree becomes negative, the sequence is not graphical.
- Repeat with the reduced sequence.
The Havel-Hakimi theorem guarantees that a sequence is graphical if and only if the reduced sequence after each step remains graphical, providing a recursive correctness proof.
Special Graph Degree Sequences
| Graph Type | Degree Sequence Pattern | Example (n=5) |
|---|---|---|
| Complete graph Kₙ | All n−1 | [4,4,4,4,4] |
| Cycle Cₙ | All 2s | [2,2,2,2,2] |
| Path Pₙ | Two 1s, rest 2s | [2,2,2,1,1] |
| Star K₁,₄ | One (n-1), rest 1s | [4,1,1,1,1] |
| Empty graph | All 0s | [0,0,0,0,0] |
| Regular graph | All equal k | [3,3,3,3,3,3] |
Applications of Degree Sequences
Degree sequences and graphicality tests appear in many real-world contexts:
- Network design: Given connectivity requirements for each node in a computer network, verify whether a valid network topology exists before hardware procurement.
- Molecular chemistry: The valence sequence of atoms determines possible molecular structures. A degree sequence corresponds to a valid molecule if and only if it is graphical, with additional chemical constraints.
- Social network analysis: Degree sequences model the distribution of connections in social networks. The small-world property often corresponds to specific graphical sequences with power-law characteristics.
- Bioinformatics: Protein interaction networks are analyzed through their degree sequences to detect anomalies and structural motifs.
- Combinatorics and extremal graph theory: Degree sequences anchor proofs of the existence of graphs with specific properties, including Ramsey theory results.
The Handshaking Lemma
The requirement that the degree sum be even is a direct consequence of the Handshaking Lemma: in any graph, the sum of all vertex degrees equals twice the number of edges (∑ deg(v) = 2|E|). This is because each edge contributes exactly 1 to the degree of each of its two endpoints. Consequently, the total degree sum must always be even, regardless of the graph's structure.