On the Reconstruction of 3-Uniform Hypergraphs from Degree Sequences of Span-Two

A nonnegative integer sequence is k-graphic if it is the degree sequence of a k-uniform simple hypergraph. The problem of deciding whether a given sequence π\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\pi $$\end{document} is 3-graphic has recently been proved to be NP-complete, after years of studies. Thus, it acquires primary relevance to detect classes of degree sequences whose graphicality can be tested in polynomial time in order to restrict the NP-hard core of the problem and design algorithms that can also be useful in different research areas. Several necessary and few sufficient conditions for π\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\pi $$\end{document} to be k-graphic, with k≥3\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$k\ge 3$$\end{document}, appear in the literature. Frosini et al. defined a polynomial time algorithm to reconstruct k-uniform hypergraphs having regular or almost regular degree sequences. Our study fits in this research line providing a combinatorial characterization of span-two sequences, i.e., sequences of the form π=(d,…,d,d-1,…,d-1,d-2,…,d-2)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\pi =(d,\ldots ,d,d-1,\ldots ,d-1,d-2,\ldots ,d-2)$$\end{document}, d≥2\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$d\ge 2$$\end{document}, which are degree sequences of some 3-uniform hypergraphs. Then, we define a polynomial time algorithm to reconstruct one of the related 3-uniform hypergraphs. Our results are likely to be easily generalized to k≥4\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$k \ge 4$$\end{document} and to other families of degree sequences having simple characterization, such as gap-free sequences.


Introduction
The degree sequence of a simple hypergraph is the list of its vertex degrees, usually arranged in non-increasing order. Given a nonnegative integer sequence π , the possibility of an efficient test for the existence of a simple hypergraph having degree sequence π remained unsolved for many years (see [1,4]). The degree sequence of a simple k-uniform hypergraph, say k-hypergraph, is said k-graphic, briefly k-sequence. Note that very little can be said about the uniqueness of the hypergraphs related to a degree sequence. In general, 2-sequences do not guarantee such uniqueness but in particular cases. Similarly, the same happens when the degree sequence is regular and almost regular.
The characterization of 2-sequences, i.e., the degree sequences of graphs, was solved by Erdős-Gallai in [7].
Relying on this result, several polynomial time algorithms have been defined to reconstruct the incidence matrix of one of the related graphs.
Assuming that P = NP, if k ≥ 3 an effective characterization does not exist even for the simplest case of 3-hypergraphs (see Deza et al. [6]).
However, necessary and sufficient conditions to detect the k-graphicality of an integer sequence π , with k ≥ 3, can be found in the literature, and they mainly rely on a result by Dewdney [5], based on a recursive decomposition of π . This characterization does not yield to an efficient algorithm and the question to determine a more practical characterization remained open. Basing on these results, in [2] the authors presented some general sufficient and testable conditions for k-graphicality when k ≥ 3. Brlek et al. in [4] defined a P-time reconstruction algorithm for the case of regular k-sequences. Later this result was extended to almost regular k-sequences (see [9]). A remarkable fact is that in both cases, all the k-sequences satisfy a simple necessary and sufficient condition. In our study, we investigate spantwo 3-sequences, i.e., degree sequences where the difference between their maximal and minimal entry is two, and we prove that these conditions are not sufficient any more.
This result allows to further restrict the hard core of the reconstruction problem on 3-uniform hypergraphs, and it moves in the direction of inspecting the potential of reconstruction heuristics that base on the maximum span among the nodes' degrees. We recall that, similarly to what happens to graphs, techniques for random hypergraphs generation, as well as the small world or the scale free properties tend to condense the degree values inside small integers' intervals.
Here, we provide evidence that moving from regular or almost regular sequences to span-two sequences is critical for the reconstruction of one of the related 3-hypergraphs.
Then, we solve the related reconstruction problem, i.e., we define a polynomial time algorithm to reconstruct the incidence matrix of a 3-hypergraph having a span-two 3sequence.
To this aim, we first identify a family of span-two 3sequences that we call basic sequences and that are used as primitive sub-matrices, say blocks, of the incidence matrix of the hypergraph. At one time, we point out few span-two sequences that are not 3-sequences. Finally, we show how to successfully complete the reconstruction of the hypergraph by vertically concatenating a basic sequence block and some blocks obtained by using as edges the cyclic shifts of 3-dense Lyndon words.
So, in the next section, we give the definitions useful for our study, we point out some relevant previous results and we introduce the reconstruction problem. Section 3 is devoted to the consistency problem concerning 3-hypergraphs having span-two 3-sequences. Then, in Sect. 4, the combinatorial characterization of basic sequences is given, and then reconstruction problem is solved, via a polynomial time algorithm. Then, we show the characterization of span-two degree sequences of a 3-uniform hypergraph. We conclude the article pointing out some open problems concerning the characterization of other families of degree sequences, in Sect. 5.
An advantage of our approach based on combinatorics on words is that all the results are likely to be easily extendable to k ≥ 4 and to other families of degree sequences having simple characterization, such as gap-free sequences.
This paper is an extended version of [8] presented at the International Conference on Discrete Geometry and Mathematical Morphology (DGMM), May 24-27, 2021, Uppsala (Sweden). The structure is the same, and the same tools are used. The novelty is that in the conference paper only step-two sequences, i.e., of the form (d k , (d − 2) m ) (k, m > 0) have been studied. Now, we extend step-two sequences to span-two sequences. The problem for the span-two sequences is technically more challenging than for span-two sequences, and we find this being a sufficient additional contribution to be published in a journal paper.

Definitions, Previous Results and Introduction of the Problem
is a finite set of n vertices, and E is the set of hyperedges, i.e., a collection of subsets of V , {e 1 , e 2 , . . . , e m } where each e i is non-empty (see [1]). A hypergraph is simple if it is loopless, i.e., there are no singletons among its hyperedges, and without parallel hyperedges, i.e., e e for any pair e, e ∈ E. Moreover, a hypergraph is said to be k-uniform, briefly k-hypergraph, if each hyperedge has cardinality k. The degree of a vertex v ∈ V is the number of hyperedges e ∈ E such that v ∈ e. The degree sequence of H is the list of its vertex degrees, usually written in non-increasing order, as π = (d 1 , d 2 , . . . , d n ), d 1 ≥ d 2 ≥ · · · ≥ d n . Let us denote by σ (π) the sum of the elements of π . When H is k−uniform, the sequence π is called k-graphic. Notice that the case k = 2 corresponds to graphs.
In this context, we consider the problem of characterizing 3-sequences and reconstruct one of the related 3-hypergraphs. We recall that each hypergraph H = (V , E), where |V | = n, |E| = m, can be represented through its incidence matrix, i.e., the m × n binary matrix A = (a i, j ), with i = 1 . . . m, j = 1 . . . n, such that a i, j = 1 if and only if the vertex v j belongs to the hyperedge e i . Thus, m i=1 = a i j = d j is the degree of the vertex v j , and when H is k-uniform we have n j=1 a i j = k for each hyperedge e i . So, our study focuses on the characterization of a subset of 3-sequences and the reconstruction of the incidence matrix of their related 3-hypergraphs.
We underline that if a matrix A is the incidence matrix of a hypergraph H , then its rows' and columns' sums correspond to the sequence of the cardinalities of the elements of E and to the degree sequence π , respectively.
Frosini et al. in [9] give a necessary and sufficient condition to test d-regular or almost d-regular k-sequences, i.e., the Moreover, given a regular or almost regular integer sequence satisfying the conditions of Theorem 1, they define a P-time algorithm to compute one of the associated khypergraphs by reconstructing its incidence matrix. Such algorithm relies on the notion of Lyndon words and necklaces of fixed density (that we recall hereafter) and uses an already known algorithm for their efficient generation.
A sequence π is said to have span h if d 1 − d n = h. With h = 0 we have regular sequence, while with h = 1 we have quasi-regular sequences. Moreover, π is said to be gap-free In this paper we investigate 3-sequences having span two (or span-two sequences), i.e., sequences of the form π = (d g , (d −1) h , (d −2) p ), where the exponential notation x i indicates the entry x is repeated i times. Then, we show that their characterization and the reconstruction of (one of) the related 3-hypergraphs cannot be obtained as a simple generalization of the results in [8,9].

Necklaces and Lyndon Words
Here, we recall a couple of standard notions of combinatorics of words that will be useful in the sequel. Indeed, we consider each row of a matrix as a binary word, and we group them into equivalence classes according to their cyclic shifts. We consider each row of a binary matrix as a binary finite word w ∈ {0, 1} * , w = w 1 . . . w n , whose length n is the number of columns of the matrix. Given i ∈ {0, . . . , n − 1} the ith cyclic shift of w is the word s i (w) = w i+1 . . . w n w 1 . . . w i , so that s 0 (w) = w. We note that applying a cyclic shift to w, we obtain a different word, unless the cases w = (1) n or w = (0) n , of the same length, and having the same number of 1-elements inside. Note that the words repeat after at most n shifts.
Following the notation in [11], the binary necklace (briefly necklace) of a binary word w is the equivalence class of all its cyclic shifts. We identify a necklace with the lexicographically least representative w in its equivalence class, denoted by [w]. The set of all (the words representative of) the necklaces with length n is denoted N (n). For example, N (4) = {0000, 0001, 0011, 0101, 0111, 1111}. An important class of necklaces are those that are aperiodic. An aperiodic necklace (i.e., one with period greater than or equal to n) is called a Lyndon word. If w is a Lyndon word, then it cannot be expressed as a power of one if its proper sub-words. Let L(n) denote the set of all Lyndon words with length n. For example, L(4) = {0001, 0011, 0111}. It holds the property that a word w of length n is a Lyndon word if and only if its necklace has n different elements. We denote fixeddensity necklaces and Lyndon words in a similar manner by adding the parameter h to represent the density of the word. Thus, the set of necklaces with density h is represented by  N (n, h), and the set of Lyndon words with density h is rep- Fig. 1 The matrix M(0111). Note that all its columns' and rows' sums equal 3. Since all its rows are different, then it is the incidence matrix of a 3-hypergraph resented by L(n, h). For example, N (4, 2) = {0011, 0101}, and L(4, 2) = {0011}.
It is known from Gilbert et al. [10] that the number of fixed density necklaces and Lyndon words is respectively, where the symbols φ and μ refer to Euler and Möbius functions. We will be interested in Lyndon words with density 3. In particular, we enlighten the connection between these objects and our problem, denoting by M(w) the matrix obtained by vertically concatenate all the different cyclic shifts of a word w. For example, M(0111) is the matrix depicted in Fig. 1.
Since the cardinality of [w] (i.e., the number of rows of M(w)), where w is a word of length n and density h, is a divisor of n, the following trivially holds:

The Characterization of 3-Sequences Having Span-Two
Given a generic 3-sequence π = (d 1 , . . . , d n ), we define the complement of π , denoted by π , the vector π A direct consequence of the definition of complement of a degree sequence is the following proposition:

Proposition 2 A degree sequence π is 3-graphic if and only if its complement is 3-graphic.
Proof Since π is 3-graphic, then there exists an incidence matrix M associated with π . Given the incidence matrix M n associated with the regular vector (d max , d max , . . . , d max ) of length n, the reconstructed 3-hypergraph is regular and it is trivially unique since it contains all the possible different rows. We remove all the rows of the submatrix M, and we obtain the incidence matrix of a 3-hypergraph associated with the mirror image of the vector π (i.e., the vector π read from right to left). By flipping horizontally the columns of the obtained matrix, we find the incidence matrix of a 3hypergraph having π as degree sequence. Hence, π is 3graphic.
In this paper, we characterize the 3-sequences having span two, i.e., of the form Let us denote by P, the set of all span-two sequences whose maximum value satisfies the three conditions of Theorem 1. Clearly, span-two 3-sequences are included in P.
We consider the reconstruction problem for span-two sequences of P of length n, starting with the smallest value of n. There are no 3-hypergraphs having span-two degree sequences of length n ≤ 4, indeed an easy exhaustive check reveals it. Concerning span-two sequences in P, whose length is n ≥ 5, we prove the following result: Proposition 3 Every span-two sequence of the form: is not a 3-graphic sequence.
Let us recall the following (standard) partial order on integer sequences π and π having the same length n: we say that π π if and only if for each 1 ≤ i ≤ n, it holds π(i) ≤ π (i).
We underline that the following theorem extends Proposition 2 of [8].

Theorem 2 Each basic sequence is 3-graphic and it can be reconstructed using the shifts of three Lyndon words at most.
Proof We obtain the result by defining, for each type of basic sequence π , a class of 3-hypergraphs satisfying it. We consider separately the cases of the basic sequences: Let us study the 4 cases separately.
1. Let us define the following algorithm: We proceed in proving, Property 1 Let π = (2 g , 1 h , 0 p ), with g > 0, h, p > 0, and σ (π) ≡ 3 0 (the sum of the elements of π being a multiple of three). The run of CompBasic(π ) returns the incidence matrix M of a 3-hypergraph having degree sequence π .

Proof
We start by observing that on input π = (2 g , 1 h , 0 p ), at each run i of the for-loop, with i > 1, the sequence π M (2 : n) is weakly decreasing. This statement can be proved by induction: Step: by inductive hypothesis we have that the sequence π M is weakly decreasing up to the ith iteration of the for-loop. Iteration i + 1 acts on the following possible configurations (position i + 1 of π M is underlined): no updates are produced on M and π M maintains the weakly decreasing property; , that, according to the upper bound imposed by π , can be accepted, updating the matrix M and still preserving the weakly decreasing property. Note that, if M is not accepted, then π(i + 2) = x, and so π(i + 1) = π M (i + 1) + 1. Consequently, i + 1 is a position where π and π M differs; , that, according to the upper bound imposed by π , can be accepted, updating the matrix M and still preserving the weakly decreasing property.
Finally, we observe that, at the end of the for-loop, π M and π does not differ on three consecutive elements i, i + 1, i + 2: if so, the ith iteration of the for-loop would have filled the gap.
As a consequence of the two above properties, it holds that at the end of the for-loop π M and π may differ on the positions {1, g, n − 1, n}. Since, by construction, the number of positions where they can differ is a multiple of three, then it can be zero or three only. So, the final row π \π M added to M is either void or has three elements 1, so the output of CompBasic(π ) is the incidence matrix of a 3-hypergraph as desired.
An application of Algorithm 1 for the reconstruction of sequences of type (2 g , 1 h , 0 p ) is shown in Fig. 2: Again, we proceed in proving The run of CompBasic2(π ) returns the incidence matrix M of a 3-hypergraph having degree sequence π .
Proof Also in this case, on input π = (3 g , 2 h , 1 p ), at each run i of the for-loop, with i > 1, the sequence π M (2 : n − 2) is weakly decreasing. This statement can be proved by induction: Base: when i = 2, it holds either π M = (2, 1 5 , 0 n−6 ) or π M = (2, 2, 1 4 , 0 n−6 ) or π M = (2, 3, 2, 1, 0 n−4 ); Step: by inductive hypothesis we have that the sequence π M is weakly decreasing up to the ith iteration of the for-loop. Iteration i + 1 acts on the following possible configurations (position i + 1 of π M is underlined): To reach the hypothesis, we observe that, at the end of the for-loop, π M and π does not differ on three consecutive As a consequence of the two above properties, it holds that at the end of the for-loop π M and π may differ either in the positions {1, g + h, n − 2, n − 1} or in the positions {1, g + h, n − 3, n − 2}, according to the value g = 1 or g > 1, respectively. Since, by construction, the number of positions where they can differ is a multiple of three, then it can be zero or three only. So, the final row π \π M added to M is either void or has three elements 1, so the output of CompBasic(π ) is the incidence matrix of a 3-hypergraph as desired.
Some runs of CompBasic2 for the reconstruction of sequences of type (3 g , 2 h , 1 p ), with different values of the parameters g, h and p, are shown in Fig. 3: 3. Now, we consider the class of sequences π = (4 g , 3 h , 2 p ), with g > 0, h ≥ 0, p > 0 and such that n = g + h + p ≥ 6, and |g− p| in π 1 , π 2 , and π 3 , respectively. The vector π is updated accordingly.
Such a row deletion is always possible when the lengths of π 1 and π 2 are greater than six, and the length of π 3 is greater than seven, as witnessed by Fig. 4.
Then, Special returns a matrix A satisfying the updated π and involving two Lyndon words different from (1 3 , 0 n ). All the possible cases are shown in Fig. 4. Finally, the matrix A is vertically concatenated with M to obtain the final output of CompBasic3(π ).
Proof Since the use of the shifts of w = (1 3 , 0 n−3 ) in M prevents each column sum to overcame 3, from Proposition 2, Fig. 4 Three vectors π , i.e., {(4, 2 7 ), (4, 3 2 , 2 4 ), (4 4 , 2 4 )} that originate the cases π 1 , π 2 , and π 3 . The procedure Special acts on them first deleting from the correspondent matrices M i , i = 1, . . . , 3 the rows whose elements are underlined. Then, the updated vectors π 1 , π 2 , and π 3 are obtained and reconstructed by the matrices A 1 , A 2 , and A 3 , respectively. The upper and the lower parts of the matrices have to be vertically arranged to obtain the incidence matrices of three 3hypergraphs. Each solution contains three Lyndon words at most we obtain that the for loop starting in line 5 produces a weakly decreasing sub-sequence π M (3 : n). Furthermore, since no elements 1 are present in π , then π M (g + 1 : n − 1) = π (recall, yet from Proposition 2 that one of the three positions where π M and π may differ is where the sequence of elements 2 in π ends, changing into the sequence of elements 1. No differences are present when the sequence of elements 3 changes into that of elements 2).
So, if π turns out to be π 1 , π 2 or π 3 , then Special (M) successfully completes the reconstruction of a matrix M that is the incidence matrix of a 3-hypergraph and it uses three Lyndon words at most. Otherwise π \π M is a sequence in C, so RecMin creates a new matrix A by adding (line 4 of RecMin) a first row that allows, by construction, π \π A to be a zero vector, but for a single sequence of elements 1 of length greater than three. Then, RecMin completes the reconstruction of A by adding rows that are shifts of the same Lyndon word (lines 6−8 in RecMin). So, also in this case, the final output of RecBasic3 (π ), i.e., the vertical concatenation of M and A, produces the incidence matrix of a 3-hypergraph by using three Lyndon words at most. 4. The following cases end our analysis: (5 3 , 3 p ), (5, 4, 3 p ) with p ≥ 3, p ≥ 2. All the basic sequences have been considered, and for each of them, we have provided a reconstruction strategy that involves three Lyndon words at most, so reaching the thesis.
The procedure that reconstructs the incidence matrix associated with a basic element π and that relies on the proof of Theorem 2 is denoted by RecBasic(π ).

Reconstructing a 3-Hypergraph from an Element of P
We recall that Sawada et al. [11] presented a constant amortized time (CAT) algorithm FastFixedContent for the exhaustive generation of necklaces N (n, h) of fixed length and density. Moreover, Sawada [12] shows that a slight modification of it, here denoted GenLyndon(n, h), can be used for the CAT generation of the Lyndon words L(n, h). This latter constructs a generating tree of the words, and since the tree has height h, the computational cost of generating k words of L(n, h) is O(k · h · n). Let us put together the previous algorithms and define the procedure RecP(π ) to reconstruct the 3-hypergraph of a span-two degree sequence π , if it exists. The pseudo-code of the procedure is provided: Output: An incidence matrix M of a 3−hypergraph whose degree sequence is π . We solve RecP(π '), where π is the minimum between π and π in the lexicographical order.
Step 2: While D is not a basic sequence, do D = D − (3 n ) and f = f + 1.
Step Theorem 3 Any sequence π ∈ P\N can be reconstructed by RecP.
Proof The proof consists in showing that, for any π ∈ P\N of length n > 4 there is a sufficient number of Lyndon words required by RecP (π ).
We need to consider the cases n = 5 and n = 6 separately. Concerning these two cases, we know from Corollary 1 that all basic sequences can be reconstructed using at most two Lyndon words, so we will just need to prove that all the sequences π ∈ P\N which are not basic can be reconstructed.
(1) For n = 5, we have d max = 6 and L(5, 3) = 2. There are only four sequences in P\N : π 1 = (3 2 , 1 3 ) and its complement π 1 = (5 3 , 3 2 ), and π 2 = (4, 2 4 ) and its complement π 2 = (4 4 , 2). π 1 and π 2 are basic sequences, and they can be reconstructed with two Lyndon words, so also their complements can be reconstructed. (2) For n = 6, we have d max = 10 and L(6, 3) = 3. Any such that π ≤ π has d ≤ 7. The cases d = 2, 3, and 4 concerns basic sequences, otherwise it holds d ≤ 7, so π − (3 n ) is a basic sequence, then three Lyndon words are sufficient for the reconstruction. Now, let π ∈ P be a generic sequence of length n > 6, such that π is less than π in the lexicographic order, and denote by l(B) the number of words needed to reconstruct the basic sequence B = B(π ) associated with π . The number of Lyndon words of length n and density 3 is: We show that the inequality of Step 3 of RecP is always satisfied on input π , i.e., there are enough Lyndon words to reconstruct 3-hypergraph related to π . Precisely, a simple computation shows that the following inequality holds: where: From the previous inequality we get: Fig. 6 The reconstruction of the sequences of length 5 -if n is a multiple of 3: that is always satisfied starting from d B = 4 and n = 7 on. -if n is not a multiple of 3, we get: Again the inequality is always satisfied starting from d B = 4 and n = 9 on.

Remark 1
Observe that Failure occurs if the number of Lyndon words of L(n, 3) is not sufficient to reconstruct the matrix, and the above statement prevents this to occur. The next theorem is an immediate consequence of Theorem 3 and Remark 2.
Theorem 4 A sequence π ∈ P\N is 3-graphic if and only if π can be reconstructed using the Algorithm RecP.
The validity of RecP(π ) is a simple consequence of Theorem 4. Clearly, the obtained matrix is the incidence matrix of a 3-hypergraph having degree sequence π , indeed by construction, all the rows are distinct. Moreover, the algorithm always terminates since, at each iteration, it adds as many rows as possible to the final solution. Concerning the complexity analysis, we need to generate O(m) different Lyndon words and shifts each of them O(n) times. Thus, since the algorithm GenLyndon(n, 3) requires steps to generate f words of L(n, 3), the whole process takes polynomial time.
As a consequence of Theorem 4 we have a simple characterization of the span-two sequences which are 3-graphic.

Two Examples of Application of RecP( )
We illustrate the action of RecP with two examples, the second one involving a gap-free sequence.

From
Step 4, removing 1 , 2 , 3 from the set of all available Lyndon words, we get 4 and 5 .

In
Step 5, to reconstruct (3 7 ), we use, for example, all the cyclic shifts of 5 . Thus, vertically concatenating the obtained matrices, we get the solution depicted in Fig. 7 (right).
-In Step 5, to reconstruct (3 7 ), we use, for example, all the cyclic shifts of 5 . Thus, vertically arrange the obtained matrices, we get the matrix depicted in Fig. 8 (right).

Future Developments and Conclusions
In this paper we defined a polynomial time algorithm that reconstructs the incidence matrix of a 3-uniform hypergraph, when such a hypergraph exists, from its degree sequence in case it is a span-two sequence. The novelty of our approach concerns the use of notions from combinatorics on words, in particular Lyndon words, to enhance the reconstruction strategy. The main result concerns the characterization of span-two sequences which are 3-graphic, and states that actually, very few sequences among those satisfying the conditions (1), (2), and (3) of Theorem 1 are not 3-graphic, i.e., those belonging to the set N . Degree sequences having span h > 2: we believe that an analogous rather simple characterization of sequences which are not 3-graphic cannot be obtained also for generic span-h sequences, h > 2. For instance, with h = 3, the set N 3 of span-three sequences satisfying the conditions 1., 2., and 3. of Theorem 1 that are not 3-graphic contains: and their complements. Again, we stress that few nonzero elements of the sequences prevent them from being 3-sequences. Therefore, if the number of nonzero elements overcomes 6, there exists only 10 sequences in N 3 .
Unfortunately, it seems that this characterization does not immediately lead to an algorithm for the reconstruction of 3-sequences having span h, when h > 2. This is due to the fact that the characterization of basic sequences for h > 2 is quite hard, and so it is the formulation of an analogous of Theorem 2. To better realize this statement, we investigate the case h = 3. An exhaustive search computes the following the span-3 basic sequences whose sums are multiple of three: (3 p , 2 q , 1 r , 0 s ): having length greater than five, and p, s ≥ 1, q, r ≥ 0; (4 p , 3 q , 2 r , 1 s ) and (5 p , 4 q , 3 r , 2 s ): with p, s ≥ 1, q, r ≥ 0 and length greater than five; (6, 6, 3 q ): with q ≥ 4; (6, 6, 6, 3 q ): with q ≥ 3; (6, 5, 4, 3 s ) and (6, 6, 5, 4, 3 s ): with s > 1. (7, 4 3q+2 ): with q ≥ 1; excluding the sequences in N 3 . If we want to use a reconstruction strategy similar to that in RecP, it is necessary to provide a statement analogous to that of Theorem 2, i.e., we have to prove that any basic sequence can be reconstructed using a number of Lyndon words bounded by a constant.
This task turns out to be extremely hard when the relations between the run lengths of the entries in the sequences assume the form of a linear Diophantine equation with more than two variables, as for the gap-free sequences. As an example, concerning the sequences (4 p , 3 q , 2 r , 1 s ), the coefficients p, s ≥ 1, r ≥ 0 have to satisfy the equation 4 p+2r +s = 3z, whose solutions lie on 3D hyper-planes.
It is worth mentioning that, in the specific case of gap-free sequences, some different approaches (see [2,3,9]) may help the reconstruction in the case of span h > 2. Again, these ad hoc strategies do not admit a generalization as the degree sequences span increases, underlining the non-polynomiality of the general characterization problem. Strategy failure. The strategy used in the definition of RecP roughly consists in removing blocks of (3 n ) from the sequence π in input, until we reach a basic sequence, i.e., a sequence from which we cannot remove any other block. Then, we prove that this basic sequence can be reconstructed using a minimal number of Lyndon words and that the overall number of Lyndon words which are needed is less than or equal to L(n, 3). We would like to provide an example of the failure of this strategy.
The sequence is 3-graphic, indeed one possible 3 -hypergraph solution has the incidence matrix in Fig. 9 (observe that it contains all the 7 Lyndon words). A generalization of our algorithm would work as follows: (1) The complement of π is (15, 14, 13, 13, 12, 10, 7) so we reconstruct π ; (2) We use two Lyndon words to remove two blocks (3 7 ) obtaining π = (7, 5, 3, 2, 2, 1, 1, 0), which is a basic sequence; (3) The sequence π can only be reconstructed using six Lyndon words, as follows: So, the application of our algorithm would require eight Lyndon words, so giving failure as output, whilst π can be actually reconstructed.
k-uniform hypergraphs. The algorithm RecP we have defined is tuned for 3-uniform hypergraphs. A possible direction for further research follows its generalization to obtain a polynomial algorithm for the reconstruction of generic k-uniform hypergraphs having a step-two degree sequence. We recall that the identification of the degree sequences of k-uniform hypergraphs, k ≥ 3, is an NP-hard problem. Therefore, the proposed studies aim at limiting its NP-hard core, being fully aware of the impossibility of a good general characterization. However, finding a compact nice looking characterization would be of great interest in order to design algorithms for real-life applications.
Funding Open access funding provided by Universitá degli Studi di Siena within the CRUI-CARE Agreement. Fig. 9 The reconstruction of the incidence matrices of two 3hypergraphs having degree sequences π = (13, 11,9,8,8,7,6) and π (7, 5, 3, 2, 2, 1, 1, 0) Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecomm ons.org/licenses/by/4.0/.
Publisher's Note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.