TITLE: What condition need to be imposed on Havel-Hakimi theorem to check for connected graph?
QUESTION [22 upvotes]: Havel-Hakimi Theorem:
  A sequence s: $d_1, d_2, \ldots, d_n$ of non-negative integers
      with $\Delta = d_1 \geq d_2 \geq \ldots \geq d_n$ and $\Delta \geq 1$, is graphical if and only if the 
      sequence
          $$s_1: d_2 - 1, d_3 - 1, \ldots d_{\Delta + 1} - 1, d_{\Delta + 2}, \ldots, d_n$$
          is graphical.
  Havel-Hakimi theorem provides an algorithm for determining whether a given finite sequence of non-negative
      integers is graphical. If, upon repeated application of Theorem 1, we arrive at a sequence, where every term of
      which 0, then the original sequence is graphical. On the other hand, if we arrive a sequence containing a negative
      integer, then the given sequence is not graphical. 

I tried several sequences and realized, the sequence is not graphical if it fails Havel-Hakimi's theorem. However, it doesn't always work for connected graph. For instance, the sequence:
$$ 3, 3, 1, 1, 1, 1, 1, 1$$
can be processed by Havel-Hakimi's algorithm as follows:
3, 3, 1, 1, 1, 1, 1, 1
2, 0, 0, 1, 1, 1, 1
2, 1, 1, 1, 1, 0, 0
0, 0, 1, 1, 0, 0
1, 1, 0, 0, 0, 0
0, 0, 0, 0, 0

But it can't be graphed as a connected component. On the other hand, the sequence:
$$5, 4, 3, 2, 2, 2, 2, 2$$
also satisfies the Havel-Hakimi's algorithm, but can be graphed as follows:

So my question is, what other conditions need to be added so that Havel-Hakimi's algorithm work for connected graph? Thank you.

REPLY [2 votes]: @Martin Sleziak references a paper that generates a connected realization of a degree sequence like so: 1) generate any realization using the standard Havel–Hakimi procedure 2) rewire the edges in a way that preserves the degree sequence, but makes the graph connected.
This method works, but it is rather complicated to implement.
I found a much simpler algorithm to generate a connected realization directly, and detailed it in a blog post.  I will summarize the method here.  For the proofs, see the blog post.
The Havel–Hakimi algorithm is often presented like this:

Take a node with the highest (remaining) degree. Let us denote this degree by $d$.
Connect it to $d$ other nodes with the highest (remaining) degrees.
Repeat from step 1 until all degrees are used up.

However, it is not in fact necessary to select the highest degree node in step 1. Any node can be chosen, and the theorem still stands (i.e. the algorithm builds a simple graph iff the starting sequence was graphical).  In your formulation, we can work with a degree sequence $d_1, d_2 \ge \dots \ge d_n$, without the requirement that $d_1 \ge d_2$.  I believe that the usual presentation chooses the highest degree node only because the algorithm will finish in fewer steps this way.
Theorem: If in step 1. we always choose the node with the smallest remaining degree, and if the starting degree sequence was graphical and potentially connected, then the algorithm will build a connected graph.
For the proof, see the blog post or preprint. For an implementation, see IGRealizeDegreeSequence in IGraph/M or igraph_realize_degree_sequence in igraph.
Thus, to summarize:

What condition need to be imposed on Havel-Hakimi theorem to check for connected graph?

You simply need to choose the smallest degree node in each step.
However, if you are not actually building a graph, only checking for graphicality, then you are better off with the Erdős-Gallai theorem. See this paper by Z. Király for a fast and practical implementation.
Whether the degree sequence is potentially connected can be verified by checking if $\sum_{i=1}^n d_i \ge 2(n-1)$, as Martin noted.