Manuscript Offprint
arXiv:2609.06850Don't Be Afraid to Die: Black Hole Search in Dynamic Graphs with Fewer Agents
Kass Bileski and Avery Miller[0000-0002-8231-3697]
University of Manitoba, Winnipeg MB, Canada bileskib@myumanitoba.ca, avery.miller@umanitoba.ca
Abstract. We consider a team of synchronous mobile agents operating in a port-labeled network. There is one node in the network called a black hole that permanently destroys any agent that visits the node. The team of agents must safely locate the black hole, i.e., at least one agent must survive, terminate its algorithm at a node adjacent to the black hole, and output the port number that leads to the black hole from its current position. In the setting where the network is a 1-bounded 1-interval connected dynamic graph, previous work [19] showed that a team consisting of agents is sufficient to solve the task from a scattered configuration, where denotes the degree of the black hole node. We show that agents are sufficient, nearly matching the lower bound provided in [20].
Keywords: black hole search · dynamic graphs · distributed algorithms.
Security is a significant concern in distributed systems. One kind of security hazard is a site attack: a malicious entity has compromised a node in a distributed system, and has perhaps changed the node's behaviour as to inhibit or destroy functionality, information, or entities. Once we have suspected that some node in a system has been compromised, the first step towards dealing with the hazard is to locate it. The Black Hole Search (BHS) problem abstractly models this task: a network or a network-like environment is represented using a graph in which one node is a “black hole” that immediately destroys any mobile entity that visits it. The goal of the problem is to employ a team of mobile agents to find the location of the black hole in a distributed way, i.e., each agent is independently executing a copy of the algorithm rather than having a central entity that can control and monitor all of the agents. This goal is complicated by the fact that an agent that finds the black hole is not able to report its location (since the agent has been destroyed) so the actual requirement is that at least one agent must correctly deduce the location of a node that is adjacent to the black hole, as well as the incident edge that leads to the black hole.
As a potential practical setting, the mobile agents might be a group of software agents that must search a network to locate a dangerous virus that has
- This work was supported by the Natural Sciences and Engineering Research Council of Canada (NSERC) Discovery Grant RGPIN-2024-06411.
infected one of the network nodes. As another example, the graph might represent a map of an environment in which robots or self-driving cars move around, and the attack might come in the form of a person intercepting and deactivating the robots/cars at some particular location.
In this work, we create a deterministic distributed mobile agent algorithm that solves BHS in environments where the network edges (on which the agents travel) are not reliable. Such environments complicate the task of deducing the location of the black hole because if one agent sees that another agent has traversed a link but does not return, agent cannot immediately know for certain whether this was due to agent visiting the black hole or due to the link disappearing. Regarding efficiency, our main goal is to minimize the number of mobile agents in the team, but we also want the agents to find the black hole relatively quickly, e.g., in polynomial time with respect to the network size.
1 Preliminaries
We consider a team of mobile agents that act in a synchronous, distributed way. Each agent possesses a unique integer identifier, and we assume that this identifier comes from the range for some fixed positive constant . Each agent knows its own identifier, but does not initially know the value of , , or any other property of the graph. Each agent is equipped with bits of memory. In addition to this internal memory possessed by each agent, there is also external memory: at each node in the network, there is a whiteboard that can store bits of information, and this information can be written and read by any agent that is located at the node.
Initially, i.e., in round 0, the agents are in a scattered configuration: each agent is located at a safe node in , and each safe node in may contain 0 or more agents. Essentially, other than the fact that no agent starts at the black hole, we assume that the initial configuration is arbitrary, in contrast to a rooted configuration in which all agents start at the same safe node.
At the start of each round , each agent that has not yet been destroyed by the black hole is located at some node . If the agent has not terminated its execution before round , then it performs a Look-Compute-Move (LCM) cycle in round , i.e., it performs the following phases in the following order:
-
Look phase: Agent sees the degree of node in the underlying graph , but does not see which edges are active in the current round. Also, agent sees all other agents co-located at and can read the entire internal memory of each such agent. Agent can also read the contents of the whiteboard . If the agent attempted to move in round , then it learns whether or not the move was successful, i.e., whether the edge it attempted to move along was active or inactive in round . If the move was successful, the agent learns the port number at node from which it entered .
-
Compute phase: Based on all the information it acquired during this round's Look phase, as well as the contents of its own memory, agent deterministically decides which action it will take in the Move phase of the current round : move, wait, or terminate. We place no computational restrictions on agent 's decision-making. If it decides to move, it computes the port number at of the edge that it will attempt to move along. Agent may also modify the contents of the whiteboard during this phase.
-
Move phase: If, during the Compute phase, the agent decided that it will attempt to move using some port , then the agent now attempts to move along the incident edge corresponding to the port at node . If the edge corresponding to is active in the current round , and node is a safe node, then agent will be located at at the start of round ; otherwise, if is the black hole, then agent is immediately destroyed and does not appear at any node from the start of round onward. If the edge is inactive in round , or, the agent decided to wait or terminate, then the agent will be located at node at the start of round .
We study the task of locating the black hole node in , defined as follows.
Definition 1 (Black Hole Search in 1-bounded 1-interval connected time-varying graphs (1-BHS)). Let be a 1-bounded 1-interval connected time-varying graph with underlying graph such that exactly one node in is designated as the black hole. A team of mobile agents starts in a scattered configuration in round 0. To solve the task, there must exist a round and a node adjacent to such that at least one agent terminates its execution in round at node and agent outputs the port number at that leads to . We say that this agent has reported the black hole.
We create an algorithm that each agent will follow during its Compute phase in each round such that 1-BHS is solved for any , any black hole location, and any starting configuration. We also determine an upper bound on the number of rounds that elapse before at least one agent has reported the black hole.
1.2 Related Work
Black Hole Search was introduced in [10], assuming asynchronous agents in anonymous rings. Further results about Black Hole Search in static graphs under varying assumptions and graph classes appeared in [6,7,8,9,11,12,13,14,15]. For dynamic graphs, the problem was first studied for 1-bounded 1-interval connected time-varying graphs and assuming that the underlying graph belonged to specific graph classes [1,3,16,22,23]. When the underlying graph is an -torus, the authors of [4] studied Black Hole Search in -bounded 1-interval connected time-varying graphs. Additional variants of the model and problem have been recently introduced, for example, when the black hole emerges after some unknown number of rounds [5,21], when the black hole can choose in each round whether or not a visiting agent will be destroyed [2,17], and under stronger agent capabilities such as global communication and 1-hop visibility [18].
Most relevant to our work are the previous results about Black Hole Search under the assumptions presented in Section 1.1. In [20], the authors considered the case where agents start in a rooted configuration, and provided a -round 9-agent algorithm for 1-bounded 1-interval connected graphs. They also proved that at least agents are necessary for solving the task from every scattered initial configuration. For -bounded 1-interval connected graphs, they provided an exponential-time algorithm using agents starting in a rooted configuration, and proved that at least agents are necessary (even for rooted initial configurations). In [19], the authors considered agents starting in a scattered configuration, and provided an algorithm that uses agents.
1.3 Our Results and Approach
Consider any 1-bounded 1-interval connected time-varying graph with underlying graph consisting of nodes and edges. Exactly one node in is designated as the black hole, whose degree in is denoted by . We provide an algorithm that solves 1-BHS using agents, and at least one agent has reported the black hole within rounds.
Previous work [19] had each agent follow a depth-first search (DFS) strategy, with no two agents simultaneously using the same outgoing port at a node, and replacing each edge traversal of the DFS with several mini-steps: write the agent's ID and its outgoing port to a whiteboard, traverse the edge, return back along the edge, delete its information from the whiteboard, then traverse the edge again. If the same outgoing port appears twice on the same whiteboard, then it means two agents have exited the node via and neither of them returned to erase their information. It follows that port leads to the black hole, and any agent that sees this on a whiteboard terminates and reports the black hole. We adopt the same strategy, but we use a different approach to guarantee that some agent eventually sees such a whiteboard. In [19], if an agent attempts to traverse an edge that is inactive, it keeps trying the same edge until success, and if a large enough group of agents all become stuck trying the same port at some node, then they all simultaneously quit the current strategy and perform a different algorithm, i.e., one designed to solve 1-BHS from a rooted configuration (i.e., in which all agents start at the same node). The key observation from [19] was that any rooted 1-BHS algorithm that works for a team of agents can be used to create a scattered 1-BHS algorithm that works for a team of size : at most of the agents will be destroyed, and if agents become stuck trying to traverse the same inactive edge during their DFS, then at least of them must be trying the edge from the same endpoint, and such a group successfully solves 1-BHS by switching to . In [19], they apply this observation using a 9-agent rooted 1-BHS algorithm to obtain a -agent scattered 1-BHS algorithm.
In contrast, our approach is to never switch to an alternate strategy. It is based on the observation that, if agents have already been destroyed by the black hole, then every node adjacent to the black hole has a whiteboard whose discovery immediately solves the task, so any remaining agents do not have to worry about being destroyed, i.e., they just have to solve graph exploration as if there is no black hole. Essentially, if an agent is destroyed by the black hole, they are contributing towards a future situation where the graph is safe to explore by all remaining agents. So, we create a scattered -agent 1-BHS algorithm by having all agents run a scattered graph exploration algorithm that is designed for at least 3 agents in a 1-bounded 1-interval connected graph that has no black hole, and we observe that: if agents haven't been destroyed yet, then agents might visit the black hole and be destroyed; but, once agents have been destroyed, at least one of the remaining agents running will eventually visit a node adjacent to the black hole, see a whiteboard with the same outgoing port written twice on it, and correctly report the black hole. We emphasize that the agents do not detect when the threshold has been reached, i.e., they run the same algorithm regardless of how many agents have been destroyed so far. The exploration algorithm for 3 (or more) agents, similar to the one described in [20], is designed in such a way that at most two of the agents become stuck at ports trying to traverse an inactive edge (one from each endpoint) and all other agents will skip those ports. Since a 1-bounded 1-interval connected time-varying graph stays connected despite an inactive edge, and at most two agents will be stuck in any round, it follows that at least one agent will make exploration progress in each round.
Due to space constraints, the detailed proofs are omitted and will appear in the journal version of the paper.
2 Algorithm Description
The algorithm has several components, some of which are adapted from [19]. We describe them below along with the relevant agent variables and whiteboard variables. A summary of the variables is provided in Appendix A.
2.1 Depth-First Search (DFS)
The basis of the algorithm is graph exploration, which is accomplished using a DFS. In this section, we describe how agents would carry out the search if there is no black hole and all edges are active in each round. We start by describing the single-agent version. The agent maintains an internal variable called state that keeps track of whether it is moving with the goal of discovering new nodes () or it is moving back along a previously traversed edge (). Initially, agent begins in the explore state, and the node at which it starts the DFS is called its root node.
In what follows, let denote the agent's current node. In the first step of the DFS, agent writes the pair to the DFSParent variable at (the value will be used later to detect when is at its DFS root). The purpose of DFSParent at is to remember where came from when it first arrived at so that it can later backtrack. So, after the first step of a DFS, if agent arrives at node at incoming port in explore mode, and agent hasn't visited this node yet, then agent writes the pair to the DFSParent variable at . Next, agent needs to decide where it will move next. The purpose of the DFSRecent variable on the whiteboard is to remember how agent exited the node the last time it was at . There are several possible actions for agent :
-
In the first step of the DFS, agent enters explore mode, sets , writes the pair to .DFSRecent, and exits using the port .
-
If is in explore mode and .DFSRecent is empty when arrives at a node , then determines that this is the first time it has visited . Denoting by inPort the incoming port that arrived on, agent sets , writes the pair to .DFSRecent, stays in explore mode, and exits using the port .
-
If is in explore mode and .DFSRecent was not empty when arrived at , then immediately recognizes that it has been at this node before and switches to backtrack mode. It sets (i.e., goes back the way it came), and exits the node using .
-
If is in backtrack mode, then there are three subcases. Let be the port number stored in .DFSRecent. Then:
-
if sees that the port number stored in .DFSParent is equal to and that is equal to 0, then concludes that it is located at its DFS root and has explored all outgoing ports, so DFS is done.
-
if sees that the port number stored in .DFSParent is not and not equal to , then there are further ports to explore from this node, so agent sets , writes the pair to .DFSRecent, switches to explore mode, and exits the node via the port .
-
if sees that the port number stored in .DFSParent is equal to , then it means that has explored all outgoing ports from this node, so it stays in backtrack mode, sets ,
writes the pair to , and exits the node via the port .
If a single agent follows the above method of DFS on a static connected graph with no black hole, it will eventually try every port at every node in the graph, ensuring exploration of .
Next, we extend the DFS algorithm so that multiple agents can execute it starting at arbitrary nodes. If each whiteboard has unbounded memory, then each agent could execute the algorithm independently by reading and writing to its own dedicated part of each whiteboard. However, to limit the whiteboard memory to bits, a different technique is used. At a high level, an agent performing DFS will abandon its own traversal if it ever sees DFS information written to a whiteboard by an agent with smaller ID, and instead follow that agent's DFS traversal. In particular, at each step of each agent 's DFS, there are two possible behaviours: we refer to the first possibility as "agent performs its own DFS", and we refer to the second possibility as "agent follows another agent's DFS". These will be described in more detail below. To decide which of the two behaviours to perform, agent starts each step by looking at at its current node : if the ID stored in is smaller than agent 's ID, then agent abandons its own DFS and instead follows the DFS of the agent with this smaller ID (Behaviour 2); otherwise, if is empty, or, agent 's ID is less than or equal to the ID stored in , then agent performs its own DFS (Behaviour 1).
- Behaviour 1: agent performs its own DFS.
This is nearly identical to the DFS described above for the case of a single agent. The only differences are when checking if a variable is empty or non-empty. The condition "if the variable is not empty" becomes "if the variable is storing an ID equal to ". The condition "if the variable is empty" becomes "if the variable is empty or is storing an ID strictly greater than ", and in this case agent will overwrite the information in the variable with its own. If the agent whose information was overwritten returns to this node, it will see the DFS information belonging to , who has a smaller ID, and it will instead follow agent 's DFS.
- Behaviour 2: agent follows another agent's DFS.
The variable contains the information that needs to know in order to follow the other agent. Agent does not write any values to or , and it exits node using the port number stored in .
Next, we modify the multi-agent DFS algorithm so that, if multiple agents are co-located at the same node , then only the two agents with the two smallest IDs at perform a step of their DFS. We will describe later how to ensure that the two agents attempt to exit the node using different ports. We want to restrict the number of agents at that move simultaneously because, if an adjacent vertex is a black hole, we want to avoid the situation where a large number of agents are destroyed in a single step. On the other hand, we want more than one agent to attempt a move so that progress is guaranteed if one of the two agents is blocked by an inactive edge.
In certain situations, we will want an agent to be able to stop or finish its execution of a DFS and start a new one. The potential issue is that, if an agent visits a node and sees that .DFSRecent contains .ID (indicating a previous visit occurred), the agent should be able to differentiate whether the previous visit occurred during a previous DFS execution or during its current DFS. To do this, each DFS execution will be associated with its own integer: each agent keeps an internal .DFSnum value that it includes with .DFSRecent when writing to the whiteboard, and the agent increments .DFSnum whenever it starts a new DFS. Then, when checking a node 's whiteboard for a previous visit, it also compares its current .DFSnum value to what is written on the whiteboard.
Further modifications to the DFS algorithm will be made in the following sections to handle the possibility of inactive edges and to enable the agents to determine the location of the black hole.
2.2 Even and Odd Rounds
In this section, we describe how we deal with the possibility of an unsuccessful edge traversal due to an inactive edge. Recall that an agent cannot detect whether an edge is active or inactive until it tries traversing the edge; instead, it gets the result of an attempted edge traversal at the start of the next round. So, our algorithm proceeds in pairs of consecutive rounds (and the first round in each pair is an even-numbered round). In each even round, the agents attempt to perform their movement. In each odd round, each agent finds out whether or not its move in the previous round was successful, and updates internal variables and whiteboard variables accordingly so that, in the next even round (i.e., the start of the next step of the algorithm), it can make decisions based on whether or not its previous attempted move was successful.
2.3 Individual Cautious Movement (ICM)
In this section, we describe how the agents will determine the location of the black hole. The agents move in a careful way and write appropriate information to the whiteboards so that, if an agent is destroyed by the black hole, it has left behind clues that allow other agents to deduce the black hole's location.
Consider an agent at node who wishes to perform a single step of its own DFS across an edge in explore mode to reach node . Every such DFS step will be replaced by an ICM, which consists of three stages corresponding to three movements across the edge (and recall, from the previous section, each movement starts in an even-numbered round and happens across two rounds). At the start of stage 0, agent writes to .DFSParent and .DFSRecent as it would according to the DFS algorithm, however, it also writes to a whiteboard variable called .marked the same values it wrote to .DFSRecent (i.e., the pair .ID, .outPort) consisting of 's ID and the port it will try in this round).
The purpose of .marked, which is also referred to as marked port information, is to provide a record that agent has attempted to exit node using a particular port (we can't just use .DFSRecent since it could be overwritten by another agent performing a DFS). At the end of stage 0, agent attempts to move across edge towards . If the movement was unsuccessful due to being inactive, then deletes the whiteboard information that it wrote and then retries stage 0. If the movement was successful, then recognizes that it is now at node , sets a variable .infoToDelete with its own ID, and it begins stage 1. In stage 1, at node , agent attempts to move back across to node . If this move is unsuccessful, then retries stage 1 again. If the move is successful, then sees that it is back at node and it clears the .marked variable corresponding to the ID stored in .infoToDelete. To handle timing/concurrency issues around writing and reading whiteboards, the .marked variable is cleared in the odd-numbered round of stage 1 (i.e., the whiteboard at has been updated before agents read from it in the even-numbered round of stage 2). Agent then begins stage 2, which is the third and final stage of the ICM. In stage 2, agent attempts to move back across to the node , knowing that is a safe node (and this time it does not write information to the whiteboard). If the movement is unsuccessful, then retries stage 2 again. If the movement is successful, then completes this ICM upon arrival at node , and it has finished the DFS step. From here, agent can start the next step of its DFS.
Since several agents might have previously left a node from different ports, and we don't want an agent to inadvertently overwrite important clues left by them, it turns out that a single .marked variable is not enough. However, six such variables are sufficient at each node since, in any particular round: at most two agents are attempting to leave in stage 0 of an ICM, at most two agents left marked information in the previous step and are trying to return to in stage 1 of an ICM, and there are at most two ports from which agents might not have successfully returned to delete their marked port information (one due to the black hole, the other due to an inactive edge). We differentiate the six .marked variables by appending the subscripts 1, ..., 6.
2.4 Disperse and Ignore
In this section, we describe the main tools that will enable us to solve 1-BHS using fewer agents than in previous work. The first tool is called "disperse". Suppose there are at least two agents at node , let denote the agent with smallest ID and let denote the agent with second smallest ID. After each determines its next action according to the DFS/ICM procedures above, if both agents want to move using the same outgoing port , then they disperse: agent will attempt to move using outgoing port , and, simultaneously, agent will skip port and continue its DFS elsewhere. Additionally, if it is the case that agent was attempting to return to a node to delete whiteboard information, i.e., it was in ICM stage 1, then has to remember to do this after exiting through port on behalf of agent , and it does so by copying over .infoToDelete into its own .infoToDelete. The purpose of dispersing is to avoid the situation where many agents get clumped together at the same node waiting to traverse the same edge. In particular, it follows that there can ever be at most 2 agents waiting to traverse an inactive edge (one from each endpoint), and so 3 agents performing DFS are sufficient to guarantee progress in each round.
The second tool is called “ignore”. Suppose there are at least two agents at node , let denote the agent with smallest ID and let denote the agent with second smallest ID. Moreover, suppose that both agents want to exit via some port . The agents will disperse as described in the previous paragraph, i.e., agent will try to exit via port and agent will continue its DFS elsewhere. However, recall from the description of multi-agent DFS in Section 2.1 that, if agent ever sees agent 's information on a whiteboard, agent will abandon its DFS and follow agent because agent 's ID is smaller. This could result in agent getting stuck in a (possibly infinite) loop: suppose agent is repeatedly trying an inactive edge at node , agent disperses to continue its DFS elsewhere, sees agent 's information on a whiteboard and abandons its DFS to follow agent 's DFS, arrives back at node where agent is still stuck, and so on. The purpose of the “ignore” list is to avoid such a situation: when agent disperses, it adds 's ID to its personal “ignore” list. Then, we modify the multi-agent DFS procedure as follows: if arrives at a node and sees that .DFSRecent is storing a smaller ID belonging to some agent , then only chooses to abandon its own DFS to follow if does not appear on agent 's “ignore” list. It is important to note that we can implement this idea using two variables, and , since at most 2 agents can be stuck trying ports on an inactive edge, i.e., to avoid an infinite loop without progress, an agent never has to ignore more than 2 other agents. So, if both of agent 's “ignore” variables are already set, and agent disperses with an agent with smaller ID that isn't currently ignoring, then agent overwrites its least recently modified “ignore” variable.
To implement the above ideas, we use several copies of some of the variables described earlier. For example, an agent might want to ignore two other agents and continue along its own DFS instead, so we need multiple copies of DFSParent and DFSRecent on the whiteboard for to use. Recall that, at any node , at most two agents will attempt to move in the same round, and each is ignoring at most two smaller agent IDs. It follows that four copies of DFSParent and DFSRecent suffice, which we differentiate by appending subscripts 1,2,3,4.
2.5 Summary of the Algorithm
We describe our algorithm using a collection of agents denoted as , from the point of view of some fixed arbitrary agent at a fixed node . A summary of the variables can be found in Appendix A, and the detailed pseudocode can be found in Appendix B. Initially, each agent starts in explore mode in ICM stage 0. Each step of the algorithm consists of a pair of consecutive rounds, starting with an even-numbered round.
In each even-numbered round, the agents execute Algorithm 2, which proceeds as follows. First, each agent checks if there are two marked port variables at that contain the same port number , and if so, it reports that the black hole is reached by exiting node using port and terminates its execution (since the task is solved). Otherwise, the agent with smallest ID at will attempt to move, and, if there are at least two agents at , then the agent with the second smallest ID at will also attempt to move. All other agents at wait and do nothing. In the rest of the description, suppose that is an agent with one of the two smallest IDs at node . At the start of the round, sets its inPort variable to be the port number at from which it last entered , or if it has never traversed an edge. Starting at line 1 of Algorithm 3, agent proceeds to decide which outgoing port to use when attempting to move in this round, i.e., by executing Algorithm 4:
(1) If is in explore mode and in ICM stage 0, then first checks whether or not it sees DFS information written on the whiteboard belonging to an agent with smaller ID.
(a) If sees DFS information belonging to an agent with smaller ID that is not in 's ignore list, then abandons its own DFS to follow the move made by the agent with the smallest such ID, i.e., it sets .outPort using the port from the .DFSRecent variable that contains the smallest ID that is not in 's ignore list.
(b) If does not see DFS information belonging to an agent with smaller ID, then follows its own DFS execution, and there are two sub-cases: if agent attempted to move in the previous even-numbered round and failed due to an inactive edge, then it attempts the same actions again (i.e., it does not modify any variables); otherwise, sets its variables to carry out the next step of its DFS as described in Section 2.1.
(2) If is in explore mode and in ICM stage 1, then it should attempt to move back along the edge it most recently traversed (i.e., it sets .outPort using .inPort). Moreover, it sets .infoToDelete = .ID so that, after it returns back to its previous node, it will know to delete the marked port information that it wrote there in ICM stage 0.
(3) If is in explore mode and in ICM stage 2, then it should attempt to move back along the edge it most recently traversed (i.e., it sets .outPort using .inPort). It does not write any DFS information or marked port information in this round.
(4) If is in backtrack mode, then first checks the whiteboard for DFS information belonging to an agent with smaller ID.
(a) If sees the DFS information of an agent with smaller ID that is not in 's ignore list, then abandons its DFS to follow the agent with the smallest such ID, i.e., it switches to explore mode, sets ICM stage to 0, and sets .outPort using the port from the .DFSRecent that contains the smallest ID that is not in 's ignore list.
(b) If does not see DFS information belonging to an agent with smaller ID, then will follow its own DFS execution, and there are two sub-cases: if agent attempted to move in the previous even-numbered round and failed due to an inactive edge, then it just attempts the same actions again (i.e., it does not modify any of its variables); otherwise, sets its variables to carry out the next step of its DFS as described in Section 2.1, with one modification: in the case where determines that its DFS is done, it restarts DFS by incrementing .DFSnum and then executing the instructions given for the first DFS step.
After line 1 of Algorithm 3, agent has chosen which port it will use in its attempt to leave node , but then agent does an additional check to see if there is another co-located agent at that has chosen the same outgoing port for the current round. If this is the case, then the two agents disperse, as described in Algorithm 8:
(1) If .ID .ID, then will continue as planned, i.e., it will attempt to exit using port . However, it also checks if agent is in stage 1 of an ICM, and if so, sets its own .infoToDelete variable to the value stored in .infoToDelete (and clears its own infoToDelete).
(2) If .ID .ID, then does not continue as planned, i.e., it will change its .outPort value before attempting to move. This change depends on various cases, as described in Algorithm 7:
(i) If is in explore mode and not in ICM stage 1, then performs Algorithm 7: it skips over port in its DFS by incrementing its outPort modulo the degree of . This is sufficient in most cases, however, there are two special situations after performing the increment: (a) if outPort is now pointing to 's parent in 's DFS, then switch to backtrack mode; (b) if is the root node of 's DFS (i.e., its parent port is set to ) and outPort is now 0, then has completed its DFS and should start a new one (it does this according to Algorithm 11: increment its DFSnum, set its inPort to , and write this information to .DFSParent).
(ii) If is in backtrack mode, or, in ICM stage 1 of explore mode, then notice that is trying to leave to return to a specific node and continue its DFS exploration from . However, dispersing means that cannot return to node , so instead, it just starts a new DFS with node as its root. In particular, it executes Algorithm 11: it increments its DFSnum, sets its inPort to , writes this information to .DFSParent, and sets its outPort to 0. There is one edge case to check: it is possible that also wants to leave using port 0, and in that case, agent 's DFS will start at port 1 instead (see lines 18-19 of Algorithm 8).
Moreover, in Case (2), also sets its least-recently modified ignore variable to .ID, as described in Algorithm 9.
Finally, agent attempts to exit node by moving through its chosen outgoing port, and this ends the description of the even-numbered round of the current algorithm step.
In the odd-numbered round that immediately follows, agent executes Algorithm 13, which begins by checking whether or not the move it attempted in the previous round was successful. If the move was unsuccessful, then deletes all the whiteboard information that it wrote to in the previous round (since, in the next even-numbered round, it will retry the move and rewrite the information). If the move was successful, then if was performing an ICM (i.e., is in explore mode), then increments its ICMstage variable. Moreover, if is carrying information that should be deleted from the whiteboard at the node it has arrived at (i.e., if .infoToDelete is not empty), then performs the deletion during the current round. Doing this in the current odd-numbered round ensures that the information is deleted when agents read the whiteboard in the next even-numbered round.
3 Algorithm Analysis
In what follows, we use the term marked port information variables to refer to the .marked whiteboard variables for . The first set of claims discuss the marked port information variables at each node . The first result shows that most of these variables are immediately cleared, i.e., even if 3 or more of the marked variables at contain values at the start of some even-numbered round , each will be cleared in round except for perhaps two of them due to agents unable to return to in round : a marked variable containing a port leading directly to the black hole, or, a marked variable containing a port of an edge that is inactive during round .
Lemma 1. Consider any even-numbered round and any node . Suppose that there is a collection of at least two marked port information variables on 's whiteboard that are non-empty at the start of round . Then, at most two of the variables in are not cleared during round .
Next, we observe that at most two agents modify information on 's whiteboard in any particular even-numbered round, since only the agents with the two smallest ID's at perform any actions. Moreover, if two agents write to marked port information variables, then they will not write the same port number since the Disperse method ensures that they do not try to leave via the same port.
Lemma 2. In any particular even-numbered round at any node , at most two agents write to marked port information variables on 's whiteboard in round . Moreover, if exactly two agents write to marked port information variables on 's whiteboard in round , then they write different port numbers to these variables.
We now show that there are always enough empty marked port information variables available at , i.e., an agent will never overwrite important information left behind by other agents. More specifically, we prove that at least two such empty variables exist at the start of each even-numbered round , which suffices since, by Lemma 2, at most two agents will attempt to write to marked port information variables during round . The result follows from Lemmas 1 and 2: at most two of the marked port information variables that were non-empty at the start of round are not cleared during round , and, at most two additional variables are written during round , which implies that at most 4 of the 6 marked port variables are non-empty at the start of round .
Lemma 3. Consider any even-numbered round and any node . At the start of round , at least two marked port information variables are empty at .
The previous result guarantees that an agent never has to overwrite marked port information that is written by another agent. This implies our next result: if an agent is destroyed as soon at it leaves a node , the information it left behind will always be visible to other agents that visit in the future.
Lemma 4. Consider any two nodes adjacent in . Let be the port at that leads to node . If is the black hole, and an agent exits using in an even-numbered round , then agent wrote along with .ID to some .marked variable in round , and that variable is not modified after round .
For any particular port number , it follows directly from Lemma 2 that the number of marked port information variables at that contain can increase by at most one in any particular even-numbered round. Since an agent terminates its algorithm if it sees two marked port information variables at containing the same port number , we get the following result.
Lemma 5. At the end of any even-numbered round and for any node , there are at most two marked port information variables on 's whiteboard that contain the same port number.
Recall that is the degree of the black hole node. Since each agent destroyed by the black hole permanently writes the dangerous port at a node adjacent to the black hole (Lemma 4), and, this information is written to the node at most twice (Lemma 5), it follows that at most agents are destroyed.
Lemma 6. At most agents visit the black hole.
In our algorithm, an agent reports the black hole at the start of an even-numbered round when it sees two marked port information variables containing the same port. The next result shows there are no "false positives", i.e., if a port at node does not directly lead to the black hole, then at most one marked variable at contains port . The reason is: if there is an agent (in ICM stage 0) that writes in a second marked variable at and its movement is successful, then there is another agent (in ICM stage 1) that simultaneously returns to along the same edge to clear the marked variable in which it wrote .
Lemma 7. Consider any two nodes adjacent in . Let be the port at that leads to node . If node is not the black hole, then at the start of any even-numbered round , at most one marked port information variable contains .
We will make use of an upper bound on the number of edge traversals needed by a DFS before it has visited all nodes of the graph. More specifically, if there is a large sequence of movements made by a single agent, we can conclude that it must visit all nodes in the graph. The next result bounds the number of movements in a DFS traversal by noticing that each edge can be visited at most twice in each direction: once from to in explore mode and subsequently from to in backtrack mode, then, once from to in explore mode and subsequently from to in backtrack mode. In our algorithm, each DFS edge traversal proceeds in three ICM stages, so is an upper bound on the number of movements that an agent could make during a single DFS traversal of .
Lemma 8. In a static connected graph with edges, one execution of DFS (without ICM) performed by a single agent requires at most edge traversals.
The proof of correctness and running time proceeds as follows. Consider any maximal interval of rounds in which no agent visits the black hole or reports the black hole. Our goal is to bound the length of by . After doing so, we can use Lemma 6 to bound the number of such intervals by , and then conclude that the black hole is reported within rounds.
Let denote the agent with smallest ID during . Agent either follows the DFS of a dead agent with smaller ID (in which case, will die or report within successful movements) or it follows its own DFS (in which case, will die or report within successful movements). However, the fact that performs at most successful movements in does not immediately give an upper bound on the length of , since an inactive edge can impede 's progress. To prove that consists of at most rounds, it suffices to show that, after every successful movement by during , either successfully moves again within rounds, or, otherwise, an agent other than is destroyed within rounds. The idea is assume that the first situation does not occur, i.e., that a fixed inactive edge prevents 's movement for at least consecutive rounds for a very large constant , and then consider the agents and with second smallest and third smallest ID's during , respectively. Note that the graph is static and connected during these consecutive rounds. Agent 's progress cannot get stalled at the same port as due to our Disperse subroutine and ignore variables, so, either performs a complete DFS within the rounds (i.e., dies or reports the black hole), or, 's progress gets stuck at the endpoint of opposite from and remains there. In the latter case, 's progress cannot get stalled at the same port as or due to our Disperse subroutine and ignore variables, so performs a complete DFS within the rounds (i.e., dies or reports the black hole), which concludes the argument.
Theorem 1. 1-BHS can be solved using agents in rounds.
The memory requirements follow from the fact that each agent and each whiteboard stores a constant number of variables. For variables that store non-constant values, these values are either bounded above by the maximum agent ID (assumed to be ) or the maximum port number at a node (which is ) or the running time of the algorithm (which is ).
Lemma 9. Each agent uses bits of internal memory, and each whiteboard uses bits of storage.
References
-
Balamohan, B., Flocchini, P., Miri, A., Santoro, N.: Time optimal algorithms for black hole search in rings. Discret. Math. Algorithms Appl. 3(4), 457–472 (2011). https://doi.org/10.1142/S1793830911001346
-
Bhattacharya, A., Goswami, P., Bampas, E., Mandal, P.S.: Perpetual exploration in anonymous synchronous networks with a byzantine black hole. In: Kowalski, D.R. (ed.) 39th International Symposium on Distributed Computing, DISC 2025, Berlin, Germany, October 27-31, 2025. pp. 16:1–16:17. LIPIcs, Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2025). https://doi.org/10.4230/LIPICS.DISC.2025.16
-
Bhattacharya, A., Italiano, G.F., Mandal, P.S.: Black hole search in dynamic tori. In: Casteigts, A., Kuhn, F. (eds.) 3rd Symposium on Algorithmic Foundations of Dynamic Networks, SAND 2024, Patras, Greece, June 5-7, 2024. pp. 6:1–6:16. LIPIcs, Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2024). https://doi.org/10.4230/LIPICS.SAND.2024.6
-
Bhattacharya, A., Italiano, G.F., Mandal, P.S.: Searching for a black hole in a dynamic cactus. J. Graph Algorithms Appl. 29(2), 127–166 (2025). https://doi.org/10.7155/JGAA.V29I2.3042
-
Bonnet, F., Bramas, Q., Lamani, A.: Brief announcement: Searching for an eventually-emerging black hole in rings. In: Bonomi, S., Mandal, P.S., Robinson, P., Sharma, G., Tixeuil, S. (eds.) Stabilization, Safety, and Security of Distributed Systems - 27th International Symposium, SSS 2025, Kathmandu, Nepal, October 9-11, 2025, Proceedings. pp. 82-87. Lecture Notes in Computer Science, Springer (2025). https://doi.org/10.1007/978-3-032-11127-2“8
-
Czyzowicz, J., Dobrev, S., Královic, R., Miklík, S., Pardubská, D.: Black hole search in directed graphs. In: Kutten, S., Zerovnik, J. (eds.) Structural Information and Communication Complexity, 16th International Colloquium, SIROCCO 2009, Piran, Slovenia, May 25-27, 2009, Revised Selected Papers. pp. 182–194. Lecture Notes in Computer Science, Springer (2009). https://doi.org/10.1007/978-3-642-11476-2“15
-
Dobrev, S., Flocchini, P., Kralovic, R., Prencipe, G., Ruzicka, P., Santoro, N.: Black hole search by mobile agents in hypercubes and related networks. In: Bui, A., Fouchal, H. (eds.) Proceedings of the 6th International Conference on Principles of Distributed Systems. OPODIS 2002, Reims, France, December 11-13, 2002. pp. 169–180. Studia Informatica Universalis, Suger, Saint-Denis, rue Catulienne, France (2002)
-
Dobrev, S., Flocchini, P., Kralovic, R., Ruzicka, P., Prencipe, G., Santoro, N.: Black hole search in common interconnection networks. Networks 47(2), 61–71 (2006). https://doi.org/10.1002/NET.20095
-
Dobrev, S., Flocchini, P., Kralovic, R., Santoro, N.: Exploring an unknown graph to locate a black hole using tokens. In: Navarro, G., Bertossi, L.E., Kohayakawa, Y. (eds.) Fourth IFIP International Conference on Theoretical Computer Science (TCS 2006), IFIP 19th World Computer Congress, TC-1 Foundations of Computer Science, August 23-24, 2006, Santiago, Chile. pp. 131–150. IFIP, Springer (2006). https://doi.org/10.1007/978-0-387-34735-6“14
-
Dobrev, S., Flocchini, P., Prencipe, G., Santoro, N.: Mobile search for a black hole in an anonymous ring. In: Welch, J.L. (ed.) Distributed Computing, 15th International Conference, DISC 2001, Lisbon, Portugal, October 3-5, 2001, Proceedings. pp. 166–179. Lecture Notes in Computer Science, Springer (2001). https://doi.org/10.1007/3-540-45414-4“12
-
Dobrev, S., Flocchini, P., Prencipe, G., Santoro, N.: Searching for a black hole in arbitrary networks: optimal mobile agent protocols. In: Ricciardi, A. (ed.) Proceedings of the Twenty-First Annual ACM Symposium on Principles of Distributed Computing, PODC 2002, Monterey, California, USA, July 21-24, 2002. pp. 153-161. ACM (2002). https://doi.org/10.1145/571825.571853
-
Dobrev, S., Flocchini, P., Santoro, N.: Cycling through a dangerous network: A simple efficient strategy for black hole search. In: 26th IEEE International Conference on Distributed Computing Systems (ICDCS 2006), 4-7 July 2006, Lisboa, Portugal. p. 57. IEEE Computer Society (2006). https://doi.org/10.1109/ICDCS.2006.25
-
Dobrev, S., Kralovic, R., Santoro, N., Shi, W.: Black hole search in asynchronous rings using tokens. In: Calamoneri, T., Finocchi, I., Italiano, G.F. (eds.) Algorithms and Complexity, 6th Italian Conference, CIAC 2006, Rome, Italy, May 29-31, 2006, Proceedings. pp. 139–150. Lecture Notes in Computer Science, Springer (2006). https://doi.org/10.1007/11758471“16
-
Dobrev, S., Santoro, N., Shi, W.: Using scattered mobile agents to locate a black hole in an un-oriented ring with tokens. Int. J. Found. Comput. Sci. 19(6), 1355–1372 (2008). https://doi.org/10.1142/S0129054108006327
-
Flocchini, P., Ilcinkas, D., Santoro, N.: Ping pong in dangerous graphs: Optimal black hole search with pebbles. Algorithmica 62(3-4), 1006–1033 (2012). https://doi.org/10.1007/S00453-011-9496-3
-
Flocchini, P., Kellett, M., Mason, P.C., Santoro, N.: Searching for black holes in subways. Theory Comput. Syst. 50(1), 158–184 (2012). https://doi.org/10.1007/S00224-011-9341-8
-
Goswami, P., Bhattacharya, A., Das, R., Mandal, P.S.: Perpetual exploration of a ring in presence of byzantine black hole. In: Bonomi, S., Galletta, L., Rivière, E., Schiavoni, V. (eds.) 28th International Conference on Principles of Distributed Systems, OPODIS 2024, Lucca, Italy, December 11-13, 2024. pp. 17:1–17:17. LIPIcs, Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2024). https://doi.org/10.4230/LIPICS.OPODIS.2024.17
-
Kaur, T., Saxena, A.: When agents are powerful: Black hole search in time-varying graphs. In: Chatterjee, B., Kothapalli, K., Mittal, N., Natarajan, A.M., Singh, D. (eds.) Distributed Computing and Intelligent Technology - 22nd International Conference, ICDCIT 2026, Bhubaneswar, India, January 16-19, 2026, Proceedings. pp. 3–18. Lecture Notes in Computer Science, Springer (2026). https://doi.org/10.1007/978-3-032-16632-6“1
-
Kaur, T., Saxena, A., Mandal, P.S., Mondal, K.: Black hole search by scattered agents on time-varying dynamic graphs. In: Bonomi, S., Mandal, P.S., Robinson, P., Sharma, G., Tixeuil, S. (eds.) Stabilization, Safety, and Security of Distributed Systems - 27th International Symposium, SSS 2025, Kathmandu, Nepal, October 9-11, 2025, Proceedings. pp. 309–324. Lecture Notes in Computer Science, Springer (2025). https://doi.org/10.1007/978-3-032-11127-2“25
-
Kaur, T., Saxena, A., Mandal, P.S., Mondal, K.: Black hole search in dynamic graphs. In: Korman, A., Chakraborty, S., Peri, S., Boldrini, C., Robinson, P. (eds.) Proceedings of the 26th International Conference on Distributed Computing and Networking, ICDCN 2025, Hyderabad, India, January 4-7, 2025. pp. 221–230. ACM (2025). https://doi.org/10.1145/3700838.3700869
-
Kaur, T., Saxena, A., Mandal, P.S., Mondal, K.: Black hole search: Dynamics, distribution, and emergence. CoRR abs/2603.00766 (2026). https://doi.org/10.48550/ARXIV.2603.00766
-
Luna, G.A.D., Flocchini, P., Prencipe, G., Santoro, N.: Black hole search in dynamic rings: The scattered case. In: Bessani, A., Défago, X., Nakamura, J., Wada, K., Yamauchi, Y. (eds.) 27th International Conference on Principles of Distributed Systems, OPODIS 2023, Tokyo, Japan, December 6-8, 2023. pp. 33:1–33:18. LIPIcs, Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2023). https://doi.org/10.4230/LIPICS.OPODIS.2023.33
-
Luna, G.A.D., Flocchini, P., Prencipe, G., Santoro, N.: Locating a black hole in a dynamic ring. J. Parallel Distributed Comput. 196, 104998 (2025). https://doi.org/10.1016/J.JPDC.2024.104998
A Summary of Variables
| Variables in each agent a's memory | |
|---|---|
| Variable | Description |
| a.ID | Stores the ID of the agent a. |
| a.state | Stores value explore or backtrack. Denotes whether a's DFS is in an explore or backtrack mode. It is initialized to explore. |
| a.DFSnum | Stores a positive integer c to represent that a_i is executing its c'th DFS. |
| a.success | A boolean variable. This will be used to remember whether the attempted action of agent a in the previous even-numbered round was successful, i.e., False if an attempted edge traversal failed, and True otherwise. It is initially set to True. |
| a.outPort | Stores the port number that will be used by agent a if attempting to exit its current node v in the current round, or ⊥ if it decides to stay. Can take values from {⊥, 0, 1, ..., δ_v - 1}, where δ_v is the degree of v. |
| a.inPort | Stores the port used by agent a to enter the current node, or -1 at the start of a DFS. It can take values from {−1, 0, 1, ..., δ_v - 1}, where δ_v denotes the degree of the current node v. |
| a.ICMstage | A variable denoting which ICM stage agent a is currently in. It can take the value 0, 1, or 2. |
| a.infoToDelete | Stores the ID of an agent b such that a will be responsible for deleting b's marked port information from the whiteboard at a's next node u. Can occur if a is in stage 1 of its ICM (in which case b = a), or, agent b was unable to return to u where it started an ICM due to a missing edge e, and agent b stops trying to return to u due to dispersing, and agent a is later able to traverse edge e to reach u. In this case, the whiteboard at u still has b's marked port information, and a will delete it. |
| a.ignore₁a.ignore₂ | Stores the ID of an agent b such that a will not follow b's DFS, even if b.ID < a.ID. Each is initialized to ⊥. |
| a.oldestIgnore | A variable that stores i ∈ {1, 2} corresponding to the least recent ignore_i variable that was set by agent a. |
| a.writePorta.writeRecenta.writeParent | Boolean variables used to remember whether or not an agent should write its travel information and/or marked port information to the whiteboard in the current round. |
| Variables in each node v's whiteboard | |
|---|---|
| Variable | Description |
| A triple (ID, p, DFSnum). The first entry is the ID of an agent a. The second entry is the port p at v from which agent a entered for the first time while running its DFS. The third entry stores which DFS is being executed. Initially (⊥, ⊥, ⊥). | |
| A triple (ID, p, DFSnum). The first entry is the ID of an agent a. The second entry is the most recent port at v used by agent a to continue its DFS exploration. The third entry stores which DFS is being executed. Initially (⊥, ⊥, ⊥). | |
| A pair (ID, p). The first entry is the ID of an agent a. The second entry is the port used by agent a during stage 0 of its current ICM. Initially (⊥, ⊥). | |
B Pseudocode for
In the pseudocode, agent is running the code and is located at node .
Algorithm 1:
1 .DFSnum 1; 2 evenRound True; 3 while true do 4 .inPort port at corresponding to the edge that last used to enter node . In round 0, this is set to ; 5 if evenRound then 6 Execute (); 7 evenRound False; 8 else if not evenRound then 9 Execute (); 10 evenRound True;
Algorithm 2:
1 if then 2 Report that the black hole is through port ; 3 Terminate; 4 else if .ID is smallest or second smallest among agents at then 5 Execute MovementSetup(); 6 Execute WriteWhiteboard(); 7 Attempt to move through port .outPort;
Algorithm 3: MovementSetup
1 Execute (); /* Agents have set their outPort. Now, check if two of them intend to use the same port, and if so, make them disperse. */ 2 if ( at such that .outPort = .outPort) then 3 Execute Disperse();
Algorithm 4:
1 .writePort ← False; 2 .writeParent ← False; 3 .writeRecent ← False; 4 if .state = explore and .ICMstage = 0 then 5 | j ← CheckFollow(); // check for agent to follow 6 if then 7 | // Follow agent with smallest ID I am not ignoring 8 .outPort ← .DFSRecent_j.p; 9 .writePort ← True; 10 else if .success = True then 11 | // Follow next step of my own DFS 12 Execute ; 13 else if .state = explore and .ICMstage = 1 then 14 .outPort ← .inPort; 15 .infoToDelete ← .ID; 16 else if .state = explore and .ICMstage = 2 then 17 .outPort ← .inPort; 18 else if .state = backtrack then 19 | j ← CheckFollow(); // check for agent to follow 20 if then 21 | // Follow agent with smallest ID I am not ignoring 22 .state ← explore; 23 .ICMstage ← 0; 24 .outPort ← .DFSRecent_j.p; 25 .writePort ← True; 26 else if .success = True then 27 | // Follow next step of my own DFS 28 Execute ;
Algorithm 5: CheckFollow()
/* Find the DFSRecent variable containing the smallest ID that is smaller than .ID and that is not ignoring. Return if no such variable exists. */
1 ; 2 foreach do 3 | IDtoCheck ← .DFSRecent_z.ID; 4 if ((IDtoCheck < .ID) and (not Ignoring(IDtoCheck)) then 5 | if () or (IDtoCheck < .DFSRecent_j.ID) then 6 | | ; 7 return ;
Algorithm 6:
1 if .state = explore then 2 | if not such that .ID = wb.DFSRecent.ID) and .DFSnum = wb.DFSRecent.DFSnum) then 3 | // my current DFS hasn't already visited this node 4 .outPort .inPort + 1) mod ; 5 .writeRecent True; 6 .writeParent True; 7 if outPort = inPort then 8 | // v has degree 1 and has got here via port 0 9 .state backtrack; 10 else 11 .writePort True; 12 else 13 // my current DFS has already visited this node 14 .state backtrack; 15 .outPort .inPort; 16 else if .state = backtrack then 17 /* prev: which DFSRecent variable stores the last port I used to exit the current node */ 18 prev index such that .DFSRecent.ID = .ID; 19 prevPort wb.DFSRecent.p; 20 Execute DetermineNextPort(prevPort); 21 .writeRecent True;
Algorithm 7: DetermineNextPort(prevPort)
1 outPort ← (prevPort + 1) mod ; /* par: which DFSParent variable stores the port I first arrived on at this node */ 2 par ← index j such that .DFSParent .ID = .ID; 3 if outPort = .DFSParent .p then 4 | // Backtracking to parent node 5 else 6 | // Not backtracking to parent of this node 7 .state ← explore; 8 .ICMstage ← 0; 9 .writePort ← True; 10 if .DFSParent .p = -1 and outPort = 0 then 11 | // v has no parent, so DFS is done, start a new DFS 12 Execute StartDFS();
Algorithm 8: Disperse
1 agent at with smallest ID; 2 agent at with second smallest ID; 3 if then 4 | if and then 5 | ; 6 else if then 7 | Execute StartIgnore(); 8 | if or and then 9 | // start a new DFS 10 | Execute StartDFS(); 11 | ; 12 | ; 13 | ; 14 | ; 15 | ; // only matters in ICM stage 1 16 else 17 | // skip to the next DFS port instead of using outPort 18 | Execute DetermineNextPort(outPort); 19 | ; /* Edge case: starts a new DFS and wants to use port 0, but also wants to use port 0 */ 18 if and then 19 | ;
Algorithm 9: StartIgnore()
1 if then 2 | ; 3 else if then 4 | ; 5 | ; 6 else 7 | if then 8 | ; 9 | ; 10 else if then 11 | ; 12 | ;
Algorithm 10: Ignoring(i)
1 return or ;
Algorithm 11: StartDFS()
1 ; 2 ; 3 ; 4 ;
Algorithm 12: WriteWhiteboard()
/* If 2 agents want to write to , have them execute the code below one at a time, with smaller ID going first */
1 if then /* There are at least two empty marked_j variables at the start of every even round, write to one of them. / 2 dest ← index j such that ; 3 ; 4 ; 5 if then / Find a variable to write to. First, prioritize overwriting my previously written info at this node. If none, then find an empty variable. If none, then overwrite info belonging to agent with largest ID / 6 if such that then // overwrite my previously written travel information dest ← j; 7 else if such that then 8 dest ← j; 9 else 10 | dest ← index j such that is largest; 11 ; 12 ; 13 ; 14 if then / Find a variable to write to. First, prioritize overwriting my previously written info at this node. If none, then find an empty variable. If none, then overwrite info belonging to agent with largest ID */ 15 if such that then | dest ← j; 16 else if such that then 17 dest ← j; 18 else 19 | dest ← j; 20 else 21 | dest ← index j such that is largest; 22 ; 23 ; 24 ;
Algorithm 13:
1 if attempted to move in the previous round but failed then 2 | .success ← False; 3 | Execute UndoWhiteboard(); 4 else 5 | .success ← True; 6 if attempted to move in the previous round and succeeded then 7 | if .state = explore then 8 | .ICMstage ← .ICMstage + 1) mod 3; 9 | if .infoToDelete then | /* Clear some marked port information at */ 10 | Find where .marked_j.ID = .infoToDelete; 11 | .marked_j.ID ← ; 12 | .marked_j.p ← ; 13 | .infoToDelete ← ;
Algorithm 14: UndoWhiteboard()
1 if .writePort then 2 | mine ← index such that .marked_j.ID = .ID; 3 | .marked_mine.ID ← ; 4 | .marked_mine.p ← ; 5 if .writeRecent then 6 | mine ← index such that .DFSRecent_j.ID = .ID; 7 | .DFSRecent_mine.ID ← ; 8 | .DFSRecent_mine.p ← ; 9 | .DFSRecent_mine.DFSnum ← ; 10 if .writeParent then 11 | mine ← index such that .DFSParent_j.ID = .ID; 12 | .DFSParent_mine.ID ← ; 13 | .DFSParent_mine.p ← ; 14 | .DFSParent_mine.DFSnum ← ;