Elsevier

Theoretical Computer Science

Volume 846, 18 December 2020, Pages 61-74
Theoretical Computer Science

A distributed algorithm for finding Hamiltonian cycles in random graphs in O(logn) time

https://doi.org/10.1016/j.tcs.2020.09.020Get rights and content

Abstract

It is known for some time that a random graph G(n,p) contains w.h.p. a Hamiltonian cycle if p is larger than the critical value pcrit=(logn+loglogn+ωn)/n. The determination of a concrete Hamiltonian cycle for G(n,p) is a nontrivial task, even when p is much larger than pcrit. In this paper we consider random graphs G(n,p) with p in Ω˜(1/n), where Ω˜ hides poly-logarithmic factors in n. For this range of p we present a distributed algorithm AHC that finds w.h.p. a Hamiltonian cycle in O(logn) rounds. The algorithm works in the synchronous model and uses messages of size O(logn) and O(logn) memory per node.

Introduction

Surprisingly few distributed algorithms have been designed and analyzed for random graphs. To the best of our knowledge the only work dedicated to the analysis of distributed algorithms for random graphs is [1], [2], [3]. This is rather surprising considering the profound knowledge about the structure of random graphs available since decades [4], [5]. While algorithms designed for general graphs obviously can be used for random graphs the specific structure of random graphs often allows to prove asymptotic bounds that are far better. In the classical Erdős and Rényi model for random graphs a graph G(n,p) is an undirected graph with n nodes where each edge independently exists with probability p [6]. The complexity of algorithms for random graphs often depends on p, e.g., Krzywdziński et al. [2] proposed a distributed algorithm that finds w.h.p. a coloring of G(n,p) with 18np colors in O(lnlnp1) rounds.

In this work we focus on finding Hamiltonian cycles in random graphs. The decision problem, whether a graph contains a Hamiltonian cycle, is NP-complete. In contrast to problems such as coloring or maximal independent set it is a non-local graph problem, i.e., it is required to always consider the entire graph in order to solve the problem. It is impossible to solve it in the local neighborhoods. For this reason there is almost no work on distributed algorithms for finding Hamiltonian cycles in general graphs. On the other hand it is well known that G(n,p) contains w.h.p. a Hamiltonian cycle, provided ppcrit=(logn+loglogn+ω(n))/n, where ω(n) satisfies limnω(n)= [4, Th. 8.9]. There is a large body of work on sequential algorithms for computing w.h.p. a Hamiltonian cycle in a random graph (e.g. [7], [8], [9], [10], [11]).

We are aware of two distributed algorithms for computing Hamiltonian cycles in random graphs. The algorithm by Levy et al. [1] outputs w.h.p. a Hamiltonian cycle provided p=ω(logn/n1/4). This algorithm works in synchronous systems, terminates in linear worst-case number of rounds, requires O(n3/4+ϵ) rounds on expectation, and uses O(n) space per node. The algorithm of Chatterjee et al. [3] works for pclogn/nδ (δ1) and has a run time of O˜(nδ). An algorithm based on a transformation scheme is discussed below [12].

The search for a distributed algorithm for a Hamiltonian cycle is motivated by the usage of virtual rings for routing in wireless networks [13], [14]. A virtual ring is a directed closed path involving each node of the graph, possibly several times. Virtual rings enable routing with constant space routing tables, messages are simply forwarded along the ring. The downside is that they may incur a linear path stretch. To attenuate this, distributed algorithms for finding short virtual rings have been proposed [15], [14]. Hamiltonian cycles are the shortest possible virtual rings and therefore of great interest. Short virtual rings are also of interest for all token circulation techniques as discussed in [16]. Kim et al. discuss the application of random Hamiltonian cycles for peer-to-peer streaming [17]. Rabbat et al. present distributed optimization algorithms for in-network data processing, aimed at reducing the amount of energy and bandwidth used for communication based on Hamiltonian cycles [18].

This paper uses the synchronous CONGEST model, i.e., each message contains at most O(logn) bits. Furthermore, each node has only O(logn) bits of local memory. Without these two assumptions there is a very simple solution provided the nodes have unique identifiers. First a BFS-tree rooted in a node v0 is constructed. Then the adjacency list of each node is convergecasted to v0 which applies a sequential algorithm to compute w.h.p. a Hamiltonian path (see Sec. 1.1). The result is broadcasted into the graph and thus each node knows its neighbor in the Hamiltonian cycle. This can be achieved in O(diam(G)) rounds. Note that if p=ωnlogn/n then w.h.p. diam(G(n,p))=O(logn/lognp) [19], [5]. In particular for p in Ω˜(1/n) w.h.p. the diameter of G(n,p) is constant [20].

For the stated restrictions on message size and local storage we propose an algorithm that terminates in a logarithmic number of rounds, this is a significant improvement over previous work [1], [3]. Our contribution is the distributed algorithm AHC, its properties can be summarized as follows.

Theorem 1

Let G(n,p) with p(logn)3/2/n be a random graph. Algorithm AHC computes in the synchronous model w.h.p. a Hamiltonian cycle for G using messages of size O(logn). AHC terminates in O(logn) rounds and uses O(logn) memory per node.

Pósa showed already in 1976 that almost all random graphs with cnlogn edges possess a Hamiltonian cycle [7]. Later Komlós et al. determined the precise threshold pcrit for the existence of a Hamiltonian cycle in a random graph [21]. A sequential deterministic algorithm that works w.h.p. at this threshold requiring O(n3+o(1)) time is due to Bollobás et al. [10]. For larger values of p or restrictions on the minimal node degree, more efficient algorithms are known [8], [22]. The algorithm of Thomason finds a Hamiltonian path or shows that no such path exists provided p12n1/3 [11].

The above cited algorithms were all designed for the sequential computing model. Some exact algorithms for finding Hamiltonian cycles in G(n,p) on parallel computers using the CRCW-PRAM model have been proposed [23], [24]. The first uses O(nlogn) processors and O(log2n) expected time provided p>clogn/n for some large enough constant c. MacKenzie and Stout proposed an algorithm that operates in O(logn) expected time and requires n/logn processors provided p is constant [24]. Apart from the above mentioned work [1], [3] we are aware of only one other distributed algorithm for this problem. Ghaffari and Li proposed a general transformation that simulates any work-efficient PRAM algorithm running on a graph G in T parallel rounds via a distributed algorithm running in τmix(G)2O(logn)T rounds in the CONGEST model [12]. Applying their transformation to the algorithm of Coppersmith [23] they show the existence of a distributed algorithm that finds in 2O(logn) rounds w.h.p. a Hamiltonian cycle of G(n,p) provided that pClogn/n for some large enough constant C. Besides the fact that the transformed algorithm may be difficult to implement it also has a worse time complexity compared to the proposal of this paper.

There are several approaches to construct a Hamiltonian cycle. The approach used by Levy et al. at least goes back to the work of MacKenzie and Stout [24]. They initially construct a small cycle with Θ(n) nodes. As many as possible of the remaining nodes are assorted in parallel into n vertex-disjoint paths. During the final phase, each path and each non-covered vertex are patched into the initial cycle.

The second approach is used in the proofs to establish the critical value pcrit (e.g., [7], [25]) and all derived sequential algorithms (e.g., [10]). Initially a preferably long path is constructed, e.g., using a depth first search algorithm [22]. This path is extended as long as the node at the head of the path has a neighbor that is not yet on the path. Then the path is rotated until it can be extended again. A rotation of the path cuts off a subpath beginning at the head, reverses the order of the subpath's nodes, and reattaches the subpath again. The procedure stops when no sequence of rotations leads to an extendable path. The algorithm in [3] follows this approach.

Section snippets

Computational model and assumptions

This work employs the synchronous CONGEST model of the distributed message passing model [26], i.e., each message contains at most O(logn) bits. Furthermore, each node has only O(logn) bits of local memory. The communication network is represented by an undirected graph G=(V,E), where V is a set of n processors (nodes) and E represents the set of m bidirectional communication links (edges) between them. Each node carries a unique identifier. Communication between nodes is performed in

Informal description of algorithm AHC

Algorithm AHC operates in sequential phases, each of them succeeds w.h.p. The first two phases last O(logn) rounds. Each subsequent phase requires a constant number of rounds only. Phase 0 lasts 3(3logn1) rounds and constructs a path P of length 3logn starting in v0. In the next 3logn rounds Phase 1 closes P into a cycle C of length at most 4logn. The following 6logn phases are called the middle phases. In each of those phases the number of nodes in C is increased. The increase is by a

Formal description

Algorithm AHC operates in synchronous rounds. By counting the rounds a node is always aware in which round and therefore also in which phase it is. Each phase lasts a known fixed number of rounds. If the work is completed earlier, the network is idle for the remaining rounds of the phase. Algorithm AHC gradually builds an oriented cycle C starting with node v0. The cycle is maintained as a doubly linked list to support insertions. The orientation of C is administered with the help of variable ne

Analysis of algorithm AHC

This section proves the correctness and analyzes the complexity of the individual phases and proves the main theorem. First, we prove that AHC produces the numbering that guarantees that the final phases work correctly. Afterwards the individual phases are analyzed. Some of the results are proved for values of p less than (logn)3/2/n to make them more general.

Lemma 2

At the end of each phase each node has a different number provided λ7. Furthermore, the numbers are ascending beginning with 0 for node

Proof of Theorem 1

The pre-processing phase lasts 9 rounds. By Lemma 3, Lemma 5 phases 0 and 1 terminate after 3logn rounds w.h.p. with a cycle with at most 4logn nodes. Each middle phase lasts a constant number of rounds. According to Lemma 9 after at 3logn middle phases the cycle C has w.h.p. n/7 nodes and by Lemma 12 after another 3logn middle phases w.h.p. n3logn nodes. Then in 3logn final phases, each lasting a constant number of rounds, C is w.h.p. a Hamiltonian cycle by Lemma 13. This leads to the

Conclusion

This paper presented an efficient distributed algorithm to compute in O(logn) rounds w.h.p. a Hamiltonian cycle for a random graph G(n,p) provided p(logn)3/2/n. This constitutes a large improvement over the state of the art with respect to p=clogn/nδ (0<δ1) and run time O˜(nδ). It is well known that G(n,p) contains w.h.p. a Hamiltonian cycle, provided ppcrit. There is a large gap between (logn)3/2/n and pcrit. It appears that by maxing out the arguments of this paper it is possible to

Declaration of Competing Interest

The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

Acknowledgements

This work is supported by the Deutsche Forschungsgemeinschaft (DFG) under grant DFG TU 221/6-3. The author is grateful to the reviewers' valuable comments that improved the manuscript.

References (27)

  • E. Levy et al.

    A distributed algorithm to find Hamiltonian cycles in G(n,p) random graphs

  • K. Krzywdziński et al.

    Distributed algorithms for random graphs

    Theor. Comput. Sci.

    (2015)
  • S. Chatterjee et al.

    Fast and efficient distributed computation of Hamiltonian cycles in random graphs

  • B. Bollobás

    Random Graphs

    (2001)
  • A. Frieze et al.

    Introduction to Random Graphs

    (2015)
  • P. Erdős et al.

    On random graphs I

    Publ. Math. (Debr.)

    (1959)
  • L. Pósa

    Hamiltonian circuits in random graphs

    Discrete Math.

    (1976)
  • D. Angluin et al.

    Fast probabilistic algorithms for Hamiltonian circuits and matchings

    J. Comput. Syst. Sci.

    (1979)
  • E. Shamir

    How many random edges make a graph Hamiltonian?

    Combinatorica

    (1983)
  • B. Bollobás et al.

    An algorithm for finding Hamilton paths and cycles in random graphs

    Combinatorica

    (1987)
  • A. Thomason

    A simple linear expected time algorithm for finding a Hamilton path

    Discrete Math.

    (1989)
  • M. Ghaffari et al.

    New distributed algorithms in almost mixing time via transformations from parallel algorithms

  • D. Malkhi et al.

    Virtual ring routing trends

  • View full text