In graph theory, the degree of a vertex is the number of connections it has. For example, the vertices of the below graph have degrees (3, 2, 2, 1).
It is easy to determine the degrees of a graph’s vertices (i.e. its degree sequence), but what about the reverse problem? Given a list of integers, how can we construct a simple graph that has them as its vertex degrees? Does such a graph even exist? This blog post deals with a special case of this problem: constructing connected simple graphs with a given degree sequence using a simple and straightforward algorithm.
If you are already familiar with this topic, feel free to skip ahead to the algorithm for building connected graphs.
Building a graph that realizes a certain degree sequence is usually done using the well-known Havel–Hakimi algorithm (HH). The algorithm can be understood most easily by imagining each vertex to have as many stubs as its degree. We then need to connect up all these stubs to form a graph.
For example, the degree sequence (3, 3, 2, 2, 1, 1) would be drawn like this:
The numbers show how many unconnected stubs each vertex has.
The HH algorithm proceeds by selecting an arbitrary vertex, and connecting up all of its stubs to the other vertices that have the most free stubs. This is repeated until no unconnected stubs are left. The procedure for the above degree sequence is illustrated below:
The vertex selected in each step is marked by the dotted circle. Some presentations of the HH algorithm, such as the one currently in Wikipedia, always select the vertex with the highest remaining degree. It is important to note that this is not necessary. Any vertex can be selected in each step, for as long as all of its stubs are connected up to the other vertices with the highest remaining degrees.
A degree sequence is said to be graphical if there exists a simple graph having it as its vertex degrees. The Havel–Hakimi theorem states that if the starting degree sequence is graphical, then the algorithm will succeed in connecting up all stubs without creating any self-loops.
A different formulation of the HH theorem is as follows:
Theorem: Let us order the degrees decreasingly with the exception of one vertex, and write the degree sequence as $d_1, \; d_2 \ge d_3 \ge \cdots \ge d_n$. This degree sequence is graphical if and only if $d_2 - 1, d_3 - 1, \ldots, d_{d_1 + 1} - 1, d_{d_1 + 2}, \ldots, d_n$ is also graphical.
In this view, a HH step takes a degree sequence, and reduces it to another, shorter one.
What if we are looking to build a connected graph with a given degree sequence? Not every degree sequence has a connected realization. Those that do are called potentially connected degree sequence.
The general Havel–Hakimi procedure does not always build connected graphs, even if the starting degree sequence was potentially connected. However, in each step of the algorithm, we have the freedom to select any vertex we like (and connect up all its stubs). It turns out that there is a special selection rule that guarantees that the result will be connected (provided that the starting degree sequence was potentially connected): always select the vertex with the smallest remaining degree. Let us refer to a HH step with this choice as a HH* step.
As a demonstration, let us produce an arbitrary potentially connected degree sequence:
In[]= degseq = VertexDegree@First@ConnectedGraphComponents@RandomGraph[{50, 50}]
Out[]= {2, 3, 5, 3, 2, 3, 4, 4, 3, 4, 2, 1, 5, 3, 2, 2, 2, 4, 2, 6, 3, 2, 2, \
1, 1, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1}
The usual largest-first implementation of the Havel–Hakimi algorithm typically produces disconnected graphs:
IGRealizeDegreeSequence[degseq, Method -> "LargestFirst"]
The default method of the IGRealizeDegreeSequence function (Method -> "SmallestFirst") guarantees a connected realization, if one exists.
IGRealizeDegreeSequence[degseq]
65 videos|120 docs|94 tests
|
|
Explore Courses for Civil Engineering (CE) exam
|