The efficient distribution of resources among agents is a frequent problem in Multi-Agent-Systems  with e. g. medical applications . These resources are often modeled as objects and sometimes they can be divided among agents and sometimes they are indivisible. One famous problem in this field is called House Marketing: Each of the participating agents initially owns one house (an indivisible object) and the agents can trade their houses in trade cycles with other agents [15, 17]. Versions of this problem were considered with different optimization criteria like pareto-optimality [2, 14, 18] or envy-freeness [5, 7, 9]. Gourves et al.  studied two similar problems where agents are only able to perform (pairwise) trades with agents they trust. This is modeled by a social network of the participating agents where an edge between two agents means that they trust each other. The first version is called Reachable Assignment: Can one reach a given target assignment by a sequence of rational swaps? A swap is rational if both participating agents obtains an object they prefer over their current object and the agents share an edge in the social network. The second version is called Reachable Object and the question is whether there is a sequence of rational swaps such that a given agent obtains a given target object.
Gourves et al.  showed that Reachable Assignment and Reachable Object are both NP-hard on general graphs. They further proved that Reachable Assignment is decidable in polynomial time if is a tree. Huang and Xiao  showed that if the underlying graph is a path, then Reachable Object can be solved in polynomial time. Moreover, they studied a version of Reachable Object that allows weak preference lists, i.e. an agent can be indifferent between different objects and shows that this problem is NP-hard even if the input graph is a path. Contributing to the Reachable Object problem, Saffidine and Wilczynski  proposed an alternative version of Reachable Object, called Guaranteed Level Of Satisfaction, where an agent is guaranteed to obtain an object at least as good as a given target object. They showed that Guaranteed Level Of Satisfaction is co-NP-hard. Finally, Bentert et al.  showed that Reachable Object is polynomial-time solvable if the input graph is a cycle and NP-hard even if the input graph is a clique, that is, all agents can trade with each other.
In our work, we will mainly focus on Reachable Assignment for the two special cases where the input graph is either a cycle or a clique. We show an -time algorithm for Reachable Assignment on -vertex cycles and further prove NP-hardness for Reachable Assignment on cliques. Figure 1 displays an example for a triangle, that is, a cycle (and a clique) of size three.
At the core of our hardness proof for cliques lies the combination of a reduction from Reachable Object to Reachable Assignment by Gouvres et al.  and the NP-hardness proof for Reachable Object on cliques by Bentert et al. . The polynomial-time algorithm for Reachable Assignment on cycles is shown in three steps. In the first step, we will show that once an object is swapped into either clockwise or counter-clockwise direction, it is impossible to swap it back into the opposite direction. Moreover, assigning a direction to each object is equivalent to providing a sequence of rational swaps. We will also show how to verify in polynomial time whether such an assignment corresponds to a solution. In this case, we will say that the assignment of directions yields the target assignment. In a second step, we show a characterization of assignments of directions that yield the target assignment. We call these direction assignments valid. In the third and final step, we will iterate over all edges in the input graph and construct for each iteration a 2-SAT formula that is satisfiable if and only if there exists a valid assignment of directions that corresponds to a solution in which the first swap is done over the iterated edge. Besides a novel characterization of instances that have a solution, our main technical contribution is a non-trivial reduction to 2-SAT. This approach to showing polynomial running times was used before [4, 12], but we believe that its potential is still relatively unexplored.
2 Preliminaries and Preprocessing
We use graph-theoretical notation in a similar way as Diestel . For a graph and a set of vertices , we use to denote the induced subgraph of in , that is, the graph where if and only if and . For two integers and we denote by the set of integers . If is a cycle, then we always assume that the agents are numbered from to , where , such that agent shares an edge with agents and . We also say that agent is the clockwise neighbor of agent and that agent is the counter-clockwise neighbor of agent . We denote by the sequence of clockwise neighbors starting from and ending in , that is,
Let . Then and .
We now formally define Reachable Assignment and Reachable Object. Let be a set of agents and let be a set of indivisible objects. Each agent has a preference list over a non-empty subset of the set of objects . Each preference list is a strict ordering on . The set of all preference lists is called a preference profile . A bijection is called an allocation or assignment. Akin to the house marketing problem , each agent is initially assigned exactly one object. We denote this initial assignment by and for the sake of simplicity, we will interchangeably use and for an agent , an object , and an assignment . Let be a graph where the set of vertices is the set of agents. We will use the term agents interchangeably with vertices of . A trade between agents and is only possible if their corresponding vertices share an edge in and if both and receive an object that they prefer over the objects they hold in the current assignment . We can express this formally by and and we call such a trade a rational swap. A sequence of rational swaps is a sequence of assignments where is the result of performing one rational swap in assignment for all . We call an assignment reachable if there exists a sequence of rational swaps . For an agent , an object is reachable if there exists an assignment and a sequence of rational swaps such that . Gourves et al.  introduced the problems Reachable Assignment and Reachable Object as follows.
|Input:||A set of agents, a set of objects, a preference profile , a graph , an initial assignment and a target assignment .|
|Question:||Is reachable from ?|
|Input:||A set of agents, a set of objects, a preference profile , a graph , an initial assignment , an agent and an object .|
|Question:||Is reachable for agent from ?|
Recall that assignments are bijections. This allows us for any assignment , any object and the agent with to denote by .
We end this section with a simple data reduction rule for Reachable Assignment. Whenever an agent prefers an object over the object it is assigned in the target assignment , then we can simply remove from its preference lists. This is due to the fact that once the agent possesses , then it cannot receive anymore. We will assume that every instance has already been preprocessed by the following data reduction rule, which is equivalent to assuming that assigns each agent its most preferred object.
Reduction Rule 1.
If for any agent with object there exists an object such that , then remove from .
3 A Polynomial-Time Algorithm for Reachable Assignment on Cycles
In this section we develop a polynomial-time algorithm for Reachable Assignment on cycles. To the best of our knowledge, this is the first polynomial-time algorithm for Reachable Assignment beyond the initial algorithm for trees by Gourves et al. . Our algorithm generalizes several ideas used in the algorithm for trees and uses a novel characterization of solutions. We divide the section into three subsections. In Subsection 3.1, we formally define what we mean by swapping an object in a certain direction and provide a polynomial-time algorithm to verify whether a given assignment of directions to all objects corresponds to a solution. In this case, we will say that the assignment of directions yields . In Subsection 3.2, we define a property we call validity and show that this characterizes the assignments of directions that yield . Finally in Subsection 3.3, we reduce the problem of deciding whether there exists a valid assignment of directions to 2-SAT.
3.1 Swapping Directions in a Cycle
In this subsection we will formally introduce assignments of directions. We will refer to them as selections and always denote them by . Consider an instance of Reachable Assignment. Let be an object, let , and let . Since the underlying graph is a cycle, there are exactly two paths between agents and for object . By definition of rational swaps, once has been swapped, say from agent to agent then is not able to return to agent since agent just received an object that it prefers over and will therefore not accept again. Hence, if is swapped again, then it is given to agent and the argument can be repeated for agent . As there are only two paths between agents and , there are also only two directions, namely clockwise and counter-clockwise. We will henceforth encode these directions into a binary number saying that the direction of is if is swapped in clockwise direction and otherwise. This yields the following definition of selections.
Let be an instance of Reachable Assignment. A selection of is a function that assigns each object a direction .
Given a selection , we say that an object is closer than another object with to , if starting from and going in direction , it holds that comes before . Therein, can be an edge, an agent, or a third object.
We will see that for a pair of objects (with assigned directions) there is a unique edge over which they can be swapped. To show this, we need the following definition of a path of an object. These paths consist of all agents that will hold the respective object in any successful sequence of swaps that respects the selection.
Let be a selection for instance and let and be two objects with . Let , let , let , and let . The path of for is
The set of shared paths of and for is the set of all connected paths in .111If , then contains two disjoint paths, one with as endpoint and one with . Finally, and are opposite if there exists a selection such that .
Examples for paths and shared paths are given in fig. 2.
With these definitions at hand, we are now able to determine unique edges where two objects and can be swapped with respect to all selections with .
Let be a selection for instance and and be two objects with . If for some path there is not exactly one edge in such that the corresponding preference lists allow and to be swapped between the two incident agents, then does not yield target assignment .
Note that and have to be swapped somewhere on each path in as otherwise at least one of the objects cannot reach its target agent. For each path there has to be at least one edge on where and can be swapped or does not yield the target assignment . Assume towards a contradiction that there are at least two edges and on some path where and can be swapped according to the corresponding preference lists and yields . Suppose and are swapped over in a sequence of rational swaps that yields (the case for is analogous). Then one of or must have already passed the other edge , say (again, the case for is analogous). Since and could be swapped over , it holds for the two agents and incident to that and . Since already passed , agent already held . Hence, agent will not accept object in the future and hence can not reach its destination as is on the path of . This contradicts the assumption that yields . ∎
We show that two objects and are swapped exactly once on each path in in any sequence of rational swaps and that . Examples with are given in fig. 2.
Let be a selection and let and be two objects with . There are at most two edges on such that and can only be swapped over these edges or does not yield target assignment . Each of these edges is on a different path in .
Let be any selection such that . Note that and cannot be swapped over any edge that is not on a path in and that by lemma 1 they have to be swapped over a specific edge for each path in . Hence the number of edges where and can be swapped over in any sequence of rational swaps that yield and that respects is equal to .
Now assume that . Then, and are swapped at least thrice. For and to perform a first swap, both of them must have at least passed one agent each. Observe that if and are swapped for a second time, then each agent has held or between the first and the second swap of and . Hence, after the second swap, they must have passed at least agents combined. Repeating this argument once again, we get that they must have passed passed agents after the third swap. This means that at least one of the agents has passed more than agents, a contradiction to the fact that an agent does not accept an object once the agent traded that object away. Thus, two objects can only be swapped twice and we can use lemma 1 to find at most two unique edges. ∎
Observe that only depends on and and hence for each selection with , it holds that and the edges specified in lemma 1 are the same for and . We will denote the set of edges specified in lemma 1 by . Note that proposition 1 also implies that if yields , then . If , then we define .
We next show that the order in which objects are swapped is irrelevant once a selection is fixed. We use the following definition to describe an algorithm that checks in polynomial time whether a selection yields .
Let be an instance of Reachable Assignment and let be selection of . Let and be two objects with . Let be the agent currently holding . If is held by agent , then and are facing each other and if also and , then and are in swap position.
Using the notion of swap positions, we are finally able to describe a polynomial-time algorithm that decides whether a given selection yields . We refer to our algorithm as Greedy Swap and pseudo code for it is given in algorithm 1. We mention that it is a generalization of the polynomial-time algorithm for Reachable Assignment on trees by Gourves et al. . Greedy Swap arbitrarily swaps any pair of objects that is in swap position until no such pair is left. If is reached in the end, then it returns True and otherwise it returns False.
Let be an instance of Reachable Assignment and let be a selection of . Greedy Swap returns True if and only if yields .
Observe that Greedy Swap only performs rational swaps and only returns True if is reached. Hence, if it returns True, then yields .
Now suppose that a selection yields assignment , but Greedy Swap returns False. Then either and every object is assigned the same direction, or there are two objects and , which are in swap position at some edge , but the corresponding preference lists do not allow a swap. In the former case clearly does not yield . In the latter case, consider the initial positions of and and the corresponding shared paths . Since and are in swap position at the point where Greedy Swap returns False, it holds that and there is a shared path such that is on .
If and meet at edge for the first time, then let be the number of objects that are closer to than and that are assigned direction . If and meet at edge for the second time, then let be the number of objects that are assigned direction . We will now show that has to be swapped with exactly objects before and can be swapped (for the first or between the first and the second swap, respectively). We will only show the case for and being swapped over for the first time as the other case is analogous when considering the instance after the first swap of and has just happened. Starting from the agent that initially holds we can then calculate the edge where and meet in every sequence of rational swaps that results in reaching the target assignment . Suppose can be swapped with more than objects before meeting at edge . Then must either be swapped with at least one object that is not closer to than or it must be swapped with the same object twice before being swapped with for the first time. This, however, means that will meet after , a contradiction. Now suppose that can be swapped with less than objects before meeting . Then there is an object that is closer to than and that is assigned direction and which is not swapped with before and are swapped. However, then will not be able to meet as at least is between them, a contradiction.
Now that we have shown that will swap exactly objects before meeting , we can also determine the edge where, given , they must necessarily meet, in every sequence of rational swaps where objects are swapped according to the directions assigned to them by . Now since we assumed that is reachable with selection , there must be a sequence of rational swaps where and must be swapped at edge . But since and met, by assumption, at edge , either , which is a contradiction because at the preference lists of the incident agents do not allow a swap between and , or and cannot have met at edge if all swaps were performed according to the directions assigned by selection , a contradiction to the definition of Greedy Swaps. ∎
3.2 Validity of Selections
We will next define a set of properties that a selection needs to fulfill in order for Greedy Swap to return True and then show that these properties are both necessary and sufficient. The idea is to have one property that guarantees that for each object and for each edge on its path there exists exactly one object that should be swapped with that object over this edge and a second property to guarantee that for each two objects and there are exactly edges where and should be swapped. Before we can formally state these properties, we give the following two definitions.
Let be an instance of Reachable Assignment. The set is the set of all object-edge-pairs and is the function that assign to each object-edge-pair the direction such that lies on the path of from its initial agent to its destination in direction .
Using the notion of object-edge-pairs, we define candidate lists. These will be used to eliminate possible choices for selections.
Let be an object-edge-pair and let be a selection. The candidate list of at edge and the size of with respect to is
Figure 3 presents an example of candidate lists.
Note that the size of with respect to is set to one if . This is due to the fact that we will later search for a selection such that for all objects and all edges with . This definition then avoids a case distinction. The following observation follows from proposition 1 and the observation that for all with and with a simple counting argument.
For each it holds that .
We can finally define the first property called exact from the set of properties that characterizes the selections for which Greedy Swap returns True and which, by proposition 2, correspond to a solutions for Reachable Assignment.
Let be an instance of Reachable Assignment. A selection is unambiguous if for all it holds that ; is complete if for all it holds that , and exact if .
Where exactness guarantees that for each object and for each edge on its path for there exists a possible swapping partner for this edge, the second property will guarantee that no pair of objects blocks one another in a selection. We start with the case in which an object blocks another object that is swapped in the same direction.
Let be a selection and let and be two objects with . Then shields in direction if , the object is closer to than the destination of (in direction ), and there exists an agent on with .
In fig. 3 the object shields in clockwise direction. Note that if shields in direction , then and cannot be both swapped in direction as the agent obtains first and then will not accept afterwards. However, by definition is on the path of and hence has to obtain or the target assignment cannot be reached.
We continue with the case where an object blocks another object that is swapped in the opposite direction. Based on lemma 1, we define compatibility of two objects.
Let be a selection and let and be two objects with . Then, and are compatible in selection if for each there exists exactly one edge on that is also contained in .
A selection is harmonic if for every object there is no object moving in direction that shields in that direction, and every object with direction is compatible with . A selection is valid, if it is both exact and harmonic.
In order to show that valid selections characterize those selections that correspond to a solution of Reachable Assignment, we start with an intermediate lemma.
Let be an instance of Reachable Assignment on cycle , let be a selection, let be two object-edge-pairs where and let be objects with direction . Let further and let . Let be the index such that starts closer to in direction than . If is harmonic, then is closer to in direction than . If is closer to in direction than , then shields .
Considering the preference lists at edges and we will denote the agents at by and and the agents at by and .
Suppose towards a contradiction that is closer to than in direction .
We distinguish between two cases. In the first case is harmonic. Then since and are assigned the same direction, and are not opposite. Further and cannot shield each other. Thus, it must hold that
because is on both and .
In the second case is not harmonic and there is some agent that will not accept since it prefers more and would be shielded from its destination by . Therefore we will now assume that is harmonic and show that then must be closer to in direction than .
Since can be swapped with at we know that
since arrives at and is then swapped with . However is further away from than and in order for to be swapped with at that edge we know
We also know that has already passed agent to get to and that must at least come to agent since otherwise could not reach its destination. Since can be swapped with at , its destination is at least agent . But if must move at least to it also must pass and since was there first we know that
because otherwise would shield from its destination which we know cannot be true as is harmonic. However, if those terms are true then
which cannot be true as is a strict ordering, a contradiction. ∎
We end this subsection with the statement that valid selections are exactly the selections that correspond to a solution of Reachable Assignment.
Let be an instance of Reachable Assignment and let be a selection for . Greedy Swap returns True on input if and only if is valid.
First we will prove that if is valid then Greedy Swap returns True. Let therefore be an object with path . We will prove that if is valid then is guaranteed to pass every edge of . Since is arbitrarily chosen we can generalize the statement to all objects. Now recall that Greedy Swap simply performs a swap between two objects that are in swap position over and over again. It only returns False if there are two objects in swap position at edge that cannot be swapped according to the preference lists of the agents that are incident to . If we prove for every object, at every edge on its path, that the corresponding preference lists always allow a swap, we know that Greedy Swap returns True.
Consider any edge on the path of . Let be the path starting with and ending at , that is, the path that still has to take after reaching . Let be the path that has already passed when reaching . Let be the object that meets at with . Suppose and cannot be swapped at due to the preference lists of their agents. Then either there exists no object that can be swapped with at edge in which case is incomplete, a contradiction, or there exists object with that can be swapped with at but starts closer to than . We will now show that if is not an edge where and can be swapped, then that leads to a contradiction.
First of all, since is harmonic there must be an edge on the shared path of and for where and can be swapped. We distinguish between two cases. If is on , then has already passed edge and there exist two objects with direction that can be swapped with at . Then, would be ambiguous, a contradiction. Otherwise is on but not equal to . But then the edge where and can be swapped at is further away from with respect to , than the edge where and can be swapped at, even though is closer to than , with respect to . But then due to lemma 2, is not harmonic, a contradiction. Thus we can conclude that and can be swapped at edge . Since we chose the edge to be arbitrary we can generalize this to all edges on . From this follows that reaches its destination. This can be generalized to all objects and thus, as described above, Greedy Swap returns True.
Now we will show that if is not valid, then Greedy Swap returns False. Let be incomplete. Then there exists an object and an edge on its path where there exists no object such that and can be swapped at . Hence, if reaches this edge there is no object that it can be swapped with. Since this edge is on its path, cannot have reached its destination and hence cannot be reached. Greedy Swap therefore returns False.
Let be ambiguous. Then there exist objects , and and edge on their paths such that if reaches , then it can be swapped with both and . Say is swapped with at . Note that if and can be swapped at edge then must at least reach both agents incident to to get to its destination and at one of these two agents, let us call it it holds . But then cannot be accepted by anymore since has already been assigned to both of the agents before has been assigned to one of them and thus cannot reach its destination. Hence, cannot be reached. Greedy Swap therefore returns False.
Let be inharmonic. We distinguish between two cases. In the first case there exist objects and such that shields from its destination. That means that and walk in the same direction and stops at its destination before can pass . Since , however, is on , cannot reach its destination and cannot be reached. In the second case there exist objects and with and a path such that there exists no edge on where and can be swapped. Since , it holds that and must meet at some edge on and none of them has already reached its destination. Since and cannot be swapped at they cannot reach their destinations and Greedy Swap returns False.
If is not valid, then it is either incomplete, ambiguous or inharmonic and thus Greedy Swap returns False on input , a contradiction. ∎
3.3 Reduction to 2-SAT
In this subsection we will construct a 2-SAT formula such that a selection is valid if and only if it corresponds to a satisfying truth assignment of . We will use a variable for each object and say that setting this variable to True corresponds to swapping this object in clockwise direction. We will use objects interchangeably with their respective variables. The formula will be the conjunction of two subformulas and . The first subformula corresponds to harmonic selections and is constructed as follows.
Let be an instance of Reachable Assignment. For every pair of objects for which there exists a direction such that shields in direction , we add the clause if , and otherwise. Further, for every pair of objects for which there exists a direction such that and are not compatible for any selection where , we add the term if , and otherwise. We use to denote the constructed formula.
We will now show that any satisfying truth assignment of exactly corresponds to a harmonic selection.
Let be an instance of Reachable Assignment. A selection is harmonic if and only if it corresponds to a satisfying truth assignment of .
We will prove both directions of the statement by contradiction. For the first direction suppose that is a harmonic selection but it does not correspond to a satisfying truth assignment of . Then there must exist a clause in such that is not satisfied by the truth assignment corresponding to . We distinguish between two cases. In the first case is a clause for shielding in direction for every selection where but it holds that . But then, by definition, is not harmonic, a contradiction. In the second case is a clause for two non-compatible objects and for every selection where but it holds that , a contradiction to being harmonic.
We will now show the other direction of the statement. Suppose that corresponds to a satisfying truth assignment of but it is not harmonic. We again distinguish between two cases. In the first case there exist two objects and and a direction such that shields in direction for every selection where . But since corresponds to a satisfying truth assignment of , due to the clauses for shielding objects, if , then and thus, does not shield , a contradiction.
In the second case there exist two objects and and a direction such that and are not compatible in direction for every selection where . But since corresponds to a satisfying truth assignment of , due to the clause for compatibility, if , then and thus, and are compatible, a contradiction. ∎
A formula for exact selections requires much more work. To this end, we first introduce a variant of Reachable Assignment.First Swap Reachable Assignment Input: An instance of Reachable Assignment and an edge Question: Is reachable if the first swap is performed over edge ?
Observe that is a yes-instance of Reachable Assignment if and only if there is an edge in such that is a yes-instance of First Swap Reachable Assignment. We will later iterate over all edges and check for each whether it yields a solution. Suppose that some instance of First Swap Reachable Assignment is a yes-instance. Let and . Then, the object is swapped into clockwise direction and the object is swapped into counter-clockwise direction. Thus, in every selection that yields the target assignment as a solution to , it must hold that and . We refer to the pair of objects and as the guess of that instance and denote it , where refers to the object that is swapped into clockwise direction and refers to the object that is swapped into counter-clockwise direction. For every selection where , we say that respects the guess . Further, denotes the object in guess which is swapped in counter-clockwise direction and denotes the object in guess which is swapped in clockwise direction. We also denote the unique path of in clockwise direction from its initial agent to its destination with and the unique path of in counter-clockwise direction from its initial agent to its destination with . If we can prove that for a guess and the corresponding instance of First Swap Reachable Assignment there exists no valid selection that respects , then we say that the guess is wrong. We will now define a property of objects which cannot be swapped in one direction given a certain guess .
Let be an instance of First Swap Reachable Assignment with guess and let be an object such that there exists a direction such that there is no selection with that respects and that is valid. Then is decided in direction .
We find that an object is decided by means of five rules listed below. Therein, is an object in .
The objects and are opposite.
The object occurs in none of ’s candidate lists.
The object occurs in a candidate list of together with another object that is decided in direction .
The agent is neither on nor on .
The object starts between two decided and opposite objects.
We mention that there are a couple of additional technical conditions for the last rule and that there may be decided objects that are not found by either of the five rules. For the sake of simplicity, we say that an object is decided only if fulfills at least one of the rules above. All other objects are said to be undecided. We next show that each of these rules in fact shows that is decided.
Let be a guess, let be the decided direction of in , and let . If and are opposite, then is decided in the direction .
Observe that by definition there is a direction such that in every selection with it holds that . If , then in any selection with , it holds that shields . If , then in any selection with , it holds that shields . Hence in no selection with is harmonic and thus there is no valid selection with and thus is decided in direction . ∎
The second rule focuses on objects that cannot be swapped with one of the two guessed objects.
Let be a guess and let be an object such that . If there exists a such that is not in the candidate list of , then is decided.
Let be a selection where
We distinguish between two cases. In the first case the set of shared paths is empty. Then, the path of and of are disjoint. Now consider a selection where
Because , we now know that
and thus shield from its destination in . Thus, a selection where is not valid.
In the second case there is at least one path in . But then since is not in the candidate list of , there exists no edge on any path where and can be swapped and thus and are not compatible in selection . Thus, a selection where is not valid. This concludes the proof. ∎
The third rule focuses on the effect that decided objects have on other objects.
Let such that , i.e, is a guessed object. If there exists an object such that is decided in direction , then for every where it holds that is decided in direction .
Suppose towards a contradiction that there exists an undecided object and a valid selection that respects such that . Since is decided in direction , it holds for every valid selection that and thus, also for . But then, by definition, and thus, is not valid, a contradiction. ∎
The fourth rule focuses on objects that are in the end held by the agents that are neither on nor on .
Let be an instance of First Swap Reachable Assignment on cycle with guess and let and be non-opposite. Let be an object such that the destination of is not on the union of