Guest User
Using app without sign in

Practice book
Graph Theory Through Problems300 Exercises with Hints, Worked Algorithms and Complete Solutions
By Mohammed Islam Hadjoudj
Learn graph theory by solving problems: 300 exercises, from routine checks to challenging proofs, each with a complete solution.
Also by the authorGraph Algorithms for Coding Interviews100 solved interview problems with visual explanations and Python solutions.View on AmazonSelect an algorithm and generate steps to begin visualization
Which degree sequences belong to a graph?
algorithms.havelhakimi.description
Builds one vertex per number, then run the algorithm. With your own drawing on the canvas instead, the run uses its degrees.
Select an algorithm and generate steps to begin visualization
The Havel-Hakimi algorithm decides whether a list of non-negative integers is the degree sequence of a simple graph, that is, a graph without loops or repeated edges. Such a list is called graphical. When the answer is yes, the algorithm also builds one graph with exactly those degrees, so it is a constructive proof rather than just a test.
Sort the degrees from largest to smallest. Take the vertex that needs the most neighbours, say d of them, and join it to the d vertices that need the most after it; each of those now needs one neighbour fewer. Remove the first vertex and repeat on the shorter list. If a vertex ever needs more neighbours than there are vertices that can still take an edge, the sequence is not graphical. A quick first check is the handshake lemma: the degrees of any graph add up to an even number. Havel (1955) and Hakimi (1962) proved that this greedy choice never fails when some graph exists.
Degree sequences describe networks when only the number of connections of each node is known, as in social, citation and chemical networks. Havel-Hakimi is used to generate test graphs with a prescribed degree distribution, to check network data for consistency, and in chemistry to ask which molecules a set of valences allows. In graph theory courses it comes right after the handshake lemma, next to the Erdős-Gallai theorem, which gives an equivalent test by inequalities.
Related algorithms: algorithms.prufercode.name, Eulerian Path (Undirected), Graph Coloring, Bipartite Check