Beyond Quasi-Adjoint Graphs: On Polynomial-Time Solvable Cases of the Hamiltonian Cycle and Path Problems
Abstract
The Hamiltonian cycle and path problems are fundamental in graph theory and useful in modelling real-life problems. Research in this area is directed toward designing better and better algorithms for general problems, but also toward defining new special cases for which exact polynomial-time algorithms exist. In the paper, such new classes of digraphs are proposed. The classes include, among others, quasi-adjoint graphs, which are a superclass of adjoints, directed line graphs, and graphs modelling a DNA sequencing problem.
1Introduction
The problem of searching for a Hamiltonian cycle or path is fundamental in graph theory and useful in modelling real-life problems. Electronic circuit design, job scheduling, and sequencing of DNA chains are just a few examples of such an application. In its decision version, the problem for directed or undirected graphs belongs to the NP-complete class of computationally hard problems. As the problem is regularly used, a lot of effort was put into designing more and more efficient algorithms (see, e.g., Jäger and Zhang, 2010; Björklund, 2014). On a more theoretical ground, research was directed toward proving polynomial-time solvability of Hamiltonicity for subsequent classes of graphs. There are many works related to the problem in undirected graphs (see surveys of Gould, 1991; Gross et al., 2013), its directed version was not so extensively studied (e.g., Favaron and Ordaz, 1986; Bang-Jensen and Gutin, 1999).
In the paper, superclasses of (directed) quasi-adjoint graphs are defined and proven to have a polynomial-time solution of the Hamiltonian cycle problem and, partially, the Hamiltonian path problem. Section 2 introduces necessary definitions and summarizes previous work, Section 3 contains theoretical results including algorithms, and a conclusion is given in Section 4.
2Theoretical Background
The following statements refer to directed graphs with, in general, loops and multiple arcs accepted. Throughout the paper, standard terminology from graph theory is used, see, e.g. Berge (1973). Let V stand for the set of vertices of a graph
The problem of searching for a Hamiltonian cycle or a Hamiltonian path is NP-hard even if all vertices in a digraph have their indegree and outdegree not exceeding 2 (Garey and Johnson, 1979). It is solvable in polynomial time when restricted to special subclasses of digraphs, for example, acyclic digraphs (Lawler, 1976), directed line graphs (Kasteleyn, 1963), or specific variations of dense digraphs (Bang-Jensen and Gutin, 2002).
A directed line graph is a 1-graph (a graph with no multiple arcs) where the following holds for all pairs
Adjoints have this useful property because of the vertex-arc relation with their graphs H, and a question arose whether this class could be widened. In 2008, its superclass of quasi-adjoint graphs was defined and a polynomial-time exact algorithm solving the Hamiltonian cycle problem was provided (Blazewicz et al., 2008). Digraph G is a quasi-adjoint graph if and only if, for all
3Superclasses of Quasi-Adjoint Graphs
Fig. 1
The considered class of polynomially solvable instances of the Hamiltonian cycle/path problem can be further extended. The simplest extension is to add to quasi-adjoint graphs their counterparts with the adjacency matrix transposed. Obviously, digraph G has a Hamiltonian cycle/path if and only if its transposed counterpart
Proposition 1.
Proof.
According to the definition, every two vertices of an adjoint have their sets of successors either identical or disjoint. Consequently, if two vertices have a common predecessor, they must have the same sets of predecessors, because all the predecessors point to the same subset of vertices. □
Lemma 1.
Proof.
Figure 1 presents an example of a graph, which becomes the quasi-adjoint graph after the transposition of its adjacency matrix. □
The following extension of the quasi-adjoint graphs takes into account the above property. Let
(3.1)
(3.2)
Theorem 1.
(i)
Proof.
From the definition, for each pair of vertices of a quasi-adjoint graph, their sets of successors are either disjoint or one of them is a subset of the other. If they are disjoint, the left part of the clause defining elements of
Fig. 2
The same we have for the clause for
The joint class
Theorem 2.
The Hamiltonian cycle problem in graphs belonging to
Proof.
The algorithm solving the problem consists of two stages. Firstly, graph
The reduction is made by removal of arcs where no arc having the possibility of composing any Hamiltonian cycle is removed. For
If
Finally, all the marked arcs are removed from G. Analogous operations are performed for
If graph G has m significantly greater than
Fig. 3
As we see, the algorithms for recognizing graphs from
Precisely, the reduction from the proof of Theorem 2 in the case of a graph outside
Algorithm 1
Theorem 3.
Algorithm 1 works in
Proof.
The time complexity immediately follows from the pseudocode. The correctness, i.e. whether all Hamiltonian cycles are preserved after the reduction, has been partially analysed in the proof of Theorem 2, here it remains to prove that: (i) the algorithm can be applied to a graph outside
(i) As the reduction is made only for pairs that satisfy the appropriate condition, only these arcs are removed which for sure will not compose any solution of the problem. (ii) The arcs marked to be reduced stay in the graph until the end of the algorithm, thus they do not influence other connections. Every next operation of marking an arc is independent of the previous ones. At any moment we can treat the graph as having the opposite direction of all its arcs, as it does not change the answer to the problem. (iii) Although such a pair already fulfills the condition for quasi-adjoint graphs, a reduction made for it can help to positively classify another pair. Only arcs that do not compose any solution are marked for the reduction. (iv) Vertex p with the same set of successors as u has the same connections that will never be used, thus safe to be removed. □
By re-running the algorithm, one increases its efficiency as new pairs of vertices can meet the required criteria. If the number of runs is constant, the complexity function does not grow. If one decides to re-run the algorithm as long as there are some reductions made, the number of runs is upper bounded by
Another observation led to a further extension of the considered classes. If, among all successors (resp. predecessors) of a pair of vertices, there is one with a unique predecessor (resp. successor), it binds in any Hamiltonian cycle its predecessor (resp. successor). Such a case can be added to the clauses defining
(3.3)
(3.4)
Theorem 4.
The Hamiltonian cycle problem in graphs belonging to
Proof.
The reduction is done similarly as for the graphs in
After the removal of the marked arcs from G, the algorithm solving the Hamiltonian cycle problem in quasi-adjoint graphs is executed with, optionally, the reversed orientation of arcs if
Fig. 4
It should be noticed that the example graph from Fig. 2(B) does not belong to any of the classes
When solving the Hamiltonian path problem in graphs from class
Let a be the assumed beginning of the path, b its end, and the added arc be
4Conclusion
Until now, the quasi-adjoint graphs were the widest class of digraphs proven to have a polynomial-time solution of the Hamiltonian cycle and path problems based on the transformation of graphs G into H. The extended classes of digraphs defined in the paper add new cases to this class. In addition, the reduction of arcs being a part of the proposed algorithms can function standalone and can be applied to digraphs outside the classes, possibly resulting in polynomial-time solutions for them.
The case of the Hamiltonian path has a more complicated solution because of the underlying assumptions in the definitions of the classes. Research on the algorithm for this problem could especially benefit, as the Hamiltonian path model is willingly used for real-life problems. As one of the current applications, the computational part of the process of genome assembly can be given, modelled, among others, as searching for variants of such a path (Swat et al., 2021).
References
1 | Bang-Jensen, J., Gutin, G. ((1999) ). On the complexity of Hamiltonian path and cycle problems in certain classes of digraphs. Discrete Applied Mathematics, 95: , 41–60. |
2 | Bang-Jensen, J., Gutin, G. ((2002) ). Digraphs. Theory, Algorithms and Applications. Springer-Verlag, London. |
3 | Berge, C. ((1973) ). Graphs and Hypergraphs. North-Holland Publishing Company, London. |
4 | Bertossi, A.A. ((1981) ). The edge Hamiltonian path problem is NP-complete. Information Processing Letters, 13: (4–5), 157–159. |
5 | Björklund, A. ((2014) ). Determinant sums for undirected hamiltonicity. SIAM Journal on Computing, 43: (1), 280–299. |
6 | Blazewicz, J., Kasprzak, M. ((2006) ). Computational complexity of isothermic DNA sequencing by hybridization. Discrete Applied Mathematics, 154: (5), 718–729. |
7 | Blazewicz, J., Kasprzak, M. ((2012) ). Reduced-by-matching graphs: toward simplifying Hamiltonian circuit problem. Fundamenta Informaticae, 118: (3), 225–244. |
8 | Blazewicz, J., Hertz, A., Kobler, D., de Werra, D. ((1999) ). On some properties of DNA graphs. Discrete Applied Mathematics, 98: (1–2), 1–19. |
9 | Blazewicz, J., Formanowicz, P., Kasprzak, M., Markiewicz, W.T. ((2004) ). Sequencing by hybridization with isothermic oligonucleotide libraries. Discrete Applied Mathematics, 145: (1), 40–51. |
10 | Blazewicz, J., Kasprzak, M., Leroy-Beaulieu, B., de Werra, D. ((2008) ). Finding Hamiltonian circuits in quasi-adjoint graphs. Discrete Applied Mathematics, 156: (13), 2573–2580. |
11 | Favaron, O., Ordaz, O. ((1986) ). A sufficient condition for oriented graphs to be Hamiltonian. Discrete Mathematics, 58: (3), 243–252. |
12 | Garey, M.R., Johnson, D.S. ((1979) ). Computers and Intractability. A Guide to the Theory of NP-Completeness. W.H. Freeman and Company, San Francisco. |
13 | Gould, R.J. ((1991) ). Updating the Hamiltonian problem – a survey. Journal of Graph Theory, 15: (2), 121–157. |
14 | Gross, J.L., Yellen, J., Zhang, P. (Eds.) ((2013) ). Handbook of Graph Theory, second edition. Chapman and Hall/CRC, Boca Raton. |
15 | Jäger, G., Zhang, W. ((2010) ). An effective algorithm for and phase transitions of the directed Hamiltonian cycle problem. Journal of Artificial Intelligence Research, 39: , 663–687. |
16 | Kasprzak, M. ((2018) ). Classification of de Bruijn-based labeled digraphs. Discrete Applied Mathematics, 234: , 86–92. |
17 | Kasteleyn, P.W. ((1963) ). A soluble self-avoiding walk problem. Physica, 29: (12), 1329–1337. |
18 | Lawler, E.L. ((1976) ). Combinatorial Optimization: Networks and Matroids. Holt, Rinehart and Winston, New York. |
19 | Swat, S., Laskowski, A., Badura, J., Frohmberg, W., Wojciechowski, P., Swiercz, A., Kasprzak, M., Blazewicz, J. ((2021) ). Genome-scale de novo assembly using ALGA. Bioinformatics, 37: (12), 1644–1651. |