Move-optimal partial gathering of mobile agents in asynchronous trees

IDs

to solve the partial gathering problem. Hence, the second proposed algorithm is also asymptotically optimal in terms of total moves. the case that the restriction of the multiplicity detection is relaxed: the strong multiplicity detection and non-token model, where the strong multiplicity detection model allows each agent to count the number of agents at the current node. In this case, we propose a deterministic algorithm to solve the g-partial gathering problem in O (kn) total moves. From the lower bound of the total moves for the non-token model, this algorithm is also asymptotically optimal in terms of the total moves. Finally, we consider the case that the restriction of the token model is relaxed: the weak multiplicity detection and removable-token model. In this case, we propose a deterministic algorithm to solve the g-partial gathering problem in O (gn) total moves. This result shows that the total moves can be reduced by using tokens. Note that in this model, agents require (gn) total moves to solve the g-partial gathering problem. Hence, this algorithm is also asymptotically optimal in terms of the total moves.
For example, Fraigniaud and Pelc [6] considered the gathering problem in tree networks for the first time. This algorithm achieves the gathering for two synchronous agents with an arbitrary delay in starting time. The space complexity for each agent is O (log n) bits, which is asymptotically optimal [7]. Later, they considered the space complexity for the case that two synchronous agents start the algorithm at the same time [7]. In this case, they proposed an algorithm to achieve the gathering for O (log l + log log n) memory per agent, where l is the number of leaves.
The time complexity required for two agents' gathering in tree networks is considered in [8,9]. Czyzowicz et al. [8] considered the trade-off between time and space complexities for two synchronous agents' gathering for the case that each agent has k ≥ c log n memory bits (c is some constant). In this case, they proposed an algorithm to solve the gathering problem in O (n +n 2 /k) time, which is asymptotically optimal. Elouasbi and Pelc [9] considered the time complexity trade-off between determinism and randomization. They proposed a deterministic algorithm for two synchronous agents' gathering in O (n) time. On the other hand, when agents know the maximum degree of the tree and the upper bound of the initial distance between two agents, they proposed a randomized algorithm to achieve the two synchronous agents' gathering with high probability in O (log n) time.
Asynchronous gathering for two or more agents is considered in [10]. Baba et al. showed a lower bound of space complexity for time-optimal algorithms, that is, they showed that each agent requires (n) memory bits to solve the gathering problem in O (n) time. In addition, they proposed a space-optimal algorithm to solve the gathering problem on the condition that the time complexity is asymptotically optimal, that is, both the time complexity and the space complexity are O (n).

Organization
The paper is organized as follows. Section 2 presents the system model and the problem to be solved. In Section 3 we show the lower bound of total moves for the non-token model. In Section 4 we consider the first model, that is, the weak multiplicity detection and non-token model. In Section 5 we consider the second model, that is, the strong multiplicity detection and non-token model. In Section 6 we consider the third model, that is, the weak multiplicity detection and removable-token model. Section 7 concludes the paper.

Network and agent model
A tree network T is a tuple T = (V , L), where V is a set of nodes and L is a set of communication links. We denote by n (= |V |) the number of nodes. Let d v be the degree of v. We assume that nodes have no distinct IDs (i.e., are anonymous), but each link l incident to v is uniquely labeled at v with a label chosen from the set {0, 1, . . . , d v − 1}. We call this label port number. Since each communication link connects two nodes, it has two port numbers. However, port numbering is local, that is, there is no coherence between the two port numbers. The path P (v 0 , v k ) = (v 0 , v 1 , . . . , v k ) with length k is a sequence of nodes from v 0 to v k such that {v i , v i+1 } ∈ L (0 ≤ i < k) and v i = v j if i = j. Note that, for any u, v ∈ V , P (u, v) is unique in a tree. The distance from u to v is the length of the path from u to v. Next, we explain about center nodes. Let us consider the following sequence of trees constructed recursively as follows: T 0 = T and T i+1 is obtained from T i by removing all its leaves. Let j be the minimum value such that T j has at most two nodes. Then, we call such nodes center nodes. We use the following theorem about center nodes later. Theorem 1. [22] There exist one or two center nodes in a tree. If there exist two center nodes, they are neighbors. 2 Next we define symmetry of trees, which is important to consider solvability in Section 4.

Definition 1.
A tree T is symmetric iff there exists a function λ : V → V such that all the following conditions hold (see Fig. 1): • For any u, v ∈ V , u is adjacent to v iff λ(u) is adjacent to λ(v).
• For any link {u, v} ∈ L, the port number assigned to {u, v} at u is equal to the port number assigned to link {λ(u), λ(v)} at λ(u).
When tree T is symmetric, we say nodes u and v in T are symmetric if u = λ(v) holds. When tree T is not symmetric, we say tree T is asymmetric. 2 There exist k agents on tree T , and let A = {a 1 , a 2 , . . . , a k } be the set of the agents. We assume that agents know neither n nor k. We consider the strong multiplicity detection model and the weak multiplicity detection model. In the strong multiplicity detection model, each agent can count the number of agents at the current node. In the weak multiplicity detection model, each agent can recognize whether another agent stays at the same node or not, but cannot count the number of agents at its current node. In both models, each agent cannot read the state of any other agent. Moreover, we consider the non-token model and the removable-token model. In the non-token model, agents cannot mark the nodes or the edges in any way. In the removable-token model, each agent initially leaves a token on its initial node at the beginning of the algorithm, and agents can remove any owner's token during the execution of the algorithm. We assume that agents are anonymous (i.e., agents have no IDs) and execute a deterministic algorithm. We model an agent as a finite state machine (S, δ, s initial , s f inal ). The first element S is the set of all states of agents, which includes initial state s initial and final state s f inal . When an agent changes its state to s f inal , the agent terminates the algorithm. The second element δ is the state transition function. In the weak multiplicity detection and non-token model, δ is described as In the definition, set M T = {⊥, 0, 1, . . . , − 1} represents the agent's movement, where is the maximum degree of the tree. In the left side of δ, the value of M T represents the port number assigned at the current node to the link the agent used in entering the current node (The value is ⊥ in the first activation). In the right side of δ, the value of M T represents the port number through which the agent leaves the current node to visit the next node. If the value is ⊥, the agent does not move and stays at the current node. In this case, if the value of R A (explained in the next sentence) changes from the previous movement, then the agent may change the value of M T and leave the current node.
In addition, R A = {0, 1} represents whether another agent stays at the current node or not. The value 0 represents that no other agents stay at the current node, and the value 1 represents that another agent stays at the current node.
In the strong multiplicity detection and non-token model, δ is described as δ : In the definition, {0, 1, . . . , k − 1} represents the number of other agents at the current node. In the weak multiplicity detection and removable-token model, δ is described as δ : In the definition, in the left side of δ, R T = {0, 1} represents whether a token exists at the current node or not. The value 0 of R T represents that there does not exist a token at the current node, and the value 1 of R T represents that there exists a token at the current node. In the right side of δ, R T = {0, 1} represents whether the agent removes a token at the current node or not. If the value of R T in the left side is 1 and the value of R T in the right side is 0, it means that the agent removes a token at the current node. Otherwise, it means that an agent does not remove a token at the current node. Note that, in both models, we assume that each agent is not imposed any restriction on the memory.
During the execution of the algorithm, agents are located either on nodes or links. Each agent executes the following three operations in an atomic step: 1) Agent a h reaches some node v, 2) agent a h executes local computation at v, and 3) agent a h leaves v or stays there. The local computation in the second action and the decision for the third action are determined by the state transition function δ. In the local computation, agent a h executes the following operations: 1) Agent a h obtains information about its local configuration (i.e., existence (resp. the number) of other agents at the current node v in the weak (resp. strong) multiplicity model and the token state at v in the removable-token model), 2) agent a h executes some computation at v, 3) agent a h decides whether a h removes the token or not for the case of the removable-token model, 4) agent a h decides whether a h moves to the next node or not, and 5) agent a h decides the port number to leave from (in the case that it decides to move). We assume a h completes possible local computation at each step, that is, at the end of a step, a h either leaves v or decides to stay at v. If a h decides to stay at v, after the decision a h does nothing (i.e., does not change its state, does not remove the token at v, or does not leave v) unless other agents change a h 's local configuration. Note that the above atomic actions can be easily implemented if each node has a buffer that stores agents visiting the node and makes them execute processes in a FIFO order, and this assumption is very natural in a distributed system. In addition we assume that agents move in the tree network in a FIFO manner, that is, when agent a h leaves some node v j before another agent a i leaves v j through the same communication link as a h , then a h reaches v j 's neighboring node v j before a i . Note that a FIFO assumption is known to be also natural in a distributed system.

System configuration
In the non-token model, (global) configuration c is defined as a product of states of agents, states of links, and locations of agents. Here, the state of link (v j , v j ) is a sequence of agents that are in transit from v j to v j in this order. In the removable-token model, configuration c is defined as a product of states of agents, states of nodes (existence or nonexistence of tokens), states of links, and locations of agents. Note that in both models, the locations of agents are either on nodes or links. In addition, in the initial configuration c 0 , we assume that node v j has a token if there exists an agent at v j , and v j does not have a token if there exists no agent at v j . Moreover in both models, we assume that no pair of agents stay at the same node in the initial configuration c 0 , thus exactly k district nodes each have a token in c 0 .
When configuration c i changes to c i+1 , a scheduler activates a non-empty set of agents, say A i , and each agent in A i takes a step as mentioned before. We denote by such a transition c i We assume that the scheduler is fair, that is, each agent is activated after a finite (unknown) amount of time and infinitely many times. In addition, we assume that if the scheduler activates some agent a j that is 1) in a sequence of agents that are in transit in some link (v l ,v l ), but 2) not in the head of the sequence, then a j does not take a step (i.e., does not reach v l ). Moreover, if several agents at the same node are included in A i , the scheduler activates the agents one by one in an arbitrary order. When A i = A holds for every i, all agents take steps every time. This model is called the synchronous model. Otherwise, the model is called the asynchronous model. In this paper, we consider the asynchronous system.
, E is called an execution starting from c 0 . We assume that any execution E is maximal in the sense that E is infinite, or ends in final configuration c f inal where every agent's state is s f inal .

Partial gathering problem
The requirement of the partial gathering problem is that, for a given positive integer g, each agent should move to a node and terminate so that at least g agents should meet at the node. Formally, we define the g-partial gathering problem as follows.

Definition 2.
Execution E solves the g-partial gathering problem when the following conditions hold: • Execution E is finite. • In the final configuration, for any node v j such that there exists an agent on v j , there exist at least g agents on v j . 2 For the g-partial gathering problem, we have the following lower bound on the total number of agents moves. Notice that the lower bound result holds in any multiplicity detection model and any communication model (e.g., the removable-token model).

Theorem 2.
The total number of moves required to solve the g-partial gathering problem for tree networks is (gn) if g ≥ 2.
Proof. We assume that k = n/2 holds. Let us consider a line network such that g/2 agents are placed at consecutive nodes starting from one endpoint and the other k − g/2 agents are placed at consecutive nodes starting from the other endpoint. We call the g/2 agents (resp., k − g/2 agents) group G 1 (resp., G 2 ). Then, agents in G 1 need to meet at the same node with agents in G 2 . Let a l ∈ G 1 (resp., a r ∈ G 2 ) be the agent located at the farthest node from the endpoint that an agent in G 1 (resp., G 2 ) exists. Then, the distance between a l and a r is at least n/2 , and hence they requires at least n/2 moves to meet at the same node v . Similarly, in order for one agent in G 1 and one agent in G 2 to meet at v , they require at least n/2 moves. This requires g/2 × n/2 = gn/4 moves. Thus, we have the theorem. 2

Lower bound of the total moves for the non-token model
For the non-token model, we have the following lower bound of the total moves. This result holds even for the strongmultiplicity detection model.

Theorem 3.
In the non-token model, agents require (kn) total moves to solve the g-partial gathering problem even if agents know k. Proof. For simplicity, we show the theorem for the case of the weak-multiplicity model, and the following proof can be similarly applied to the strong-multiplicity model. We show the theorem by contradiction, that is, we assume that there exists an algorithm A to solve the g-partial gathering problem in o(kn) total moves. Let a local configuration of agent a staying at node v be a boolean value indicating whether another agent stays at v or not. Then, we define a waiting state of agents as follows: an agent a is in the waiting state at node v if a never leaves v before the local configuration of a changes. Concretely, there are two cases. The first case is that, when a visits node v and enters a waiting state at v, there exist no other agents at v. In this case, a neither changes its waiting state nor leaves v until another agent visits v. When the scheduler activates a and a observes such an agent, a can break its waiting state and leave v. The second case is that, when a visits v and enters a waiting state at v, there exists another agent at v. In this case, a neither changes its waiting state nor leaves v until there are no other agents at v. When the scheduler activates a and a detects such a situation, a can break its waiting state and can leave v. 1 Let us consider the initial configuration c 0 such that k agents are placed in tree T with n nodes. We claim that some agent enters a waiting state in o(n) moves without meeting other agents. Consider the execution that repeats a phase in which every agent not in a waiting state: 1) makes a movement, and 2) visits a node. Let a i be the first agent that enters a waiting state in this execution. Then, a i does not meet other agents until it enters a waiting state. This is because, unless each agent enters a waiting state, it moves in the tree and is never observed by other agents. If a i makes (n) moves before it enters a waiting state, each of the other agents makes (n) moves. This implies the total number of moves is (kn), which contradicts to the assumption of A. Hence, a i enters a waiting state in o(n) moves without meeting other agents. This implies there exists a node v x which a i does not visit before it enters a waiting state. Let v w be the node where a i is placed in the initial configuration c 0 .
Next, we construct tree T with kn + 1 nodes as follows: Let T 1 , . . . , T k be k trees with the same topology as T and v j x (1 ≤ j ≤ k) be the node in T j corresponding to v x in T . Tree T is constructed by connecting a new node v to v j x for every j (Fig. 2). Let v j w (1 ≤ j ≤ k) be the node in T j corresponding to v w in T . Consider the configuration c 0 such that k agents are placed at v 1 w , v 2 w , . . . , v k w , respectively. Since agents do not have knowledge of n, each agent performs the same behavior as a i in T (note that they do not visit v j x ). Hence, each agent placed in T j (1 ≤ j ≤ k) enters a waiting state without moving out of T j . Thus, each agent enters a waiting state at different nodes and does not resume its execution. Therefore, algorithm A cannot solve the g-partial gathering problem in T . This is a contradiction. 2

Weak multiplicity detection and non-token model
In this section, we consider the g-partial gathering problem for Model 1 in Table 1, that is, the weak multiplicity detection and non-token model. First, we consider the case for asymmetric trees. In this case, agents can achieve the classical gathering in O (kn) total moves by the previous result in [10]. This result can be clearly applied to the g-partial gathering.
Hence, we have the following theorem.

Theorem 4.
In the weak multiplicity detection and non-token model, agents solve the g-partial gathering problem in O (kn) total moves for asymmetric trees. 2 Next, we consider the case that the tree is symmetric and agents are placed symmetrically in the initial configuration.
In this case, we show that there exist no algorithms to solve the g-partial gathering problem if g ≥ 5 holds. We consider the case such that in the initial configuration even agents are placed symmetrically in a symmetric tree, that is, if there exists an agent at node v, there also exists an agent at node v , where v and v are symmetric. Then, we have the following theorem.
Theorem 5. Let us consider the initial configuration such that agents are placed symmetrically in a symmetric tree. Then, in the weak multiplicity detection and non-token model, there exist no algorithms to solve the g-partial gathering problem if g ≥ 5 holds.
Proof. For contradiction, we assume that the g-partial gathering problem can be solved. We prove the theorem for the case that g is an odd number (we can also prove the theorem similarly for the case that g is an even number). We assume that the tree network is symmetric, and for any node v, we denote by v the node symmetric to v. We consider the initial configuration c 0 such that 3g − 1 agents are placed symmetrically in the symmetric tree, that is, if there exists an agent at v, there also exists an agent at v . For any agent a located at a node v in c 0 , let a denote the agent that is located at v in c 0 . Note that since 2g < k = 3g − 1 < 3g holds, agents are allowed to meet at one or two nodes. Then, we have the following lemma [6]. We consider a waiting state defined in Section 3. Then, the definition means that even when the local configuration of some waiting agent changes, the agent does not change its state unless the scheduler activates the agent. Note that, if an agent is staying at some node, then it is either in an initial state or a waiting state. Then, we have the following lemma about a waiting state.

Lemma 2. At any node v j where at least three waiting agents exist, at least two of the agents never leave v j by the end of the algorithm.
Proof. We assume that agents a Let us consider a configuration such that there exist at least three nodes where there exist at least three waiting agents, respectively. We call such a configuration a three-node three-waiting-agent configuration. Then in three-node three-waitingagent configurations, by Lemma 2 there exist at least three nodes where agents exist at the end of the algorithm execution.
In addition since agents are allowed to meet at one or two nodes because of k < 3g, agents cannot solve the g-partial gathering problem when the system reaches a three-node three-waiting-agent configuration. This is the key idea of the proof. We consider an adversarial scheduler such that once some agent enters a waiting state, the scheduler never activates the agent until all agent enter waiting states. When all agents are in waiting states, we denote such a configuration by c t . Note that c t is the configuration such that all agents' states are waiting states and each agent enters a waiting state exactly once. Then, the outline of the proof is described as follows. At first, we construct configuration c t by considering the adversarial scheduler. Then, we consider the placement of waiting agents in c t and show the unsolvability in any placement. If c t is a three-node three-waiting-agent configuration or a configuration such that there exists at most one waiting agent at each node, we can clearly show that agents cannot solve the g-partial gathering problem. Otherwise, we show that, in any placement of waiting agents in c t , there exists an execution by an adversarial scheduler such that the system reaches either 1) a three-node three-waiting-agent configuration, 2) a configuration such that there exists at most one waiting agent at each node, or 3) a configuration such that there exist two nodes with agents but there exist at most g − 1 waiting agents at one of them.
At first, we consider the execution until the system reaches the first configuration c t such that all agents are in waiting states. We consider an execution E t under the following fair scheduler α t that makes agents' movements as follows. First, α t activates all agents once. This makes all agents leave their initial nodes and be in transit; otherwise all agents enter waiting states at their initial nodes and cannot solve the g-partial gathering problem. Next, α t selects an agent a among heads of FIFO sequences of transiting agents in links, and activates a and a at the same time where a is an agent whose initial node is symmetric to that of a. By the definition of an atomic step, after a and a visit nodes and execute local computation, they enter waiting states or leave the nodes. Similarly, α t continues to activate a pair of such symmetric transiting agents at the same time. Eventually, all agents enter waiting states and they reach c t . Note that, in any algorithm, each agent necessarily enters a waiting state in finite time (otherwise, if an agent never enters a waiting state, the agent moves in the tree network forever). Hence, scheduler α t is fair because the system reaches configuration c t in finite number of agents' steps. Then, since agents are initially placed symmetrically and move symmetrically, it follows that if there exist l waiting agents at a node v in c t , there also exist l waiting agents at node v . Thus we can denote the nodes where agents exist in c t by v 1 , . . . , v s , v 1 , . . . , v s . In addition, let N l (resp., N l ) be the number of waiting agents at v l (resp., v l ) in c t . Clearly, N l = N l (1 ≤ l ≤ s) and N 1 + N 2 + · · · + N s = k/2 hold. Without loss of generality, we assume that order. We consider the following eight cases depending on values of . . , N s ), and show that agents cannot solve the g-partial gathering problem in any case (contradiction). Fig. 3 represents the classification depending on values of N 1 and N 2 . In addition, Case 7 considers N 1 = N 2 = 2 and N 3 = 1, and Case 8 considers Case 1: N 2 ≥ 3 holds. In this case, there exist at least three waiting agents at each of v 1 , v 2 , v 1 and v 2 (three-node three-waiting-agent configuration). Hence from Lemma 2, there exist at least four nodes where agents exist at the end of algorithm execution. However, since k = 3g − 1 holds, agents are allowed to meet at one or two nodes. This contradicts the assumption that agents can solve the g-partial gathering problem.
In this case, there exist no nodes where more than one agents exist in c t . From the definition of a waiting state, the local configuration of each agent does not change and each agent never leaves the current node. This contradicts the assumption.
Before considering Case 3, we introduce the notion of elimination. Let us select a set of agents A elimi such that both In addition, let c elimi 0 be the configuration obtained from c 0 by eliminating all agents in A elimi in c 0 . Moreover we define an execution E elimi t as follows: When in E t the scheduler activates sets of agents A 0 , A 1 , . . . , A t−1 in this order and the system reaches c t , then in E elimi t the scheduler activates sets of agents  Proof. We prove the lemma for the case of |A elimi | = 1. Then, we can similarly prove the lemma for the case |A elimi | ≥ 2 by applying the following argument to each of A elimi one by one. Let a j i (2 ≤ i ≤ N j ) be the unique agent in A elimi . In this case, we show that the locations and states of agents in A − A elimi in c elimi l (0 ≤ l ≤ t) are equal to those in c l . At first, we denote by c p the configuration in E t immediately after a j i enters a waiting state at v j . Note that a j i enters a waiting state without being observed by any other agents. This is because 1) multiple agents do not exist at the same node in the initial configuration, 2) by the definition of scheduler α t , a j i leaves its initial node before any other agents visit the node, and 3) until c p , a j i reaches some node v, executes local computation, and leaves v in an atomic step, that is, a j i never waits at any node before c p . In addition, in c p there already exist waiting agents a is an agent in the waiting state at some node v bi (v bi ) where no other agents exist (note that b i can leave v bi when b i−1 arrives at v bi and enters a waiting state), and are activated at the same time, and behave symmetrically.
Finally, agents b h−1 and b h−1 enter waiting states at v 2 and v 2 , respectively. We call such a configuration c elimi x . An example is shown in Fig. 4. In the figure, we assume that agents a 2 2 and a 2 2 of the dotted lines are eliminated. In addition, the black agents a 1 2 , a 1 3 , a 1 2 , and a 1 3 never leave the current nodes by the end of the algorithm. In Fig. 4, agents a 1 1 and a 1 1 move symmetrically and enter waiting states at v 3 and v 3 , respectively ( Fig. 4 (b)). After this, agents a 3 1 and a 3 1 move symmetrically and enter waiting states at v 2 and v 2 , respectively ( Fig. 4 (c) to Fig. 4 (d)). Now, let us consider c t . In c t , there exist two waiting agents a 2 1 and a 2 2 (a 2 1 and a 2 2 , respectively) at v 2 (v 2 ). In addition, since a 2 1 (a 2 1 ) is the first agent that enters a waiting state at v 2 (v 2 ), a 2 1 (a 2 1 ) can leave v 2 (v 2 ). However we consider the execution E x similarly to E elimi  Fig. 4 (f)). After this, agents a 3 1 and a 3 1 move symmetrically and enter waiting states at v 2 and v 2 , respectively ( Fig. 4 (g) to Fig. 4 (h)). Then there exist three waiting agents a 2 1 , a 2 2 , and a 3 1 (a 2 1 , a 2 2 , and a 3 1 , respectively) at v 2 (v 2 ), and agents a 2 2 and a 3 1 (a 2 2 and a 3 1 , respectively) never leave the current node by Lemma 2. Note that, agents a 1 2 , a 1 3 , a 1 2 and a 1 3 also never leave the current nodes v 1 and v 1 . Thus in c x , there exist four nodes where agents exist and never leave the current nodes (three-node three-waiting-agent configuration), which is a contradiction.
From Case 4 to Case 6, we consider cases that there exist at least two waiting agents a 1 1 and a 1 2 (a 1 1 and a 1 2 , respectively) at v 1 (v 1 ), and there exists at most one waiting agent at the other nodes. . This configuration is the same as the Case 2 and agents cannot solve the g-partial gathering problem. 2 From Case 6 to Case 8, we consider a configuration obtained from c 0 by eliminating at least four agents, and we cannot apply this way for the case of 2 ≤ g ≤ 4. 3 Execution E x is fair because the system reaches configuration c x in finite number of agents' steps. Similarly, we can show that schedulers or executions we consider in the rest of this section are fair. Case 5: (g + 3)/2 ≤ N 1 ≤ g and N 2 = 1 hold.
In this case, we consider the initial configuration c elimi 0 obtained from c 0 by eliminating agents a 1 2 , . . . , a 1 N 1 . Note that, the number of eliminated agents a 1  Fig. 5 (b)), and after this, agent a 3 1 moves and enters a waiting state at v 3 (Fig. 5 (c)).   Fig. 5 (e)). After this, agent a 3 1 leaves v 3 and enters a waiting state at v 3 ( Fig. 5 (f)). Then there exist three waiting agents a 3 1 , a 1 1 , and a 3 1 at v 3 , and agents a 1 1 and a 3 1 never leave v 3 . Note that, agents a 1 2 , a 1 3 , a 1 2 and a 1 3 also never leave the current nodes v 1 and v 1 . Thus in c y , there exist three nodes where agents exist at the end of algorithm execution (three-node three-waiting-agent configuration), which is a contradiction.
In this case, agents are allowed to meet at v 1 or v 1 . As a way to satisfy this, we consider an execution E x from c t to c x , where each agent moves symmetrically until they enter waiting states at v 1 or v 1 in c x . Then, there exist (3g − 1)/2 agents at v 1 and v 1 , respectively.  . This configuration is the same as the Case 2 and agents cannot solve the g-partial gathering problem.
In this case, there are two waiting agents at v 1  where there exist two waiting agents a 1 1 and a 1 2 (a 1 1 and a 1 2 , respectively) at v 1 (v 1 ) and one waiting agent at v 2 , v 3 , v 2 , and v 3 , respectively. In this configuration, it is necessary that some agent enters a waiting state at v 2 , v 3 , v 2 and v 3 in order to meet there or to make the waiting agents leave the current nodes. Without loss of generality, we assume that at first some agents enter waiting states at v 2 and v 2 , respectively. After this, we assume that some agents enter waiting states at v 3 and v 3 , respectively. To do this, we consider an execution E elimi We call such a configuration c elimi x . Then, local configurations of a 2 1 and a 2 1 change and they can leave the current nodes. For example in Fig. 6, agent a 1 1 (a 1 1 ) leaves v 1 (v 1 ) and directly enters a waiting state at v 2 (v 2 ) ( Fig. 6 (a) to Fig. 6 (b)). Moreover after c elimi and v d( j+1) , respectively. Note that at node v d( j+1) , we assume that there exists a waiting agent d j+1 . Then, local configurations of agents d j+1 and d j+1 change. Finally, agents d i−1 and d i−1 enter waiting states at v 3 and v 3 , respectively. We call such a configuration c elimi y . For example in Fig. 6, agent a 2 1 (a 2 1 ) leaves v 2 (v 2 ) and directly enters a waiting state at v 3 (v 3 ) (Fig. 6  (b) to Fig. 6 (c)). Now let us consider c t . In c t , agents a 1 1 , a 2 1 , a 3 1 , a 1 1 , a 2 1 and a 3 1 can leave the current nodes. However we consider the execution E x similarly to E elimi x , that is, agents b 1 and b 1 , b 2 and b 2 , . . . , b h−1 and b h−1 are activated and behave symmetrically in this order, while agents a 2 1 and a 2 1 are not activated. Finally, agents b h−1 and b h−1 enter waiting states at v 2 and v 2 , respectively. We call such a configuration c x . Then there exist three waiting agents a 2 1 , a 2 2 , and b h−1 (a 2 1 , a 2 2 , and b h−1 , respectively) at v 2 (v 2 ), and a 2 2 and b h−1 (a 2 2 and b h−1 , respectively) never leave the current node. For example in Fig. 6, agent a 1 1 (a 1 1 ) leaves v 1 (v 1 ) and directly enters a waiting state at v 2 (v 2 ) (Fig. 6 (d) to Fig. 6 (e)). Then there exist three waiting agents a 2 1 , a 2 2 , and a 1 1 (a 2 1 , a 2 2 , and a 1 1 , respectively) at v 2 (v 2 ), and a 2 2 and a 1 1 (a 2 2 and a 1 1 , respectively) never leave the current node. Moreover after this, we consider the execution E y similarly to E elimi y , that is, agents d 1 and d 1 , , and a 2 1 , respectively) at v 3 (v 3 ), and a 3 2 and a 2 1 (a 3 2 and a 2 1 , respectively) never leave the current node. Thus in c y there exist four nodes where agents exist at the end of algorithm execution (three-node three-waiting-agent configuration). This contradicts that agents can solve the g-partial gathering problem. Therefore, we have the theorem. 2

Strong multiplicity detection and non-token model
In this section, we consider a deterministic algorithm to solve the g-partial gathering problem for Model 2 in Table 1, that is, the strong multiplicity detection and non-token model. We propose a deterministic algorithm to solve the g-partial gathering problem in O (kn) total moves. Recall that, in the strong multiplicity detection model, each agent can count the number of agents at the current node.
At the beginning, each agent performs a basic walk [9]. In the basic walk, each agent a h leaves the initial node through the port 0. Later, when a h visits a node v j through the port p of v j , a h leaves v j through the port (p + 1) mod d v j . The basic walk allows each agent to traverse the tree in the DFS-traversal. Hence, when each agent visits nodes 2(n − 1) times, it visits all the nodes and returns to the initial node. Remind that nodes are anonymous and agents do not know the number n of nodes. However, if an agent records the topology of the tree it ever visits, it can detect that it visits all the nodes and returns to the initial node. Concretely, in the DFS-traversal, every time each agent a h visits a node for the first time, it obtains the port number used to enter and pushes it a stack. When a h leaves the current node through the port p, it compares p with the number p in the head of the stack. If p = p holds, a h removes p from the stack and this means that a h moves closer to its initial node. Otherwise, it means that a h moves further from its initial node. When a h visits some node and the stack becomes empty, it means that a h returns to its initial node. Moreover, if there exists no port p incident to its initial node such that a h does not leave its initial node through p, it can detect that it observed all the nodes in the tree. The idea of the algorithm is as follows: First, each agent performs the basic walk until it obtains the whole topology of the tree. Next, each agent computes a center node of the tree and moves there to meet other agents. If the tree has exactly one center node, then each agent moves to the center node and terminates the algorithm. If the tree has two center nodes, then each agent moves to one of the center nodes so that at least g agents meet at each center node. Concretely, agent a h first moves to the closer center node v j . If there exist at most g − 1 agents except for a h , then a h terminates the algorithm at v j . Otherwise, a h moves to another center node v j and terminates the algorithm.
The pseudocode is described in Algorithm 1. We have the following theorem. Proof. At first, we show the correctness of the algorithm. From Algorithm 1, if the tree has one center node, agents go to the center node and agents solve the g-partial gathering problem obviously. Otherwise, each agent a h first moves to one of the center nodes. If there already exist g or more agents at the center node, a h moves to the other center node. Since k ≥ 2g holds, agents can solve the g-partial gathering problem.
Next, we analyze the total number of moves. At first, agents perform the basic walk and record the topology of the tree.
This requires at most 2(n − 1) total moves for each agent. Next, each agent moves to one of the center nodes, and terminates Algorithm 1 The behavior of active agent a h (v j is the current node of a h ).
Main Routine of Agent a h 1: perform the basic walk until it obtains the whole topology of the tree 2: if there exists exactly one center node then 3: go to the center node via the shortest path and terminate the algorithm 4: else 5: go to the closest center node via the shortest path 6: if there exist at most g − 1 agents except for a h then 7: terminate the algorithm 8: else 9: move to the other center node 10: terminate the algorithm 11: end if 12: end if the algorithm. This requires at most n 2 + 1 moves for each agent. Hence, each agent requires O (n) total moves. Therefore, agents require O (kn) total moves. 2

Weak multiplicity detection and removable-token model
In this section, we consider the g-partial gathering problem for Model 3 in Table 1, that is, the weak multiplicity detection and removable-token model. We show that agents can achieve the g-partial gathering in asymptotically optimal total moves (i.e., O (gn)) by using only one removable token of each agent. Recall that, in the removable-token model, each agent has a token. In the initial configuration, each agent leaves a token at the initial node. We define a token node (resp., a non-token node) as a node that has a token (resp., does not have a token). In addition, when an agent visits a token node, the agent can remove the token.
The idea of the algorithm is similar to [11], which considers the g-partial gathering problem for distinct agents (i.e. having IDs) in unidirectional ring networks with whiteboards. The algorithm in [11] consists of two parts: the leader election and leaders' instructions. In the first part, agents execute the leader agent election partially using their IDs and whiteboards.
Then, there exist at least g − 1 non-leader agents between two leader agents. In the second part, each leader agent moves in the ring and instructs non-leader agents which node they should meet at by using whiteboards. After this, non-leader agents move to their gathering nodes by the instruction. When applying the above idea to the model in this section, there exist two problems. The first is the difference of network topology, that is, [11] considers unidirectional ring networks but in this paper we consider tree networks. The second is the difference of agents' and nodes' ability, that is, in [11] agents have distinct IDs and each node has a whiteboard but in this paper agents have no IDs and each node is allowed to only have at most one removable token. The first problem is solved by embedding the unidirectional ring in the tree network, and we explain this in the next paragraph. The second problem is solved by the combination of port numbers and removable-tokens, and we explain this in Section 6.1 and 6.2. Now, we explain the way to embed the ring from the tree network. Agents perform the basic walk and embed a unidirectional ring network in the tree network by the Euler tour technique. Concretely, letting v 0 , v 1 , . . . , v 2(n−1) (= v 0 ) be the node sequence such that agent a h visits the nodes in this order in the basic walk starting at v 0 , we can regard that a h moves in the unidirectional ring network with 2(n − 1) nodes. Later, we call this ring the virtual ring. In the virtual ring, we define the direction from v i to v i+1 as a forward direction, and the direction from v i+1 to v i as a backward direction. For simplicity in the virtual ring, operations to an index of a node assume calculation under modulo 2(n − 1), that is, v (i+1) mod 2(n−1) is simply represented by v i+1 . In addition in the virtual ring, we define the neighboring agent of a h as the first agent in a h 's forward (backward) direction, i.e., there exist no agents between them. Moreover, when a h visits a node v j through a port p of v j from a node v j−1 in the virtual ring, agents also use p as the port number of (v j−1 , v j ) at v j . For example, let us consider a tree in Fig. 7 (a). Agent a h performs the basic walk and visits nodes a, b, c, b, d, b in this order. Then, the virtual ring of Fig. 7 (a) is shown in Fig. 7 (b). Each number in Fig. 7 (b) represents the port number through which a h visits each node in the virtual ring. Next, we define a token node in a virtual ring. At the beginning of the algorithm, each agent a h leaves its token node through the port 0 in the basic walk. Thus, when a h visits some token node in the tree such that a h leaves there through the port 0 in the next movement, that is, when a h visit some token node v j through the port (d v j − 1), a h regards the node as the token node in the virtual ring. In Fig. 7 (a), if nodes a and b are token nodes, then in Fig. 7 (b), nodes a and b are token nodes. By this definition, a token node in the tree network is mapped to exactly one token node in the virtual ring. Thus, by performing the basic walk, we can regard that all agents move in the same virtual ring although agents start the algorithm at different nodes. This is because the virtual ring starting at some node in the tree is actually represented by a port sequence P , and the virtual ring starting at other nodes in the same tree can be represented by the cyclic transformation of P . In Fig. 7, the virtual ring starting at a h 's initial node is represented by 001020. On the other hand, the virtual ring starting at another token node b is represented by 000102, and this sequence can be also represented by the cyclic transformation of 001020. Moreover, in the virtual ring, each agent also moves in a FIFO manner, that is, when an agent a h leaves some node v j before another agent a i , a h arrives at v j+1 before a i . In the following section, we explain the algorithm on the virtual ring. Note that we can show the asymptotical equivalence in terms of total moves between a tree and a virtual ring, because a tree with n nodes is regarded as a virtual ring with 2n − 1 nodes. The algorithm consists of two parts. In the first part, agents elect some leader agents by partially executing the leader agent election algorithm. In the second part, the leader agents instruct the other agents which node they should meet at, and the other agents move to the node.

The first part: leader election
In this section, we explain how to elect multiple leader agents. Note that, in this part no token is removed. In the leader agent election, each agent takes a state from the following three states: • active: The agent is performing the leader agent election as a candidate for leaders. • inactive: The agent has dropped out from the set of the leader candidates.
• leader: The agent has been elected as a leader.
The aim of the first part is similar to [11], that is, to elect some leaders and satisfy the following two properties: 1) At least one agent is elected as a leader, and 2) in the virtual ring, there exist at least g − 1 inactive agents between two leader agents.
At first, we explain the idea of the leader election in [11] to adopt it in this paper. In [11], the network is a unidirectional ring, each agent is distinct, and each node has a whiteboard. First, we explain the idea under the assumption that the ring is bidirectional for intuitively understanding. Later, we apply the idea to the unidirectional ring. The algorithm consists of several phases. In each phase, each active agent compares its own ID with IDs of its forward and backward neighboring active agents. More concretely, each active agent writes its ID on the whiteboard of its current node, and then moves forward and backward to observe IDs of the forward and backward active agents. If its own ID is the smallest among the three agents, the agent remains active (as a candidate for leaders) in the next phase. Otherwise, the agent drops out from the candidate for the set of leader candidates and becomes inactive. Note that, in each phase, neighboring active agents never remain as candidates for leaders. Hence at least half of the currently active agents become inactive in each phase, that is, the number of inactive agents between two active agents at least doubles in each phase. Then from [23], after executing j phases, there exists at least 2 j − 1 inactive agents between two active agents. Thus, after executing log g phases, the following properties are satisfied: 1) At least one agent remains as a candidate for leaders, and 2) the number of inactive agents between two active agents is at least g − 1. Therefore, all the remaining active agents become leaders.
Next, we implement the above algorithm in asynchronous unidirectional rings by using a traditional approach [23]. Let us consider active agent a h . In unidirectional rings, a h cannot move backward or observe the ID of its backward active agent. Instead, a h moves forward until it observes IDs of two active agents. Then, a h observes IDs of three successive active agents. We assume a h observes id 1 , id 2 , id 3 in this order. Note that id 1 is the ID of a h . Here this situation is similar to that in which the active agent with ID id 2 observes id 1 as its backward active agent and id 3 as its forward active agent in a bidirectional ring. For this reason, a h behaves as if it would be an active agent with ID id 2 in the bidirectional ring. That is, if id 2 is the smallest among the three IDs, a h remains active as a candidate for leaders. Otherwise, a h drops out from the set of leader candidates and becomes inactive.
In the following, we explain the way to apply the above leader election to anonymous agents in the weak multiplicity detection and removable-token model. First, we explain the treatment about IDs. For explanation, let active nodes be nodes where active agents start execution of each phase. In this section, agents use virtual IDs in the virtual ring. Concretely, when agent a h moves from an active node v j to v j 's forward active node v j , a h observes port sequence p 1 , p 2 , . . . p l , where p m is the port number at v j+m through which a h visits the m-th node v j+m after leaving v j . In this case, a h uses this port sequence p 1 , p 2 , . . . p l as its virtual ID. For example, in Fig. 7 (b), when a h moves from a to b , a h observes the port  Fig. 8. An example that agents observe the same port sequence. numbers 0, 0, 1, 0, 2 in this order. Hence, a h uses 00102 as a virtual ID from a to b . Similarly, a h uses 0 as a virtual ID from b to a. Note that, multiple agents may have the same virtual IDs, and we explain the behavior in this case later. Next, we explain the treatment of whiteboards by using removable tokens. Fortunately, we can easily overcome this problem if agents can detect active nodes. Concretely, each active agent a h moves until a h visits three active nodes. Then, a h observes its own virtual ID, the virtual ID of a h 's forward active agent a i , and the virtual ID of a i 's forward active agent a j . Thus, a h can obtain three virtual IDs id 1 , id 2 , id 3 without using whiteboards. Therefore, agents can use the above approach for a unidirectional ring, that is, a h behaves as if it would be an active agent with ID id 2 in a bidirectional ring. In the rest of this paragraph, we explain how agents detect active nodes. In the beginning of the algorithm, each agent starts the algorithm at a token node and all token nodes are active nodes. After each agent a h visits three active nodes, a h decides whether a h remains active or drops out from the set of leader candidates at the active (token) node. If a h remains active, then a h starts the next phase and leaves the active node. Thus, in some phase, when some active agent a h visits a token node v j where no agents exist, a h knows that a h visits an active node and the other nodes are not active in the phase.
After observing three virtual IDs id 1 , id 2 , id 3 , each active agent a h compares virtual IDs by the lexicographical order and decides whether a h remains active (as a candidate for leaders) in the next phase or not. Different from [11], multiple agents may have the same IDs. To treat this case, if id 2 < min(id 1 , id 3 ) or id 2 = id 3 < id 1 holds, then a h remains active as a candidate for leaders. Otherwise, a h becomes inactive and drops out from the set of leader candidates. For example, let us consider the initial configuration of Fig. 8 (a). In the figure, black nodes are token nodes and the numbers near communication links are port numbers. The virtual ring of Fig. 8 (a) is shown in Fig. 8 (b). For simplicity, we omit non-token nodes in Fig. 8 (b). The numbers in Fig. 8 (b) are virtual IDs. Each agent a h continues to move until a h visits three active nodes. By the movement, a 1 observes three virtual IDs (01, 01, 01), a 2 observes three virtual IDs (01, 01, 1000101010), a 3 observes three virtual IDs (01, 1000101010, 01), and a 4 observes three virtual IDs (1000101010, 01, 01), respectively. Thus, a 4 remains as a candidate for leaders, and a 1 , a 2 , and a 3 drop out from the set of leader candidates. Note that, like Fig. 8, if an agent observes the same virtual IDs three times, it drops out from the set of leader candidates. This implies, if all active agents have the same virtual IDs, all agents become inactive. However, we can show that, when there exist at least three active agents, it does not happen that all active agents observe the same virtual IDs. Thus in each phase, at least the half of active agents become inactive, and we show this later (Lemma 5). Moreover, if there are only one or two active agents in some phase, then the agents notice the fact during the phase. In this case, the agents immediately become leaders. By executing log g phases, agents complete the leader agent election.
Pseudocode. The pseudocode to elect leaders is given in Algorithm 2. All agents start the algorithm with active states. The pseudocode describes the behavior of active agent a h , and v j represents the node where agent a h currently stays. If agent a h becomes inactive or a leader, a h immediately moves to the next part and executes the algorithm for an inactive state or a leader state in Section 6.2. In Algorithm 2, a h uses the following variables: • id 1 , id 2 , and id 3 are variables for storing three virtual IDs.
• phase is a variable for storing its own phase number.
In Algorithm 2, each active agent a h moves until a h observes three virtual IDs and decides whether a h remains active as a candidate for leaders or not on the basis of the virtual IDs. Note that, since each agent moves in a FIFO manner, it does not happen that some active agent passes another active agent in the virtual ring, and each active agent correctly observes three neighboring virtual IDs in the phase. In Algorithm 2, a h uses procedure NextActive(), by which a h moves to the next active node and returns the port sequence as a virtual ID. The pseudocode of NextActive() is described in Procedure 1. In NextActive, a h uses the following variables:

Algorithm 2
The behavior of active agent a h (v j is the current node of a h ).

Variables for Agent a h
Main Routine of Agent a h 1: phase = phase + 1 2: id 1 = Next Active() 3: id 2 = Next Active() 4: id 3 = Next Active() 5: if the number of active agents in the tree is two or less then 6: change its state to a leader state 7: break Algorithm 2 8: end if  leave v j through the port (p + 1) mod d v j // arrive at the forward node and v j is updated 8: let p be the port number through which a h visits v j 9: • port is an array for storing a virtual ID. • move is a variable for storing the number of nodes it visits.
During the basic walk, each active agent visits active node v j through the port (d v j − 1). Thus, when agent a h leaves active node v j , it always uses the port 0 (line 2 in Procedure 1).
Note that, if there exist only one or two active agents in some phase, then the agent travels once around the virtual ring before getting three virtual IDs. In this case, the active agent knows that there exist at most two active agents in the phase and they become leaders (lines 5 to 8 in Algorithm 2). To do this, agents record the topology every time they visit nodes, but we omit the description of this behavior in Algorithm 2 and Procedure 1.
First, we show the following lemma to show that at least one agent remains active or becomes a leader in each phase. 1. The length of T is q.
2. The length of T is 2q.

The length of T is greater than kq. 2
We show the lemma by contradiction, that is, assume that there exist k ≥ 3 active agents in some phase and all the k active agents have the same virtual IDs. Let x be the virtual ID. Then, t [1..|x|] = x holds. In addition, when each active agent moves in the tree and observes one virtual ID x, each link in the virtual link is passed by exactly once. Hence, t[( |x| + 1)..( + 1)|x|] = x holds (0 ≤ ≤ k − 1) and t[1..k |x|] = (t [1..|x|]) k holds. Moreover, in this case the total number of their moves (i.e., k |x|) is equal to the length of the tree. If x is aperiodic, the length of the tree is k |x|. However from Theorem 7, the length of the tree is never k |x|, which is a contradiction. If x is periodic, t [1..|x|] = (t [1..|x |]) s holds for some x and s (x is aperiodic). Then, t[1..k |x|] = t([1..|x |]) k s holds and the length of the tree is k s|x |(= k |x|). However, from Theorem 7, the length of the tree is never k s|x |, which is also a contradiction. 2 Next, we have the following lemmas about Algorithm 2.
Lemma 5. Algorithm 2 eventually terminates, and satisfies the following two properties.
• There exists at least one leader agent. • In the virtual ring, there exist at least g − 1 inactive agents between two leader agents.
Proof. We show the lemma in the virtual ring. Obviously, Algorithm 2 eventually terminates. In the following, we show the above two properties.
At first, we show that there exists at least one leader agent. From lines 5 to 7 of Algorithm 2, when there exist only one or two active agents in some phase, the agents become leaders. We assume that in some phase, active agent a h observes three IDs a h .id 1 , a h .id 2 , and a h .id 3 in this order. When there are three or more active agents in some phase, if 1 holds, agent a h remains as a candidate for leaders, and otherwise a h drops out from the set of leader candidates. Thus, unless all agents observe the same virtual IDs, at least one agent remains active as a candidate for leaders. From Lemma 4, it does not happen that all agents observe the same virtual IDs. Therefore, there exists at least one leader agent.
Next, we show that there exist at least g − 1 inactive agents between two leader agents in the virtual ring. At first, we show that in each phase, at least half of active agents become inactive. In each phase, if a h .id 2 < min (a h .id 1 , a h .id 3 ) or a h .id 2 = a h .id 3 < a h .id 1 holds, a h remains as a candidate for leaders. If the agent a h satisfies a h .id 2 < min(a h .id 1 , a h .id 3 ), then the a h 's backward and forward active agents drop out from the set of leader candidates. In the following, we consider the case that agent a h satisfies a h .id 2 = a h .id 3 < a h .id 1 . Let a h be a a h 's backward active agent and a h be a a h 's forward active agent. Agent a h observes three virtual IDs a h .id 1 , a h .id 2 , a h .id 3 , and both a h .id 2 = a h .id 1 and a h .id 3 = a h .id 2 hold. Hence, a h .id 2 > a h .id 3 holds, and a h drops out from the set of leader candidates. Next, a h observes three virtual IDs a h .id 1 , a h .id 2 , a h .id 3 , and both a h .id 1 = a h .id 2 and a h .id 2 = a h .id 3 hold. Since a h .id 1 = a h .id 2 holds, a h does not satisfy the condition to remain as a candidate for leaders and drops out from the candidate. Thus in each phase, at least half of active agents drop out from the set of leader candidates and become inactive. Now, we show that there exist at least g − 1 inactive agents between two leader agents. We firstly show that after executing j phases, there exist at least 2 j − 1 inactive agents between two active agents. We show this by induction. For the case of j = 1, there exists at least 2 1 − 1 = 1 inactive agent between two active agents as mentioned above. For the case of j = k, we assume that there exist at least 2 k − 1 inactive agents between two active agents. After executing k + 1 phases, since at least one of neighboring active agents becomes inactive, the number of inactive agents between two active agents is at least (2 k − 1) Hence, after executing j phases, there exist at least 2 j − 1 inactive agents between two active agents. Therefore, after executing log g phases, there exist at least g − 1 inactive agents between two leader agents in the virtual ring. 2 Lemma 6. Algorithm 2 requires O (n log g) total moves.
Proof. In the virtual ring, each active agent moves until it observes three virtual IDs in each phase. This requires at most O (n) total moves because each communication link of the virtual ring is passed by at most three agents (including the same agent if only one or two active agents exist) and the length of the ring is 2(n − 1). Since agents execute log g phases, we have the lemma. 2

The second part: leaders' instruction and agents' movement
In this section, we explain the second part, i.e., an algorithm to achieve the g-partial gathering by using the elected agents. Let leader nodes (resp., inactive nodes) be the nodes where agents become leaders (resp., inactive agents). Note that all leader nodes and inactive nodes are token nodes. In this part, each agent takes one of the following three states: Fig. 9. Partial gathering in the removable-token model for the case of g = 3 (a 1 and a 2 are leaders, and black nodes are token nodes).
• leader: The agent instructs inactive agents where they should move.
• inactive: The agent waits for the leader's instruction.
• moving: The agent moves to its gathering node.
We explain the idea of the algorithm in the virtual ring. The basic movement is also similar to [11], that is, to divide agents into groups each of which consists of at least g agents. While in [11], each node has a whiteboard, in this section each node is allowed to only have a removable token. Each leader agent a h moves to the next leader node, and during the movement a h repeats the following behavior: a h removes tokens of inactive nodes g − 1 times consecutively and then a h does not remove a token of the next inactive node. The behavior guarantees that at least g − 1 agents exist between any two token nodes when all the leaders complete the behavior. After that, agents move to the nearest token nodes, which guarantees that at least g agents meet at each token node.
First, we explain the behavior of leader agents. Whenever leader agent a h visits an inactive node v j , it counts the number of inactive nodes (including the current node) that a h has visited. If the number plus one is not a multiple of g, a h removes a token at v j . Otherwise, a h does not remove the token and continues to move. Agent a h continues this behavior until a h visits the next leader node v j (Later, explain how a h detects whether it visits the next leader node v j or not). After that, a h removes a token at v j . When all the leaders complete this behavior, there exist at least g − 1 inactive agents between two token nodes. Hence, agents solve the g-partial gathering problem by moving to the nearest token node (This is done by changing their states to moving states). For example, let us consider the configuration of Fig. 9 (a) (g = 3). We assume that a 1 and a 2 are leader agents and the other agents are inactive agents. In Fig. 9 (b), a 1 visits node v 2 and a 2 visits node v 4 , respectively. The number near each node represents the number (modulo g) of inactive nodes that a 1 or a 2 has ever visited. Then, agents a 1 and a 2 remove tokens at v 1 and v 3 , and do not remove tokens at v 2 and v 4 , respectively. After that, a 1 and a 2 continue this behavior until they visit the next leader nodes. At the leader nodes, they remove the tokens (Fig. 9 (c)).
When a token at v j is removed, an inactive agent at v j changes its state to a moving state and starts to move. Concretely, each moving agent moves to the nearest token node v j . Note that, since each agent moves in a FIFO manner, it does not happen that a moving agent passes a leader agent and terminates at some token node before the leader agent removes the token. After all agents complete their own movements, the configuration changes from Fig. 9 (c) to Fig. 9 (d) and agents can solve the g-partial gathering problem. Note that, since each agent moves in the same virtual ring in a FIFO manner, it does not happen that an active agent executing the leader agent election passes a leader agent and that a leader agent passes an active agent.
Pseudocode. In the following, we show the pseudocode of the algorithm. The pseudocode of leader agents is described in Algorithm 3. Variable tCount is used to count the number of inactive nodes a h has ever visited. When a h visits a token node v j where another agent exists, v j is an inactive node because an inactive agent becomes inactive at a token node and agents move in a FIFO manner. Whenever each leader agent a h visits an inactive node, a h increments the value of tCount.
At inactive node v j , a h removes a token at v j if tCount = g − 1 (does not remove a token otherwise) and continues to move (lines 5 to 9). This guarantees that, if a token at inactive node v j is not removed, at least g agents meet at v j . When a h removes a token at v j , an inactive agent at v j changes its state to a moving state (line 7). When a h visits a token node v j where no agents exist, v j is the next leader node. This is because token nodes are leader nodes or inactive nodes, and from an atomicity of the execution there exist no agents at each leader node. Note that also from an atomicity of the execution, it does not happen that some leader agent visits a leader node v such that another agent becomes a leader at v but still stays at v. When leader agent a h moves to the next leader node v j , a h removes a token at v j and changes its state to a moving state. In Algorithm 3, a h uses the procedure NextToken() to move to the next token node. The pseudocode of NextToken() is described in Procedure 2. In Procedure 2, a h performs the basic walk until a h visits a token node v j through the port The pseudocode of inactive agents is described in Algorithm 4. Inactive agent a h waits at v j until either a token at v j is removed or a h observes another agent. If the token is removed, a h changes its state to a moving state (lines 4 to 6). If a h observes another agent, the agent is a moving agent and terminates the algorithm at v j (lines 7 to 9). This means v j is selected as a token node where at least g agents meet at the end of the algorithm. Hence, a h terminates the algorithm at v j .
The pseudocode of moving agents is described in Algorithm 5. In the virtual ring, each moving agent a h moves to the nearest token node by using NextToken().

Algorithm 3
The behavior of leader agent a h (v j is the current node of a h ). remove a token at v j 7:

Variable in Agent
//an inactive agent at v j changes its state to a moving state 8: end if 9: NextToken() 10: end while 11: remove a token at v j // this is a leader node 12: change its state to a moving state Procedure 2 void NextToken() (v j is the current node of a h ). 1: leave v j through the port 0 // arrive at the forward node and v j is updated 2: let p be the port number through which a h visits v j 3: while (there does not exist a token) ∨ (p = d v j − 1) do

4:
leave v j through the port (p + 1) mod d v j // arrive at the forward node and v j is updated 5: let p be the port number through which a h visits v j 6: end while Algorithm 4 The behavior of inactive agent a h (v j is the current node of a h ). . . , v g l be inactive nodes that still have tokens after all leader agents complete their behaviors, and we call these nodes gathering nodes. From Algorithm 3, each leader agent a h removes the tokens at the consecutive g − 1 inactive nodes and does not remove the token at the next inactive node. By this behavior and Lemma 5, there exist at least g − 1 moving agents between v g i and v g i+1 . Moreover, these moving agents move to the nearest gathering node v g i+1 . Therefore, agents solve the g-partial gathering problem.

Main Routine of Agent
In the following, we evaluate the total number of moves required for the algorithms. At first, let us consider the total number of moves required for leader agents to move to the next leader nodes. This requires 2(n − 1) total moves since all leader agents travel once around the virtual ring. Next, let us consider the total number of moves required for moving (inactive) agents to move to the nearest token nodes (For example, the total number of moves form Fig. 9 (c) to Fig. 9 (d)). From Algorithm 5, each moving agent moves to the nearest gathering node. In the following, we show that the number of moving agents between some gathering node v g i and its forward gathering node v Therefore, we have the lemma. 2 From Lemma 6 and Lemma 7, we have the following theorem.

Theorem 8.
In the weak multiplicity detection and the removable-token model, our algorithm solves the g-partial gathering problem in O (gn) total moves. 2

Conclusion
In this paper, we considered the g-partial gathering problem in asynchronous tree networks. At first, in the non-token model we showed that agents require (kn) total moves to solve the g-partial gathering problem. After this, we considered three model variants. First, in the weak multiplicity detection and non-token model, for asymmetric trees agents can solve the g-partial gathering problem in O (kn) total moves by the previous result in [10], and we showed that there exist no algorithms to solve the g-partial gathering problem for symmetric trees. Second, in the strong multiplicity detection and non-token model, we proposed a deterministic algorithm to solve the g-partial gathering problem in O (kn) total moves.
Finally, in the weak multiplicity detection and removable-token model, we proposed a deterministic algorithm to solve the g-partial gathering problem in O (gn) total moves.
Open problems are as follows. The first is to consider the weak multiplicity detection and non-token model for symmetric trees (the same model as in Section 4) when the locations of agents are asymmetric or 2 ≤ g ≤ 4 holds. We conjecture that, even in this case, the g-partial gathering problem is not solvable by the similar discussion in Section 4. The second is to consider the g-partial gathering problem in general networks. We conjecture that in this model, the g-partial gathering problem can be solved efficiently in terms of total moves by the similar way to Section 6, that is, agents execute the leader agent election partially and elected leaders instruct non-leaders gathering nodes.