# Havel–Hakimi algorithm

Jump to navigation Jump to search

The Havel–Hakimi algorithm is an algorithm in graph theory solving the graph realization problem. That is, it answers the following question: Given a finite list of nonnegative integers, is there a simple graph such that its degree sequence is exactly this list. Here, the "degree sequence" is a list of numbers that for each vertex of the graph states how many neighbors it has. For a positive answer the list of integers is called graphic. The algorithm constructs a special solution if one exists or proves that one cannot find a positive answer. This construction is based on a recursive algorithm. The algorithm was published by Havel (1955), and later by Hakimi (1962).

## The algorithm

The algorithm is based on the following theorem.

Let ${\displaystyle S=(d_{1},\dots ,d_{n})}$ be a finite list of nonnegative integers that is nonincreasing. List ${\displaystyle S}$ is graphic if and only if the finite list ${\displaystyle S'=(d_{2}-1,d_{3}-1,\dots ,d_{d_{1}+1}-1,d_{d_{1}+2},\dots ,d_{n})}$ has nonnegative integers and is graphic.

If the given list ${\displaystyle S}$ is graphic then the theorem will be applied at most ${\displaystyle n-1}$ times setting in each further step ${\displaystyle S:=S'}$. Note that it can be necessary to sort this list again. This process ends when the whole list ${\displaystyle S'}$ consists of zeros. In each step of the algorithm one constructs the edges of a graph with vertices ${\displaystyle v_{1},\cdots ,v_{n}}$, i.e. if it is possible to reduce the list ${\displaystyle S}$ to ${\displaystyle S'}$, then we add edges ${\displaystyle \{v_{1},v_{2}\},\{v_{1},v_{3}\},\cdots ,\{v_{1},v_{d_{1}+1}\}}$. When the list ${\displaystyle S}$ cannot be reduced to a list ${\displaystyle S'}$ of nonnegative integers in any step of this approach, the theorem proves that the list ${\displaystyle S}$ from the beginning is not graphic.

## References

• Havel, Václav (1955), "A remark on the existence of finite graphs", Časopis pro pěstování matematiky (in Czech), 80: 477–480
• Hakimi, S. L. (1962), "On realizability of a set of integers as degrees of the vertices of a linear graph. I", Journal of the Society for Industrial and Applied Mathematics, 10: 496–506, MR 0148049.