learngraphtheory.org

Guest User

Using app without sign in

Cover of the book Graph Theory Through Problems

Practice book

Graph Theory Through Problems

300 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.

Available inKindlePaperback

13 chapters

Also by the authorGraph Algorithms for Coding Interviews100 solved interview problems with visual explanations and Python solutions.View on Amazon
Algorithm Selection

Select an algorithm and generate steps to begin visualization

Havel-Hakimi Calculator

Which degree sequences belong to a graph?

algorithms.havelhakimi.description

Time: algorithms.havelhakimi.timeComplexity
Space: algorithms.havelhakimi.spaceComplexity
Use Case: algorithms.havelhakimi.useCase
Showing the example graph for this algorithm.
Try:

Builds one vertex per number, then run the algorithm. With your own drawing on the canvas instead, the run uses its degrees.

Algorithm Execution

Select an algorithm and generate steps to begin visualization

About algorithms.havelhakimi.name

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.

How it works

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.

Applications

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

Interactive Controls

Zoom Controls

44%
Nodes: 7
Edges: 0