1 Introduction

Flooding is one of the most fundamental of all graph/network algorithms - for example, to achieve broadcast in networks [2, 14, 23, 25, 27, 29, 30]. The algorithm that is usually implemented is: (i) sources send a message to all their neighbours, (ii) on first receipt, receiving nodes send the message to every neighbour from which they did not receive and (iii) on subsequent receipts, the receiving node does not send the message to any neighbour. This algorithm checks if the message has been received before, to ensure termination. It requires each node records a previous event in its state, making it a stateful protocol. We consider a stateless version of flooding, i.e. algorithms that are ‘amnesiac’ in the sense that they hold no record or memory of any event beyond the immediate round. The algorithm is as follows.

Definition 1

Amnesiac flooding algorithm. Let (GE) be an undirected graph, with vertices G and edges E (representing a network where the vertices represent the nodes of the network and edges represent the connections between the nodes). Computation proceeds in synchronous ‘rounds’ where each round consists of nodes receiving messages being sent from neighbours. A receiving node sends messages to some neighbours in the next round. No messages are lost in transit. The algorithm is defined by the following conditions.

  1. (i)

    All nodes from a subset of sources or initial nodes \(I \subseteq G\) send a message M to all of their neighbours in round 1.

  2. (ii)

    In subsequent rounds, every node that received M from a neighbour in the previous round, sends M to all, and only those, nodes from which it did not receive M. Flooding terminates when M is no longer sent to any node in the network.

Hitherto, it was not known whether a stateless flooding algorithm exists that terminates on every graph. In this paper, we show that amnesiac flooding is itself such an algorithm. If e and d are the eccentricity of \(g_0\) and diameter of (GE) respectively, the termination times for a single source \(g_0\) are e rounds if (GE) is bipartite and j rounds with \(e < j \le e+d+1\) otherwise. These times are asymptotically time optimal. The difference in times between bipartite and non-bipartite graphs means that a stateless algorithm can approximate the topology or diameter/eccentricities of a network in certain cases.

Gopal, Gopal and Kutten [14] highlighted the memory requirement inherent in stateful flooding and its overhead on fast networks. For example, when multiple messages are being flooded, nodes need to keep a record of the messages they have seen and search through their data structure whenever a message arrives before deciding if it can be further flooded. This creates a bottleneck, in particular when the transmission links are fast. Either specialised high speed hardware has to be used for the search, or alternate flooding protocols that limit the memory overhead (as they do in their paper) have to be used. This is also a limitation for low memory devices, e.g. sensor networks. Since amnesiac flooding is stateless using no memory beyond the present round, it does not incur this memory overhead and bottleneck. One advantage of the stateful variant of flooding is that it can be used to construct spanning structures, such as spanning trees, which can be subsequently re-used for efficient communication [2, 22, 27, 31]. It is not easy to maintain these structures in dynamic conditions, i.e. when edges/nodes are being added or removed. We show that even when edges are being arbitrarily or adversarially removed from the graph, amnesiac flooding will still terminate. However, termination is not guaranteed in asynchronous models where the delivery time of messages on edges can vary - we show this with a non-terminating delivery schedule for the simplest of cycles. Neither is it guaranteed for general graphs even if there is a fixed delivery delay at only one edge.

This paper is structured as follows. The rest of this section looks at related work. In Sect. 2, we prove that if a message is flooded from a set I of initial nodes in round 1, all nodes receive the message at most twice and hence amnesiac flooding terminates (Theorem 2.1). In Sect. 3, this result is used to derive sharp time bounds for the number of rounds it takes for flooding to terminate. As mentioned above, in the case of a single initial node \(g_0\), flooding terminates in e rounds if (GE) is bipartite and j rounds with \(e < j \le e+d+1\) if (GE) is not bipartite. The difference in the time bounds rests on the absence of neighbouring nodes (called ‘ec-nodes’ here) equidistant from the initial node \(g_0\) in bipartite graphs. For general sets of initial nodes I, we define I-bipartite graphs as those which do not have any neighbouring nodes equidistant from the set of initial nodes I and show that the difference in termination times between bipartite and non bipartite graphs for single initial nodes \(g_0\) carries over to a similar difference in termination times between I-bipartite and non I-bipartite graphs for general I. For I-bipartite graphs termination occurs in round e(I) (Theorem 3.4), where e(I) is the eccentricity of I, i.e. the furthest distance of a node from the set I. The main theorem of the paper is for non I-bipartite graphs, where termination is shown to occur in a number of rounds which lies in the range between \(e(I)+1\) and \(e(I)+d+1\):

(Theorem 3.7) Let (GE) be a graph that is not I-bipartite and let d be the diameter. Then, flooding terminates in round j where j is in the range

$$\begin{aligned} e(I) < j \le e(I)+d+1. \end{aligned}$$

In the case where there is more than one initial node in I, termination of non I-bipartite graphs is achieved at the \(e(I)+1\) lower bound if all nodes in I have neighbouring nodes in I (Theorem 3.8). In Sect. 4 we provide some extensions of synchronous amnesiac flooding to cases where message transit along an edge may take more than one round. We show that termination of amnesiac flooding is resilient to loss of edges or vertices during the flooding process (Theorem 4.1), but not, in general, to delays even at a single edge. However, if the flooding is from a single source then the termination result for bipartite graphs extends to the case where there is a fixed delay of message transit of \(\tau \) rounds at a single edge, with the termination times more like the the non-bipartite graph termination times with no delays:

(Theorem 4.2) Let (GE) be a bipartite graph, \(g_0 \in G\) be an initial node, \(e = \{ x,y \} \in E\) be an edge, and \(\tau \) be an integer greater than 1. Then flooding initiated from \(g_0\), in which a message in transit along e takes \(\tau \) rounds and 1 round along any other edge, visits every node at most twice and completes in not more than \(2d+\tau -1\) rounds where d is the diameter of (GE).

Amnesiac flooding from multiple sources in even or odd cycles with any number of possibly different fixed delays at edges, terminates:

(Theorem 4.3) Let (GE) be an edge-weighted cycle in which (possibly different) positive integer edge weights represent duration of message transit in rounds along edges and \(I \subseteq G\) be a set of initial nodes. Then, flooding initiated from initial nodes in I terminates in not more than the weight \(\sigma \) of (GE) number of rounds, where the weight \(\sigma \) of (GE) is the sum of the weights of the edges.

However, if the duration of message transit along an edge is variable, as in the case of an asynchronous model of amnesiac flooding, then flooding is not guaranteed to terminate even on a cycle graph. Section 5 is the concluding section and contains a number of open problems.

1.1 Related work

The proof of termination in Sect. 2 of this paper appeared as a conference brief announcement by Hussak and Trehan in PODC 2019 [15]. The proof of separate time bounds for termination in bipartite and non-bipartite graphs in the case of a single initial node appeared in STACS 2020 [17]. This paper is an extended version of the two conference papers, generalizing the previous results to the case of a set I of multiple initial nodes, with a structural characterization in terms of certain quotient ‘I-bipartite’ graphs of where the corresponding separation of time bounds occurs. We also show sharpness of the bounds for the time to termination. Further extensions and also negative results are given in this paper on termination of amnesiac flooding in which there are delays of message transit along edges. Another study by Hussak and Trehan [16] considers amnesiac flooding with different messages being simultaneously flooded under various different forwarding rules when messages are received at nodes.

Flooding-based algorithms (or flooding protocols) appear in areas ranging from GPUs, high performance, shared memory and parallel computing, to mobile ad-hoc networks (MANETs), Mesh Networks, Complex Networks etc [30]. Rahman et al [28] show that flooding can even be adopted as a reliable and efficient routing scheme, comparable to sophisticated point-to-point forwarding schemes, in some ad-hoc wireless mobile network applications.

There are numerous applications of flooding as a distributed algorithm. It is often used to set up spanning trees [2, 22, 27, 31] and for solving various distributed computing problems such as leader election. For example, the time-optimal leader election of Peleg [26] builds on a variant of flooding which also does not check previously received messages to detect termination. The algorithm does continuous flooding of node IDs to determine the node in the network with the highest ID while using either the knowledge of the graph diameter or a condition on the node IDs to achieve and detect termination. Kutten et al. [20], on the other hand, use controlled stateful flooding and resulting spanning trees and structures for deterministic and randomised efficient time and message leader election.

Statelessness has always been a desirable property and stateless algorithms have been developed in various contexts. Adamek, Nesterenko, Robinson, Tixeuil [1] and Karp and Kung [18] offer stateless (flooding and other) solutions for routing. Adamek et al. provide the first known stateless geocast algorithms. One of these is based on flooding itself and also permits converting previous controlled flooding solutions to be stateless. Awerbuch and Khandekar developed stateless solutions for multi-commodity flows [3]. They also developed a framework for distributed and stateless solutions for packing and covering linear programs by multiple cooperating but uncoordinated agents [4] . In these, they list a number of desirable properties of statelessness (especially in this context): i) Self-stabilization: recovery from adversarial ‘hard’ crashes, ii) Incremental and Local adjustment: easily adjusts locally to changes, and iii) Allows asynchrony (in their context).

In [11], Dolev, Erdmann, Lutz, Schapira, and Zair, propose a model of stateless computation in which nodes have no internal state, receive external inputs and compute a global function purely on the basis of the inputs they receive from neighbours connected via directed links. They then discuss self-stabilization in this model and also the power of stateless computation proving that stateless computation is sufficiently powerful to solve a nontrivial range of computational manners in a resilient manner with small message lengths.

Note that amnesiac flooding uses rules that avoid forwarding to the most recently chosen nodes - similar ideas have been used before in distributed computing, e.g. in social networks [10] and broadcasting [12]. Processes such as random walks [8, 9, 13, 20, 21] and their deterministic variant Rotor-Router (or Propp) machine [7, 19] can also be seen as restricted variants of flooding. Finally, in some models such as population protocols, the low memory makes termination very difficult to achieve leading to research that tries to provide termination e.g. [24]. Like population protocols, amnesiac flooding is a very simple and natural algorithm - it would be interesting to investigate if there are processes in nature close to amnesiac flooding.

Since our results on amnesiac flooding [15,16,17], there have been a number of follow-up works by various researchers. In a series of works by Turau [32,33,34,35], proofs of termination for non-bipartite graphs work with the bipartite graph (called the ‘auxiliary’ graph) that is obtained by taking two copies of the given non-bipartite graph minus edges connecting ec-nodes, and creating edges between the different copies of pairs of ec-nodes. So, a message is received once by each copy of a node in the auxiliary graph rather than twice in the original graph. In [33], Turau provides a simple extension to reduce termination time in non-bipartite graphs by sending the initial broadcast message in two consecutive rounds (though this now requires the initiators to remember, in round 2, the message and their state of round 1). In [32, 33], the ‘k-flooding problem’ is posed which aims to find a set S of size k such that amnesiac flooding when started concurrently by all nodes of S terminates in the least number of rounds. This problem is shown to be NP-Hard and bounds on approximation are given. The possibility of modifying the message to achieve termination in asynchronous networks is also discussed.

Bayramzadeh, Kshemkalyani, Molla and Sharma [5, 6] consider the variants of simultaneous flooding of multiple different messages that we suggest in [16]. They propose a variant of amnesiac flooding that is ‘weak’ in the sense that the nodes have the knowledge of the diameter of the network and use that knowledge to achieve termination in one of the variants we show to be non-terminating in our original amnesiac flooding with simultaneous different messages.

2 Termination

Throughout this paper, we assume that graphs are finite, undirected and connected. In keeping with the papers by Hussak and Trehan [15] and [17] we shall refer to graphs (GE) rather than \(G=(V,E)\) and talk of ‘nodes’ \(g \in G\) rather than ‘vertices’ \(v\in V\). Terminology regarding paths and cycles is standard. A walk differs from a path in that nodes (vertices) may be visited more than once. A closed walk is a walk whose start and end nodes are the same. By ‘flooding’ we will implicitly mean the amnesiac flooding of Definition 1. In this section we prove that (amnesiac) flooding initiated from any set of initial nodes \(I \subseteq G\), all at once, terminates.

Definition 2

Let (GE) be the graph and \(I \subseteq G\) a set of initial nodes. The round-sets \(R_0, R_1, \ldots \) are defined as:

$$\begin{aligned} \begin{array}{ll} R_0 &{} \textit{is the set}\ I\ \textit{of initial nodes}, \\ R_i &{} \textit{is the set of nodes receiving a message in round i} \\ \; &{} (i \ge 1). \\ \end{array} \end{aligned}$$

Clearly, if \(R_j = \emptyset \) for some \(j \ge 0\), then \(R_i = \emptyset \) for all \(i \ge j\). Flooding terminates in round j if \(R_j \ne \emptyset \) and \(R_i = \emptyset \) for all \(i > j\).

Theorem 2.1

Any node \(g \in G\) is contained in at most two distinct round-sets.

Proof

Define \({\mathcal {R}}\) to be the set of finite sequences of consecutive round-sets of the form:

$$\begin{aligned}{} & {} \underline{R} =R_s, \ldots , R_{s+d}, \; \textit{where}\ s\ge 0, \;d>0 \nonumber \\{} & {} \quad \textit{and}\ R_s \cap R_{s+d} \ne \emptyset . \end{aligned}$$
(1)

In (1), s is the start-point \(s(\underline{R})\) and d is the duration \(d(\underline{R})\) of \(\underline{R}\). Note that, a node \(g \in G\) belonging to \(R_s\) and \(R_{s+d}\) may also belong to other \(R_i\) in (1). If a node \(g \in G\) occurs in three different round-sets \(R_{i_1}\), \(R_{i_2}\) and \(R_{i_3}\), then at least one of the durations between \(R_{i_1}\) and \(R_{i_2}\), \(R_{i_2}\) and \(R_{i_3}\) or \(R_{i_1}\) and \(R_{i_3}\) will be even. Consider the subset \({\mathcal {R}}^e\) of \({\mathcal {R}}\) of sequences of the form (1) where d is even. To prove that no node is in three round-sets, it suffices to prove that \({\mathcal {R}}^e\) is empty.

We assume that \({\mathcal {R}}^e\) is non-empty and derive a contradiction. Let \({\mathcal {R}}^e_{min}\) be the subset of \({\mathcal {R}}^e\) comprising sequences of minimum (even) duration \(\hat{d}\), i.e.

$$\begin{aligned} {\mathcal {R}}_{min}^e = \{ \underline{R} \in {\mathcal {R}}^e : \forall \; \underline{R}'\in {\mathcal {R}}^e . d(\underline{R}') \ge d(\underline{R})=\hat{d} \} \end{aligned}$$
(2)

Clearly, if \({\mathcal {R}}^e\) is non-empty then so is \({\mathcal {R}}^e_{min}\). Let \(\underline{R}^* \in {\mathcal {R}}^e_{min}\) be the sequence with earliest start-point \(\hat{s}\), i.e.

$$\begin{aligned} \underline{R}^* = R_{\hat{s}}, \ldots , R_{\hat{s}+\hat{d}} \end{aligned}$$
(3)

where

$$\begin{aligned} \forall \; \underline{R}'\in {\mathcal {R}}_{min}^e\;.\; s(\underline{R}') \ge s(\underline{R}^*) = \hat{s} \end{aligned}$$
(4)

By (1), there exists \(g \in R_{\hat{s}} \cap R_{\hat{s}+\hat{d}}\). Choose node \(g'\) which sends a message to g in round \(\hat{s}+\hat{d}\). As \(g'\) is a neighbour of g, either \(g'\) sends a message to g in round \(\hat{s}\) or g sends a message to \(g'\) in round \(\hat{s}+1\). We show that each of these cases leads to a contradiction.

Case (i) \(g'\) sends a message to g in round \(\hat{s}\)

In this case, either round \(\hat{s}-1\) is round 0 and \(g'\) is an initial node in I, or \(g'\) received a message in round \(\hat{s}-1\). Thus, the sequence

$$\begin{aligned}{} & {} \underline{R}^{*'} = R_{\hat{s}-1},R_{\hat{s}},\ldots , R_{\hat{s} +\hat{d}-1},\nonumber \\{} & {} \quad \textit{where}\; g' \in R_{\hat{s}-1} \cap R_{\hat{s}+\hat{d}-1}, \end{aligned}$$
(5)

has \(d( \underline{R}^{*'})=(\hat{s}+\hat{d}-1)-(\hat{s}-1) =\hat{d}\) which is even and so \(\underline{R}^{*'} \in {\mathcal {R}}_{min}^e\). As \(\underline{R}^{*'} \in {\mathcal {R}}_{min}^e\), by (4)

$$\begin{aligned} s(\underline{R}^{*'}) \ge s(\underline{R}^*) \end{aligned}$$
(6)

But, from (5), \(s(\underline{R}^{*'}) = \hat{s}-1\) and, from (4), \( s(\underline{R}^*)=\hat{s}\). Thus, by (6),

$$\begin{aligned} \hat{s}-1 = s(\underline{R}^{*'}) \ge s(\underline{R}^*) = \hat{s} \end{aligned}$$

which is a contradiction.

Case (ii) g sends a message to \(g'\) in round \(\hat{s}+1\)

By the definition of \({\mathcal {R}}^e\), the smallest possible value of \(\hat{d}\) is 2. However, it is not possible to have \(\hat{d}=2\) in this case as then

$$\begin{aligned} \underline{R}^* = R_{\hat{s}}, R_{\hat{s}+1}, R_{\hat{s}+2} \end{aligned}$$

and g sends a message to \(g'\) in round \(\hat{s}+1\). As we chose \(g'\) to be such that \(g'\) sends a message to g in round \(\hat{s}+\hat{d}=\hat{s}+2\) this cannot happen because g cannot send a message to \(g'\) and \(g'\) to g in consecutive rounds by the definition of flooding. So,

$$\begin{aligned} \underline{R}^* = R_{\hat{s}}, R_{\hat{s}+1},\ldots , R_{\hat{s}+\hat{d}-1}, R_{\hat{s}+\hat{d}} \end{aligned}$$

where \(\hat{s}+1<\hat{s}+\hat{d}-1\). Consider the sequence

$$\begin{aligned} \underline{R}^{*''} = R_{\hat{s}+1},\ldots , R_{\hat{s}+\hat{d}-1} \end{aligned}$$
(7)

As \(g'\) receives a message from g in round \(\hat{s}+1\) and \(g'\) sends a message to g in round \(\hat{s}+\hat{d}\), it is clear that \(g' \in R_{\hat{s}+1} \cap R_{\hat{s}+\hat{d}-1}\). Thus, \(\underline{R}^{*''} \in {\mathcal {R}}\). As \(\hat{d}\) is even, so is \((\hat{s}+\hat{d}-1)-(\hat{s}+1)=\hat{d}-2\) and therefore \(\underline{R}^{*''} \in {\mathcal {R}}^e\). Now, \(\underline{R}^* \in {\mathcal {R}}^e_{min}\) and so, as \(\underline{R}^{*''} \in {\mathcal {R}}^e\), we have, by (2),

$$\begin{aligned} d(\underline{R}^{*''}) \ge d(\underline{R}^*) \end{aligned}$$
(8)

As \(d(\underline{R}^{*''})=\hat{d}-2\) from (7) and \(d(\underline{R}^*) = \hat{d}\) from (3), we have, by (8),

$$\begin{aligned} \hat{d}-2 = d(\underline{R}^{*''}) \ge d(\underline{R}^*) = \hat{d} \end{aligned}$$

This contradiction completes the proof. \(\square \)

Definition 3

Given \(g \in G\), we use a superscript 1 to indicate that g belongs to a round-set for the first time, and a superscript 2 to indicate that it belongs to a round-set for the second time, i.e.

$$\begin{aligned} g^1 \in R_j \end{aligned}$$

means that

$$\begin{aligned} g \in R_j \;\;\; { and} \;\;\;g \notin R_i \;\;\; \textit{for all i with} \;\; 0 \le i < j, \end{aligned}$$

and

$$\begin{aligned} g^2 \in R_j \end{aligned}$$

means that

$$\begin{aligned} g \in R_j \;\;\; { and} \;\;\;g \in R_i \;\;\; \textit{for some i with} \;\; 0 \le i < j. \end{aligned}$$

Theorem 2.1 implies that \(R_i = \emptyset \) for \(i \ge 2|G |\), where \(|G|\) is the number of vertices of (GE), and therefore flooding always terminates. In the next section we give sharp bounds for the number of rounds to termination, in terms of the eccentricity of the set of initial nodes and the diameter of (GE).

3 Time to termination

The question of termination of flooding is non-trivial when cycles are present in (GE). The simple cases when (GE) is an even cycle and when (GE) is an odd cycle, as in Fig. 1 (where an arrow indicates a message received by a node in the given round), have quite different termination behaviours. The even cycle terminates remotely from the initial node \(g_0\), after round e where e is the eccentricity of \(g_0\) in (GE). On the other hand, flooding on the odd cycle returns a message to the initial node \(g_0\) and terminates after round \(2e+1= e+d+1\) resulting in a longer flooding process than the even cycle despite having fewer nodes and a smaller value of e. In this section, we show that these observations can in a certain way be generalized to arbitrary graphs. In the previous section we showed that messages can be received at most twice. Observe that in the even cycle every node receives the message only once, whereas in the odd cycle every node receives the message twice. In general graphs, this difference is due to the absence or presence of neighbouring nodes that are equidistant from the set of initial nodes I, called ‘ec-nodes’ below. In this section, by considering the BFS layers around the initial set I, we show that in graphs that have no ec-nodes, the message just travels once forward through the BFS layers in e(I) rounds, where e(I) is the ‘eccentricity’ of I, i.e. the largest distance of a node from the set I. These are the bipartite graphs in the case of I being a single node (Lemma 3.3), and so we call them ‘I-bipartite’ graphs for general I. They terminate in round e(I) and non I-bipartite graphs terminate no sooner than in round \(e(I)+1\) (Theorem 3.4). In graphs that have ec-nodes the message will have a one round bounce back through ec-nodes in the same BFS layer, and then the whole process will terminate within an additional diameter number of rounds, as nodes adjacent to a node receiving the message for the second time will receive the message for the second time in an adjacent round (Lemma 3.5). Hence the \(e(I)+d+1\) upper bound for graphs that are not I-bipartite (Theorem 3.7). The lower \(e(I)+1\) bound for termination of non I-bipartite graphs is sharp and is achieved if all nodes in I have neighbours in I (Theorem 3.8).

Fig. 1
figure 1

Flooding in even and odd cycles

Definition 4

Let (GE) be a graph with vertex set G and edge set E and let \(I \subseteq G\) be a set of initial nodes. We will use the following definitions.

  1. (i)

    For each \(j \ge 0\), the distance set \(D_j\) will denote the set of points which are a distance j from I. i.e.

    $$\begin{aligned} D_j = \{ g \in G \; : \; \delta (I,g) = j \}, \end{aligned}$$

    where, for any \(g \in G\),

    $$\begin{aligned} \delta (I,g) = { min}\{ \delta (g_0,g) \; : \; g_0 \in I \} \end{aligned}$$

    and \(\delta \) denotes the usual graph distance function for graph (GE).

  2. (ii)

    A node \(g \in G \) is an equidistantly-connected node, abbreviated ec-node, iff it has a neighbour \(g'\) equidistant from I, i.e. iff there exists \(g' \in G\) such that \(\delta (I,g)=\delta (I,g')\) and \(\{ g, g' \} \in E\). The set of ec-nodes in G is denoted \(G_{ec}\).

  3. (iii)

    The eccentricity of I, denoted e(I), is defined as

    $$\begin{aligned} e(I) = { max}\{ \delta (I,g) \; : \; g \in G \} \end{aligned}$$
  4. (iv)

    The graph (GE) is I-bipartite iff (GE) has no ec-nodes. Equivalently, (GE) is I-bipartite iff the quotient graph of (GE), in which the nodes of I are contracted to a single node, is bipartite.

Note that neighbouring initial nodes \(g_0,g_0' \in I\) are ec-nodes as they are both a distance 0 from I. We have the following basic properties of distance sets \(D_j\) and ec-nodes.

Lemma 3.1

Let (GE) be a graph and \(I \subseteq G\) be a set of initial nodes.

  1. (i)

    For all \(j \ge 0\) and \(i>j\), \(D_j \subseteq R_j\) and \(R_j \cap D_i = \emptyset \).

  2. (ii)

    For all \(j \ge 0\), \(g \in D_j\) and \(g' \in D_{j+1}\) such that g and \(g'\) are neighbours, g sends a message to \(g'\) in round \(j+1\), i.e. all nodes at a distance j from I send to all their neighbours which are a distance \(j+1\) in round \(j+1\).

  3. (iii)

    If \(j \ge 0\) and \(g \in D_j\) is an ec-node, then \(g^2 \in R_{j+1}\).

Proof

For (i), clearly every node at a distance j from I receives a message in round j and so \(D_j \subseteq R_j\). Furthermore, every message received in round j will have travelled at most j edges away from I and so could not have reached a node which is at a distance \(i>j\) from I. Thus, \(R_j \cap D_i = \emptyset \).

For (ii), we note that the only circumstance in which a node g in \(D_j\) (\(\subseteq R_j\) by (i)) does not send to a neighbour \(g'\) in \(D_{j+1}\) in round \(j+1\) is if g sent a message to \(g'\) in round j. This would need g to be in the round-set \(R_{j-1}\), i.e. \(g \in R_{j-1} \cap D_{j+1}\) which contradicts (i) which has \(R_{j-1} \cap D_{j+1} = \emptyset \) as \(j+1 > j-1\).

For (iii), if \(j \ge 0\) and \(g \in D_j\) is an ec-node, then by Definition 4(ii) there is an point \(g'\) equidistant from I, i.e. \(g' \in D_j\) such that g and \(g'\) are neighbours. If \(j=0\) then \(g,g' \in D_0 (= I \subseteq R_0)\) and send a message to each other in round 1 and so \(g,g' \in R_1\). This means that \(g^2 \in R_1\), as g is an initial node and \(g^1 \in R_0\). If \(j \ge 1\) then, by (i) of this lemma, \(D_j \subseteq R_j\) and so both g and \(g'\) receive messages in round j. Also, by (i), neither sends a message in round j as \(R_{j-1} \cap D_j = \emptyset \). Thus, g and \(g'\) send messages to each other in round \(j+1\). As this will be the second time they receive a message we have that \(g^2 \in R_{j+1}\). \(\square \)

All nodes in a graph without ec-nodes, belong to at most one round-set.

Lemma 3.2

Let (GE) be a graph and \(I \subseteq G\) be a set of initial nodes. Then (GE) has an ec-node if and only if (GE) has a node that is in two round-sets.

Proof

Suppose that (GE) has no ec-nodes. Assume, on the contrary, that (GE) has nodes that appear in two round-sets. Let \(R_j\) \((j \ge 1)\) be the earliest round which contains a node g such that \(g^2 \in R_j\) and \(h \in R_{j-1}\) be a neighbour of g which sends to g in round j, so that \(h^1 \in R_{j-1}\). Then, \(h \in D_i\) for some \(i \ge 0\) and \(h^1 \in R_i\) by Lemma 3.1 (i). Thus, \(i=j-1\) and so \(g^2 \in R_{i+1}\). As g is a neighbour of h, \(g \in D_i\), \(D_{i+1}\), or \(D_{i-1}\). If \(g \in D_i\) then g and h are ec-nodes contrary to our supposition that (GE) has no ec-nodes. If \(g \in D_{i+1}\) then \(g^1 \in R_{i+1}\) by Lemma 3.1 (i), which is contrary to the assertion that \(g^2 \in R_j = R_{i+1}\). If \(g \in D_{i-1}\) then \(g \in R_{i-1}\), by Lemma 3.1(i), and so \(g^1 \in R_{i-1}\) as \(g^2 \in R_{i+1}\). By Lemma 3.1 (ii), g sends to h in round \(i=j-1\). This is contrary to h sending to g in round j. Thus, our assumption that (GE) has nodes that appear in two round-sets is false.

Conversely, suppose that (GE) has an ec-node g, \(g \in D_j\) (\(\subseteq R_j\) by Lemma 3.1 (i)) say where \(j \ge 1\). Then \(g^2 \in R_{j+1}\) by Lemma 3.1 (iii). \(\square \)

In the case of a single initial node, bipartite graphs do not have any ec-nodes.

Lemma 3.3

Let (GE) be a graph and suppose that I contains a single initial node \(g_0\) . Then, (GE) is bipartite iff it has no ec-nodes.

Proof

It is easy to see that nodes equidistant from the initial node \(g_0\) must belong to the same partite set. A graph is bipartite iff no edge connects two such nodes, and this is the case iff (GE) has no ec-nodes by Definition 4 (ii). \(\square \)

From Lemma 3.2 we see that nodes in graphs without ec-nodes only receive a message once. For these graphs the time to termination is the number of rounds taken for the message to reach the most distant points from the set of initial nodes I. This is just the eccentricity of I, e(I).

Theorem 3.4

Let (GE) be a graph and \(I \subseteq G\) be a set of initial nodes with eccentricity e(I). Then, flooding terminates in round e(I) if and only if (GE) is I-bipartite

Proof

$$\begin{aligned} \begin{array}{l} (G,E)\ \text {is I-bipartite} \\ \text {implies}\ (G,E)\ \text {has no ec-nodes (by Definition}~4\text {(iv))} \\ \text {implies no node appears in 2 round-sets (by Lemma}~3.2) \\ \text {implies furthest nodes get message last} \\ \text {implies}\ R_{e(I)}\ \text {is the last non-empty round-set} \\ \hbox {(by Lemma}~3.1\text {(i))}. \\ \end{array} \end{aligned}$$

The converse is also true. If flooding terminates in round e(I), then the furthest nodes will receive the message for the first and only time in that round. Thus, (GE) has no ec-nodes by Corollary 3.6 (proved below independently of this theorem) and is I-bipartite. \(\square \)

To find the time to termination in general graphs we need to find a bound on when nodes can belong to a round-set for the second time. As nodes can only belong to at most two round-sets, by Theorem 2.1, this will give a bound for termination of flooding in general graphs. The following lemma shows that nodes adjacent to a node receiving the message for the second time will receive the message for the second time in an adjacent round.

Lemma 3.5

Let (GE) be a graph and \(I \subseteq G\) a set of initial nodes. If \(h \in G\) and \(h^2 \in R_j\) for some \(j \ge 1\), and if g is a neighbour of h, then

$$\begin{aligned} g^2 \in R_{j-1} \;\; { or} \;\; g^2 \in R_{j} \;\; { or} \;\; g^2 \in R_{j+1} \end{aligned}$$

Proof

Let i be the distance of h from I, i.e. \(h \in D_i\). Then, as \(h^2 \in R_j\), \(j>i\) by Lemma 3.1 (i). As g is a neighbour of h, \(g \in D_{i}\) or \(g \in D_{i-1}\) or \(g \in D_{i+1}\).

Case \(g \in D_i\).

As \(h,g \in D_i\) are neighbours they are both ec-nodes. Thus, by Lemma 3.1 (iii), \(h^2 \in R_{i+1}\) and \(g^2 \in R_{i+1}\). Therefore, \(j = i+1\) and \(g^2 \in R_j\).

Case \(g \in D_{i-1}\).

If \(g \in R_j\) which is a later round-set than \(R_{i-1}\) as \( j>i\) then, as \(g^1 \in D_{i-1} \subseteq R_{i-1}\) by Lemma 3.1 (i) is in the earlier round-set \(R_{i-1}\), it must be the case that \(g^2\) rather than \(g^1\) belongs to \(R_j\). If \(g\notin R_j\) and \(g^2 \notin R_{j-1}\) then \(g \notin R_{j-1}\) as we know that \(g^1 \in R_{i-1}\) which is an earlier round-set than \(R_{j-1}\) as \(j>i\). As \(h \in R_j\), h sends to g in round \(j+1\) and so \(g \in R_{j+1}\) which is a later round-set than \(R_{i-1}\) as \( j>i\). As \(g^1 \in R_{i-1}\), it must be the case that \(g^2 \in R_{j+1}\).

Case \(g \in D_{i+1}\), g does not send to h in round j.

In this case, as \(h \in R_j\), h sends to g in round \(j+1\). Thus, \(g \in R_{j+1}\) which is a later round-set than \(R_{i+1}\) as \( j>i\) and therefore, as \(g^1 \in D_{i+1} \subseteq R_{i+1}\) by Lemma 3.1 (i), it must be the case that \(g^2 \in R_{j+1}\).

Case \(g \in D_{i+1}\), g sends to h in round j.

In this case \(g \in R_{j-1}\). We show that \(g^1 \notin R_{j-1}\). Assume, on the contrary, that \(g^1 \in R_{j-1}\). Then, by Lemma 3.1 (i), \(g^1 \in D_{i+1} \subseteq R_{i+1}\) and thus \(j-1 = i+1\). Hence, by Lemma 3.1 (i), \(h^1 \in D_i \subseteq R_i = R_{j-2}\). Also, \(g \notin R_{j-3}\) as \(g^1 \in R_{j-1}\). To summarize:

$$\begin{aligned} g \notin R_{j-3},\;\; h^1 \in R_{j-2},\;\; g^1 \in R_{j-1},\;\; h^2 \in R_j \end{aligned}$$

So, h sends to g in round \(j-1\) and g sends to h in round j by the case assumption. This is a contradiction. Thus, the assumption that \(g^1 \in R_{j-1}\) is false and, as \(g\in R_{j-1}\), it follows that \(g^2 \in R_{j-1}\). This completes the proof. \(\square \)

Corollary 3.6

Let (GE) be a graph and \(I \subseteq G\) be a set of initial nodes. Then (GE) has an ec-node if and only if all nodes are in exactly two round-sets.

Proof

Follows from Lemmas 3.2 and 3.5. \(\square \)

We can now give bounds for time to termination of flooding for graphs that have ec-nodes.

Theorem 3.7

Let (GE) be a graph that is not I-bipartite and let d be the diameter. Then, flooding terminates in round j where j is in the range

$$\begin{aligned} e(I) < j \le e(I)+d+1. \end{aligned}$$
(9)

Proof

To show (9), we show that flooding terminates in round j where

$$\begin{aligned} e(I) < j \le { min} \{ \delta (I, g_{ec}) + d +1 \; : \; g_{ec} \in G_{ec} \}. \end{aligned}$$
(10)

If (GE) is not I-bipartite it has an ec-node \(g_{ec}\), by Definition 4 (iv). By Lemma 3.1 (iii), \(g_{ec}^2 \in R_k\) where \(k = \delta (I,g_{ec}) +1\). Let h be an arbitrary node in G other than \(g_{ec}\). Then, there is a path

$$\begin{aligned} h_0=g_{ec} \longrightarrow h_1 \longrightarrow \ldots \longrightarrow h_l = h \end{aligned}$$

where \(l \le d\). By repeated use of Lemma 3.5,

$$\begin{aligned} \begin{array}{lll} h_1^2 \in R_{j_1} &{} { where} &{} k-1 \le j_1 \le k+1, \\ h_2^2 \in R_{j_2} &{} { where} &{} j_1-1 \le j_2 \le j_1+1, \\ \ldots &{} \; &{} \; \\ h_l^2 \in R_{j_l} &{} { where} &{} j_{l-1}-1 \le j_l \le j_{l-1}+1. \\ \end{array} \end{aligned}$$

Thus,

$$\begin{aligned} h^2_l \in R_{j_l} \;\;\; { where} \;\;\; k-l \le j_l \le k+l \end{aligned}$$
(11)

Put \(j = j_l\). From (11), as \(k = \delta (I,g_{ec}) +1 \) and as \(l \le d\),

$$\begin{aligned} h^2_l \in R_{j} \;\;\; { where} \;\;\;j \le \delta (I, g_{ec}) + d +1 \end{aligned}$$

and, as \(g_{ec}\) is any ec-node,

$$\begin{aligned} h^2_l \in R_{j} \;\;\; { where} \;\;\;j \le { min}\{ \delta (I, g_{ec}) + d +1 \} \end{aligned}$$

As (GE) is not I-bipartite, \(j>e(I)\) by Theorem 3.4 and so (10) holds. Then, (9) follows from (10) easily as \(\delta (I, g_{ec}) \le e(I)\) by Definition 4 (iii). \(\square \)

Figure 2 shows that the bounds are sharp. Sharpness of the upper bound is shown by the graph on the left in which \(I=\{ g_0\}\), there are \(k-1\) nodes between \(g_0\) and \(g_k\), \(k-2\) nodes between \(g'_1\) and \(g'_k\) and between \(g''_1\) and \(g''_k\). The graph terminates in \(3k+1=k+2k+1=e(I)+d+1\) rounds for all \(k \ge 1\). The slightly more complicated graph on the right in which \(I=\{ g_0\}\), there are \(k-1\) nodes between \(h_0\) and \(h_k\), \(h'_0\) and \(h'_k\), \(g_0\) and \(g_k\) and between \(g_0\) and \(g'_k\), demonstrates sharpness of the lower bound and shows that flooding can terminate in a non-bipartite graph before round d. For all \(k \ge 1\), \(e(I)=2k+2\), \(d=3k+3\) and flooding terminates in \(2k+3\) rounds and so \(e(I)+1 = 2k+3 < d\).

Fig. 2
figure 2

Sharpness of bounds

Theorem 3.8

Let (GE) be a graph and \(I \subseteq G\) be a set of initial nodes such that every node in I has a neighbour in I. Then, flooding terminates in round \(e(I)+1\).

Proof

As all nodes in I have neighbours in I they are all ec-nodes. Let h be an arbitrary node in G. Then, by Definition 4 (iii), there is a path

$$\begin{aligned} h_0=g_{ec} \longrightarrow h_1 \longrightarrow \ldots \longrightarrow h_l = h, \end{aligned}$$
(12)

where \( 0 \le l \le e(I)\), from some node \(g_{ec} \in I\) to h. By Lemma 3.1 (iii), \(g_{ec}^2 \in R_k\) where \(k= \delta (I, g_{ec}) +1 = 0+1=1\). By repeated use of Lemma 3.5, arguing as in Theorem 3.7 putting \(k=1\) in (11), we have that

$$\begin{aligned} h^2 = h^2_l \in R_{j_l} \;\;\; { where} \;\;\; j_l \le k+l \le 1+ e(I). \end{aligned}$$
(13)

Thus, termination occurs in round \(e(I)+1\) at the latest. If h is a node that is a distance e(I) from I, \(h^1 \in R_{e(I)}\) and so we can infer from (13) that \(h^2 \in R_{e(I)+1}\). It follows that termination occurs in round \(e(I)+1\) precisely. \(\square \)

The condition that all nodes in I have neighbours in I, in Theorem 3.8, for termination in the lower bound (for non I-bipartite graphs) number of rounds \(e(I)+1\) is useful for identifying possible examples of interest such as when the subgraph induced by I is connected. Whilst sufficient, the condition is not necessary. In the graph on the left in Fig. 3, \(I=\{g_0,g_{2k},h_0\}\) and there are \(2k-1\) nodes between \(g_0\) and \(g_{2k}\) and \(h_0\) and \(h_{2k}\). Clearly, \(g_{2k}\) does not have a neighbour in I yet flooding terminates in \(2k+1 = e(I)+1\) rounds for all \(k \ge 1\). However, relaxing the connectedness condition to I only having a pair of neighbouring nodes is not, in general, sufficient for round \(e(I)+1\) termination. The graph on the right in Fig. 3 has \(I = \{ h_0, h_1, g_0 \}\) and 2k nodes between \(g_0\) and \(g_{2k+1}\). Flooding terminates in round \(2k+3\), but \(e(I)+1 = (k+1)+1 =k+2\) for all \(k \ge 0\).

Fig. 3
figure 3

Conditions for round \(e(I)+1\) termination

The clear separation in the termination times of bipartite and non-bipartite graphs, in the case of a single initial node, does not carry over directly to the general case of multiple initial nodes. For the general case, it is the presence or otherwise of ec-nodes that is the distinguishing property and we have defined I-bipartite graphs for this purpose. Unlike the single node case, having ec-nodes or not in the multiple initial node case cuts across the bipartite/non-bipartite boundary, i.e. I-bipartite graphs may not be bipartite and bipartite graphs may not be I-bipartite. The work on the k-flooding problem in [32], looking at finding a set of sources of size k that minimizes termination time, offers a different perspective on amnesiac flooding termination times.

4 Loss of edges and delays at edges

4.1 Loss of edges

In the case where edges and nodes are lost during flooding, a message transiting along an edge may never arrive at its target node. The termination result Theorems 2.1 assumes that the graph (GE) is fixed. Termination still holds if the graph loses edges and nodes.

Theorem 4.1

Suppose that

$$\begin{aligned}{} & {} (G_0,E_0), (G_1,E_1), \ldots , (G_i, E_i) , (G_{i+1}, E_{i+1}), \ldots \nonumber \\{} & {} \quad { where} \;\; G_i \supseteq G_{i+1}, E_i \supseteq E_{i+1} \; \textit{for all i} \ge 0. \end{aligned}$$
(14)

is a sequence of graphs where nodes or edges may be lost over time expressed in terms of rounds. If \(I \subseteq G_0\) is a set of initial nodes from which flooding is initiated in round 0 and progresses in subsequent rounds along the operational nodes and edges, and round-sets are defined as in Definition 2, then any node \(g \in G_0\) is contained in at most two distinct round-sets.

Proof

The proof of Theorem 2.1 for fixed (GE) assumes the contrary of the theorem, and infers a contradiction by examining a node in a round-set which had an occurrence in a previous round-set. The proof requires that the edges present in the later round were present in the earlier round. So, the proof of Theorem 2.1 is also valid for the case that edges are lost, i.e.

$$\begin{aligned}{} & {} (G,E_0), (G,E_1), \ldots , (G, E_i) , (G, E_{i+1}), \ldots \\{} & {} \quad { where} \;\; E_0 \supseteq E_1 \supseteq \ldots \supseteq E_i \supseteq E_{i+1} \supseteq \ldots \end{aligned}$$

Allowing loss of nodes follows easily. Given a graph \((G,E_i)\) and a node \(g \in G_i\), let \(E_i^g\) be the edges in \(E_i\) not incident with g. Then, \((G\setminus \{g \},E_i^g)\) is the subgraph of \((G,E_i)\) induced by the subset of nodes \(G\setminus \{g \}\) and \((G, E_i^g)\) is the subgraph of \((G,E_i)\) in which g is isolated, i.e. with the same nodes as \((G,E_i)\) but with edges incident with g removed. Clearly, flooding terminates on the sequence of graphs with monotonically decreasing sets of edges:

$$\begin{aligned} (G,E_0), (G,E_1), \ldots , (G, E_i^g) , (G,E_{i+1}^g), \ldots \end{aligned}$$

if and only if it terminates on the sequence of graphs where the isolated g is removed:

$$\begin{aligned} (G,E_0), (G,E_1), \ldots , (G\setminus \{ g \}, E_i^g) , (G \setminus \{g \} ,E_{i+1}^g), \ldots \end{aligned}$$

It follows, by inductively removing multiple nodes that become isolated, that flooding terminates on any sequence of graphs of the form (14). \(\square \)

It is worth noting that the proof of Theorem 4.1 does not require the graph to remain connected, so flooding terminates in all parts of the graph if edge loss results in a graph that becomes disconnected. Of course, in that case, some parts of the graph may not receive the message at all.

4.2 Fixed delays at edges

Here, we consider cases when messages take a fixed number of rounds greater than 1 to transit an edge. Flooding proceeds with respect to a global clock, the non-negative integer ticks of which define rounds. Flooding is initiated in round 1 when initial nodes send to all neighbours. Message transit time is given in terms of the number of ticks of the clock taken. Such flooding does not correspond to single-round message transit simply by adding nodes to an edge. Consider the example in Fig. 4 below. We have weighted graphs with edges labelled by positive integers representing a fixed message transit time in both directions. The graph on the left has message transit along edge \(\{ g_1,g_2 \}\) taking 2 rounds. The graph on the right adds a node \(g_3\) along \(\{ g_1,g_2 \}\) so that all edges have message transit time of 1 round. The behaviour of flooding in the two graphs is different - the graph on the left terminates in 4 rounds whereas the graph on the right terminates in 2. A more substantial example below shows that message transit of more than one round along an edge may lead to non-termination of flooding. In Fig. 5 arrowheads at nodes indicate a message being received at a node. Arrowheads not at nodes (as in round 4 of Fig. 5) indicate messages in transit. The arrowheaded graph in a round, which we refer to as the ‘flooding state’, determines how flooding proceeds. As the flooding states in rounds 3 and 8 are identical, flooding does not terminate. The graph in Fig. 5 is not bipartite. Figure 6 gives an example of a bipartite graph with delays at edges, over which flooding does not terminate. In the example, which has two edges with delays, it can be checked that the flooding states for rounds 5 and 13 are identical and so flooding does not terminate. If there is only one initial node and a delay at a single edge in bipartite graphs, flooding does terminate.

Fig. 4
figure 4

Edge delay and additional nodes

Fig. 5
figure 5

Non-termination of flooding with fixed edge delays

Fig. 6
figure 6

Non-terminating fixed-delay bipartite example

Definition 5

Let (GE) be an edge-weighted graph, \(g_0 \in G\) be an initial node, \(e = \{ x,y \} \in E\) be an edge with weight \(\tau \) where \(\tau \) is an integer greater than 1 and let all other edges be of weight 1. Then, the graph \((G^+,E^+)\) is obtained from (GE) by adding \(\tau - 1\) ticks along e as nodes, i.e.

$$\begin{aligned}{} & {} G^+ = G \cup \{ t_1, \ldots , t_{\tau -1} \}, \\{} & {} E^+ = (E\setminus \{x, y \}) \cup \{ \{ x,t^1 \}, \{ t^1 , t^2 \} , \ldots , \{ t^{\tau -1} , y \} \}. \end{aligned}$$

So, \((G^+,E^+)\) has all edges of duration 1. The distance function of \((G^+,E^+)\) is denoted \(\delta ^+\). If \(g,g' \in G^+\), clearly \(\delta ^+(g,g') \le \delta (g,g') + \tau -1\), where \(\delta \) is the distance function of the unweighted version of (GE). Thus, the diameter \(d^+\) of \((G^+,E^+)\) is at most \(d+\tau -1,\) where d is the diameter of unweighted (GE).

Fig. 7
figure 7

Odd-delay edge e transited in one direction

Fig. 8
figure 8

Odd-delay edge e transited in both directions

Theorem 4.2

Let (GE) be a bipartite graph, \(g_0 \in G\) be an initial node, \(e = \{ x,y \} \in E\) be an edge, and \(\tau \) be an integer greater than 1. Then flooding initiated from \(g_0\), in which a message in transit along e takes \(\tau \) rounds and 1 round along any other edge, visits every node at most twice and completes in not more than \(2d+\tau -1\) rounds where d is the diameter of (GE).

Proof

We distinguish two cases according to whether \(\tau \) is odd or even. In the figures below hollow points signify tick nodes in \((G^+,E^+)\) corresponding to ticks of the global clock as the message travels along e.

\(\tau \) odd.

Firstly, suppose that the message arrives at the node at one end of e and travels along e for an odd number of rounds without encountering the message travelling in the opposite direction as depicted in Fig. 7. Flooding corresponds to normal flooding over the bipartite graph \((G^+,E^+)\) obtained from (GE) as in Definition 5, where every node is visited once. The only difference with flooding where messages take one round to transit e is that the message transit along e takes an extra \(\tau -1\) rounds and so the time to termination may increase from a maximum of d rounds for the bipartite (GE) with normal transit at e to \(d+\tau -1\) which is less than the bound \(2d+\tau -1\) in the theorem statement. Secondly, suppose that messages pass both of the end nodes of e travelling in opposite directions and meet along e. The difference in the round numbers that the message arrives for the first time at x and at y to continue along e, is clearly odd as x and y are in different partite sets in the bipartite (GE). Thus, the opposing messages arrive at a tick node t along e for the first time in the same round as in Fig. 8. In Fig. 8, the messages passes both of the end nodes of e travelling in opposite directions, ‘meet’ at a tick t in round 3 but then continue along their journeys in their respective directions. Thus, a tick node t behaves like an ordinary additional node, except when messages travelling in opposite directions meet at t. We call such a t in \((G^+,E^+)\) a sink-tick node. If t was an ordinary node then, as it receives messages from both neighbours, the messages would go no further. If t is a sink-tick node we need it to reflood the message. So, if \(\tau \) is odd, we can simulate flooding over (GE) as a flooding over \((G^+,E^+)\) in which any sink-tick node t refloods the message to its neighbours on receiving the message. Then, if the first flooding emanating from a sink-tick node t does not interact with the flooding emanating directly from \(g_0\), flooding over (GE) corresponds to two floodings over \((G^+,E^+)\) - that initiated from \(g_0\) and that initiated from t. As \((G^+,E^+)\) is bipartite each of these two floodings visits a node once and terminates, and so flooding over (GE) delivers the message to each node twice. So, it suffices to show that the flooding over \((G^+,E^+)\) initiated from \(g_0\) does not interact with the reflooding from a sink-tick node t.

Let j be the round that the flooding from \(g_0\) first reaches a sink-tick node \(t^i\), where \(1 \le i \le \tau -1\), and assume, on the contrary, that \( k > j\) is the first round that the reflooding from \(t_i\) interacts with the flooding from \(g_0\). Then, there are two sequences of sends of the message from \(g_0\) and \(t_i\) respectively

$$\begin{aligned} g_0 \rightarrow g_1 \rightarrow \ldots \rightarrow g_k \end{aligned}$$
(15)

and

$$\begin{aligned} g_0 \rightarrow h_1 \rightarrow \ldots \rightarrow h_{j-1} \rightarrow h_j \rightarrow h_{j+1} \rightarrow \ldots \rightarrow h_k \end{aligned}$$
(16)

where \(g_k=h_k\), subscripts indicate the round a node receives a message and in (16) \(h_j =t^i\) refloods. We note that in (15) none of the nodes \(g_j , \ldots , g_k\) can be a tick node as flooding from \(g_0\) of the bipartite \((G^+,E^+)\) will only visit each node once (by Lemmas 3.2 and 3.3) and the tick nodes are visited earlier before the first visit of the sink-tick node. On the other hand, the reflooding from \(h_j\) in (16) visits tick nodes until it reaches either x or y, say x occurs after \(h_j\). One of x or y must also occur before \(h_j\). We can choose the sequence \(g_0 \rightarrow \ldots \rightarrow h_{j-1}\) such that it has x, i.e.

$$\begin{aligned}{} & {} g_0 \rightarrow \ldots \rightarrow h_{l_1}=x \rightarrow \ldots \rightarrow h_j=t^i \rightarrow \ldots \nonumber \\{} & {} \quad \rightarrow h_{l_2}=x \rightarrow \ldots \rightarrow h_k \;\;\; (0< l_1< j< l_2 < k) \end{aligned}$$
(17)

From (17), \(\delta ^+(g_0, g_k) = \delta ^+ (g_0,h_k) \le k-(l_2-l_1) < k\), where \(\delta ^+\) is the graph distance function of \((G^+,E^+)\). But, \((G^+,E^+)\) is bipartite and flooding from \(g_0\) only visits nodes once and so \(\delta ^+ (g_0,g_k) = k\) by Lemma 3.1 (i) and (15). This contradiction means that the flooding from \(g_0\) does not interact with the reflooding from \(t^i\) and so the net effect is two separate floodings of the bipartite \((G^+ ,E^+)\) each of which visits every node once and terminates. The first flooding from \(g_0\) on the bipartite \((G^+,E^+)\) takes not more than the diameter of \((G^+,E^+)\) number of rounds, \(d -1+ \tau \le 2d+\tau -1\). The reflooding from the sink-tick \(t^i\) starts after \(t^i\) is reached by the first flooding from \(g_0\), which is after at most \(d+(\tau +1)/2 -1\) rounds, and then takes at most the same number of rounds to reach every node in \(G^+\), thus terminating by round \(2(d+(\tau +1)/2 -1)= 2d+ \tau -1\). Therefore, the theorem holds for odd \(\tau \).

\(\tau \) even.

Fig. 9
figure 9

Even-delay edge e transited in both directions

Here, if messages pass both of the end nodes of e travelling in opposite directions, as depicted in Fig. 9, they do not meet. Thus, tick nodes in \((G^+,E^+)\) act like normal nodes and flooding terminates in the time it takes for \((G^+,E^+)\) to terminate. If no cycle in (GE) contains e, then (GE) is two disjoint subgraphs induced by \(G_x \subseteq G\) and \(G_y \subseteq G\) of G, where \(G= G_x \cup G_y\), \(x \in G_x\), \(y \in G_y\) and \(G_x \cap G_y = \emptyset \), connected by e. The addition of \(\tau -1\) tick nodes along edge e gives a bipartite graph \((G^+,E^+)\) where the partite sets of one of \(G_x\) or \(G_y\) are reversed. Flooding visits each node once in the bipartite \((G^+,E^+)\) and terminates by round \(d+\tau -1\).

If a cycle in (GE) does contain e, let \(g_t\) be any node in (GE) and let t also denote the round that \(g_t\) receives the message for a second time. We show that \(t \le 2d+\tau -1\). Let C be a cycle in (GE) containing x and y that is of smallest length. First of all, we construct a cycle \(C_{g_t}\) which contains x, y, \(g_t\) and is of length at most 2d in (GE). Suppose that the cycle C is oriented in a clockwise fashion thus:

$$\begin{aligned} C= c_0(=x) \rightarrow c_1(=y) \rightarrow \ldots \rightarrow c_m \rightarrow c_0 \end{aligned}$$

and that \(\delta (x,g_t) \le \delta (y,g_t)\). Let

$$\begin{aligned} \underline{p_1} = x \rightarrow u_1 \rightarrow \ldots \rightarrow u_k \rightarrow g_t \;\;\; (k \ge 0) \end{aligned}$$

be shortest path from x to \(g_t\) in (GE). Consider, in turn, the shortest path from each of the nodes \(c_1\), \(c_2\), \(\ldots \) to \(g_t\). For some of these the shortest path to \(g_t\) may be anticlockwise along C back to \(x=c_0\) and then along the shortest path \(\underline{p_1}\) from x to \(g_t\). Choose the least i with \(1 \le i \le m-1\) which has its own shortest path (possibly clockwise along C) \(\underline{p_2}\) to \(g_t\)

$$\begin{aligned} \underline{p_2} = c_i \rightarrow v_1 \rightarrow \ldots \rightarrow v_l \rightarrow g_t \;\;\; (l \ge 0, v_1 \ne c_{i-1}) \end{aligned}$$

The cycle \(C_{g_t}\) is then defined as the path \(\underline{p_1}\) backwards from \(g_t\) to x followed by the arc of C clockwise from \(x=c_0\) to \(c_i\) and then followed by the path \(\underline{p_2}\) back to \(g_0\). (It is possible that the paths \(\underline{p_1}\) and \(\underline{p_2}\) converge to the same node earlier than \(g_t\) in which case \(C_{g_t}\) will be a closed walk, starting at \(g_t\) and returning to \(g_t\) after tracing all the paths, which is comprised of a cycle with a path attached from the cycle to \(g_t\).) As the path from \(c_{i-1}\) to \(c_0=x\) anticlockwise along C and then along \(p_1\) to \(g_t\) is a shortest path from \(c_{i-1}\) to \(g_t\), it follows that this path is of length \(\le d\). The path \(\underline{p}_2\) from \(c_i\) to \(g_t\) is \(\le d\). The nodes \(c_{i-1}\) and \(c_i\) are neighbours. Thus, the length of \(G_{g_t}\) in (GE) is at most \(d+d+1\). As (GE) is bipartite the length of \(C_{g_t}\) is \(\le 2d\). So, \(C_{g_t}\) contains x, y, \(g_t\) and is of length at most 2d in (GE). Therefore, in \((G^+,E^+)\),

$$\begin{aligned}{} & {} C_{g_t} \; \textit{contains neighbouring ec-nodes}\ g_{ec} \; { and}\; h_{ec}\nonumber \\{} & {} \quad \textit{and is of length} \le 2d+\tau -1 \end{aligned}$$
(18)

By (18) we now construct a cycle \(C_{g_0}\) from two sequences of sent messages \(\underline{s}_1\) and \(\underline{s}_2\):

$$\begin{aligned}{} & {} \underline{s}_1 = w_0(=g_0) \rightarrow w_1 \rightarrow \ldots w_r (= g_{ec}) \rightarrow w_{r+1}(=h_{ec}) \\{} & {} \underline{s}_2 = z_0(=g_0) \rightarrow z_1 \rightarrow \ldots z_r(= h_{ec}) \rightarrow z_{r+1}(=g_{ec}) \end{aligned}$$

and define the direction along the cycle to be clockwise if \(g_{ec}\) is visited before \(h_{ec}\). Let \(w=w_j\) and \(z=z_j\) be nodes in \(\underline{s}_1\) and \(\underline{s}_2\) respectively that belong to \(C_{g_t}\) such that all nodes after w in \(\underline{s_1}\) and z in \(\underline{s_2}\) belong to \(C_{g_t}\). Clearly, \(C_{g_0}\) is a cycle (closed walk if \(w=z\)) of length at most 2d in (GE) and \(2d+\tau -1\) in \((G^+,E^+)\). Now, in order to show that there is a sequence of sends that deliver the message for a second time to \(g_t\) no later than round \(2d+ \tau -1\), by Theorem 3.7 it suffices to find a path from \(g_0\) to \(g_t\) that visits neighbouring ec-nodes and is of length less than or equal to \(2d+\tau -1\). There are two cases to consider:

\((i)\;g_t\) is nearer to \(g_{ec}\) than to \(h_{ec}\). The two left-hand figures in Fig. 10 depict two possible subcases where \(g_t\) is between z and w and where it is not. If \(g_t\) is between z and w, an anticlockwise path from \(g_0\) along \(C_{g_0}\) past \(h_{ec}\) and \(g_{ec}\) up to w and then along \(C_{g_t}\) until \(g_t\) is reached is a path of length less than or equal to the maximum length of one revolution of either of the cycles \(C_{g_0}\) or \(C_{g_t}\) which is less than or equal to \(2d+\tau -1\). This is because the arc that is not traversed of the larger cycle results in a corresponding smaller arc of the smaller cycle to be traversed. (Fig. 10 suggests \(C_{g_0}\) is larger than \(C_{g_t}\) but it could be drawn the other way around.) If \(g_t\) is not between z and w then an anticlockwise path from \(g_0\) along \(C_{g_0}\) past \(h_{ec}\) and \(g_{ec}\) up to \(g_t\) suffices.

\((ii)\;g_t\) is nearer to \(h_{ec}\) than to \(g_{ec}\). This case is a mirror image of (i) with clockwise instead of anticlockwise paths being used. The right-hand figures in Fig. 10 illustrate this. \(\square \)

Fig. 10
figure 10

Even-delay edge e termination time bound

The \(2d+\tau -1\) bound in Theorem 4.2 is sharp for general bipartite graphs, as the example in Fig. 11 has, for all \(k_1,k_2 \ge 2\), \(k_2\) even, \(d=k_1\), \(\tau =k_2\) and termination occurs in round \(2d+\tau -1=2k_1+k_2-1\).

Fig. 11
figure 11

Sharpness of Theorem 4.2 bound

Theorem 4.2 restricts flooding to one initial node and one delaying edge. However, if (GE) is a cycle (not necessarily bipartite), then flooding terminates with any number of initial nodes and delaying edges.

Theorem 4.3

Let (GE) be an edge-weighted cycle in which (possibly different) positive integer edge weights represent duration of message transit in rounds along edges and \(I \subseteq G\) be a set of initial nodes. Then, flooding initiated from initial nodes in I terminates in not more than the weight \(\sigma \) of (GE) number of rounds, where the weight \(\sigma \) of (GE) is the sum of the weights of the edges.

Proof

Let \((G^+,E^+)\) be the cycle obtained from (GE) by adding tick nodes along all edges of greater weight than 1 in a similar way to Definition 5. Denote successive vertices of \(G^+\), starting at an arbitrary vertex in I, by the integers \(\{ 0, \ldots , \sigma -1 \}\), where \(\sigma \) is the weight of the the cycle (GE), so that \(G^+= G \cup T\) where T is the set of tick nodes. We will assume throughout that arithmetic is modulo \(\sigma \) and say that a message sent from \(v \in G^+\) to \(v+1 \in G^+\) is clockwise, and one sent from \(v \in G^+\) to \(v-1 \in G^+\) is anticlockwise. Each initial node \(v \in I\) will generate a sequence of sends of the message in clockwise and anticlockwise directions:

$$\begin{aligned} v \rightarrow v+1 \rightarrow \ldots , \;\;\;\;\; v \rightarrow v-1 \rightarrow \ldots \end{aligned}$$

either of which may terminate if they encounter a sequence in the opposite direction at a node in G in some round. Any sequence of sent messages is defined by an initial node and a direction. For \( v \in I\), we define positively and negatively decorated versions, \(v^+\) and \(v^-\) respectively, of v and, correspondingly, positively and negatively decorated versions of subsets \(S \subseteq I\):

$$\begin{aligned} S^+ = \{ v^+ \; : \; v \in S \} , \;\; S^- = \{ v^- \; : \; v \in S \} \end{aligned}$$

Define a relation \(\sim \) on I by:

$$\begin{aligned} v \sim w \; \textit{iff} \;\; \exists m . \; v+m = w-m \;\wedge \; v+m \in G \end{aligned}$$
(19)

for \(v, w \in I\). Intuitively, \(v \sim w\) means that the clockwise sequence of sends from v and the anticlockwise sequence from w can terminate each other at some node in G if neither has been terminated earlier. Note that \(\sim \) is symmetric because if \(v \sim w \) then \(v+m=w-m\) as in (19) and thus \(w+(\sigma -m) = w-m =v+m (\in G) = v-(\sigma -m)\) and so \(w \sim v\). It is clearly reflexive as \(v+m=w-m\) implies \(w+(-m)=v-(-m)\). Also, if \(v \sim w \) and \(w \sim z\) then there exist \(m',m''\) such that \(v+m'=w-m'\) and \(w+m''=z-m''\). Thus, \(v+(m'+m'') = z-(m'+m'')\) and so \(v \sim z\) and therefore \(\sim \) is transitive. As such, \(\sim \) defines an equivalence relation on I whose set of equivalence classes we denote by \({\mathcal {I}}\).

Next, we define \(Q_i\) for \(i \ge 0\):

$$\begin{aligned} Q_i&= \{ v^+ \; : \; v \in I \; \wedge \; v \rightarrow v + 1 \rightarrow \ldots \rightarrow v+i \}\\&\cup \; \{ v^- \; : \; v \in I \; \wedge \; v \rightarrow v - 1 \rightarrow \ldots \rightarrow v-i \} \end{aligned}$$

to be the set of the positive (versions of) initial nodes from which the clockwise sequence of sent messages hasn’t terminated before round i, along with the negative (versions of) initial nodes from which the anticlockwise sequence of sent messages has not terminated. Clearly, \(Q_{i+1} \subseteq Q_{i}\). Note that, \(Q_i\) may have neither, one or both versions of a particular initial node depending on whether the corresponding oriented sequences of sent messages has terminated by round i. However, as clockwise and anticlockwise sequences are always terminated in pairs and correspond to initial nodes that may be different but do belong to the same equivalence class \(S \in {\mathcal {I}}\), the number of positive initial nodes in \(Q_i\) that belongs to S is equal to the number of negative initial nodes, i.e.

$$\begin{aligned} \forall i \ge 0 \; \forall S \in {\mathcal {I}} . \; |S^+ \cap Q_i |= |S^- \cap Q_i |\end{aligned}$$
(20)

We now prove that flooding terminates by assuming that flooding does not terminate and show that this leads to a contradiction. If flooding does not terminate, flooding yields a, clockwise say, sequence of sends:

$$\begin{aligned} v\rightarrow v+1 \rightarrow \ldots \rightarrow v+\sigma (=v) \end{aligned}$$
(21)

that is not terminated in round \(\sigma \) so that \(v^+ \in Q_{\sigma }\). By (20), there must be a \(w^- \in Q_{\sigma }\) such that v and w are in the same equivalence class S, i.e. \(v \sim w\). It follows, by the definition of \(\sim \) in (19), that flooding also yields sequences of sends:

$$\begin{aligned} v\rightarrow v+1 \rightarrow \ldots \rightarrow v+m , \;\; w\rightarrow w-1 \rightarrow \ldots \rightarrow w-m, \end{aligned}$$
(22)

where \(m \le \sigma \) and \(v+m =w-m\) and \(v+m \in G\). Clearly, the m in (22) must equal \(\sigma \), else if \(m<\sigma \) the clockwise sequence from v is terminated by the anticlockwise sequence from w in round m which is earlier than round \(\sigma \) and so flooding would not have yielded sequence (21). On the other hand, if \(m=\sigma \), then, by (22), clockwise flooding from v is terminated in round \(\sigma \), contrary to our assumption. This contradiction proves termination occurs by round \(\sigma \), where \(\sigma \) is the weight of the graph (GE). \(\square \)

4.3 Varying delays at edges

In a general asynchronous model, where the delay of message transit along an edge may vary during the flooding process, termination is not guaranteed even on the smallest cycle. Our example is of non-termination over the triangle graph where an adaptive adversary at a node produces an infinite sequence of delays at the right times so as to prevent termination. The adaptive adversary is used just as an example and non-termination over cycles can arise for any number of different reasons. Consider the triangle graph in Fig. 12, in which computation proceeds with respect to a global clock whose integer ticks are the rounds and the adversary can decide the delay of message delivery on any edge in any round. In round 0, b has the message as the initial node which is then flooded. Figure 12 illustrates rounds 1-5. Both a and c send the message to each other in round 2. In round 3, a sends the message to b but the adversary makes c hold the message for one round, indicated by a circled node. After that, in round 4, b and c send the message to each other. In any given round, the corresponding arrowheaded graph determines in which ways flooding can proceed. As the arrowheaded graphs in rounds 2 and 4 are equivalent (by a relation- and adversary-preserving automorphism), flooding can proceed from round 4 in a similar way as from round 2 with the edges b and a interchanged and the adversary acting on node c as before. The repeated adversarial intervention prevents flooding from terminating.

Fig. 12
figure 12

Varying delays at edges non-termination

5 Conclusion

It was previously thought that the stateless version of the terminating stateful synchronous flooding algorithm does not terminate in general. We have proved that it does terminate on all graphs and in optimal time. Thus, this amnesiac flooding achieves broadcast and can be used to set up spanning trees like stateful flooding in almost the same time without the additional overhead of storing every message required to achieve termination explicitly. Our work has shown that there is a clear separation of the times to termination, corresponding to whether the message is received once or twice by all nodes, in turn depending on whether the (quotient with respect to the set of sources) graph is bipartite or non-bipartite. This raises the question of whether this separation can be exploited to devise distributed procedures to detect the topology of a graph given distance measures or vice versa. If an upper bound D on the diameter d is known, a simple distributed algorithm at nodes to determine whether the network graph is bipartite is for the issuing source node to wait 2D+1 rounds to see if the message returns. It might also seem that, conversely, if the graph is known to be bipartite, a distributed algorithm for determining a bound for the diameter d is possible given that amnesiac flooding terminates in 2d+1 bounds - a node might measure the time it takes for the message to return. However, there are a number of problems to be overcome. If the graph is bipartite then, for the message to be returned to the source, the message has to be reflooded from ‘sink’ nodes which receive the message on all edges in a single round. This would result in the message possibly being returned to the issuing source node any number of times. Even if the graph is non-bipartite and a single return of the message is guaranteed, the issuing node may receive the message very early on, because of the proximity of an ec-node, and thereby underestimate d.

When the overhead of storing messages is not a problem, the main use of amnesiac flooding may be as a process that is known to terminate in 2d+1 rounds which can be used with state in distributed algorithms to obtain the diameter.

Open Problem 1. Can the diameter of a graph be obtained/approximated by a distributed algorithm that uses amnesiac flooding along with a limited amount of state recording certain events?

The basic termination result for amnesiac flooding is significant for its applicability to arbitrary graphs with unknown diameters and network topologies. For common known bipartite topologies such as hypercubes and star networks termination is clear and the result has less significance, unless messages take different times to transit along different links. In the presence of delays even stateful flooding is problematic as, although the diameter is known, it is not clear how long messages should be stored. To this end, we have looked at the termination problem when message transit along an edge takes more than one round and found that if there is a delay at only one edge in bipartite graphs then amnesiac flooding terminates but not in non-bipartite graphs. This means that if delays at edges do not occur often, and it is unlikely that there are delays at two edges during a flooding, then termination will follow in bipartite graphs. Our result is for a single source. The multi-source case is open.

Open Problem 2. Does amnesiac flooding from multiple sources on a bipartite graph, where there is a fixed time of message transit greater than one round along a single edge, terminate?

What if there can be delays at more than one edge but that delays are short-lived? The example in Fig. 5 terminates if the message transit time along an edge with a delay returns to normal once the edge becomes clear of messages for the first time.

Open Problem 3. For which class of bipartite graphs, with fixed-delays at multiple edges, does amnesiac flooding from a single source terminate if the message transit time along an edge with a delay returns to normal once the edge becomes clear of messages for the first time?

Our example with delays at edges have assumed that the delayed transit time is in both directions. Even in the non-bipartite example of Fig. 5, if the delay is in only one direction, amnesiac flooding terminates.

Open Problem 4. For which class of graphs with directional fixed-delays at edges does amnesiac flooding from a single source terminate?

The only general multiple-source and multiple-edge fixed-delay termination result we have is for cycles. Can this be extended to cylinder grid graphs, i.e. products of cycles with line graphs, or any class of tori?

Open Problem 5. Suppose that \((G_1,E_1)\) is a cycle and \((G_2,E_2)\) is a line graph. Is multiple-source amnesiac flooding on the product graph \((G_1,E_1) \times (G_2,E_2)\), where there are fixed delays at multiple edges, guaranteed to terminate? What if \((G_2,E_2)\) is an acyclic graph or a cycle graph?

As a final note, one can see processes such as random walks, coalescing random walks and diffusion as probabilistic extremal variants of flooding. Are there any implications or connections of our results on these or intermediate probabilistic models? What about randomised variants of amnesiac flooding?