The Complexity of Finding Fair Many-to-One Matchings

We analyze the (parameterized) computational complexity of"fair"variants of bipartite many-to-one matching, where each vertex from the"left"side is matched to exactly one vertex and each vertex from the"right"side may be matched to multiple vertices. We want to find a"fair"matching, in which each vertex from the right side is matched to a"fair"set of vertices. Assuming that each vertex from the left side has one color modeling its attribute, we study two fairness criteria. In one of them, we deem a vertex set fair if for any two colors, the difference between the numbers of their occurrences does not exceed a given threshold. Fairness is relevant when finding many-to-one matchings between students and colleges, voters and constituencies, and applicants and firms. Here colors may model sociodemographic attributes, party memberships, and qualifications, respectively. We show that finding a fair many-to-one matching is NP-hard even for three colors and maximum degree five. Our main contribution is the design of fixed-parameter tractable algorithms with respect to the number of vertices on the right side. Our algorithms make use of a variety of techniques including color coding. At the core lie integer linear programs encoding Hall like conditions. To establish the correctness of our integer programs, we prove a new separation result, inspired by Frank's separation theorem [Frank, Discrete Math. 1982], which may also be of independent interest. We further obtain complete complexity dichotomies regarding the number of colors and the maximum degree of each side.


Introduction
A many-to-one matching in a bipartite graph G = (U ∪ • V, E) is an edge subset M ⊆ E such that each vertex in U is incident to at most one edge in M .We study the computational complexity of finding a "fair" many-to-one matching and call this problem Fair Matching: Given a bipartite graph G = (U ∪ • V, E) in which every vertex in U is colored, it asks for a many-to-one matching M such that for each v ∈ V the vertices matched to v meet a fairness criterion.In this work, we require that M is "left-perfect", i.e., every vertex in U is incident to exactly one edge in M .Using a slightly different formulation, Stoica et al. [31] recently studied this problem in terms of a fairness requirement derived from margin of victory (MoV).Generally speaking, the margin of victory of a multiset is defined as the number of occurrences of the most frequently occurring element minus the number of occurrences of the second most frequently occurring element.(Given a set of colored vertices, we obtain a multiset from the occurrences of colors in it.)By requiring that the margin of victory of a set of colored vertices shall not exceed a given threshold, we prevent one color from becoming a dominating majority (see Stoica et al. [31] for a more extensive motivation of this concept).
As an alternative simple fairness measure, we consider Max-Min, which is defined as the difference between the number of occurrences of the most frequently occurring element and the number of occurrences of the least frequently occurring element in a multiset.In a set of colored vertices with a small value of Max-Min all colors appear more or less equally often.
Which of MoV or Max-Min is more appropriate depends not only on the specific application (as discussed in the next two paragraphs) but also on the underlying data.Suppose that we have 2n red, 2n blue, and one green vertex on the left side and two vertices on the right side.Then, it would be natural to deem a subset consisting of n red, n blue, and one green vertex fair (as it is in some sense the best we can hope for).Accordingly, MoV seems to be a better fit because the MoV of the described subset is zero whereas the Max-Min value is n − 1.In contrast, if there are 2n red, 2n blue, and 2n green vertices, then the same subset with n red, n blue, and one green vertex should be considered as unfair, rendering Max-Min more suitable for this color distribution than MoV.In general, Max-Min seems to be a natural choice for homogeneous data.The first example illustrates, however, that in some scenarios, MoV may serve as a viable relaxation of Max-Min. 1 notable application of Fair Matching emerges in the context of district-based elections.In such elections, voters (modeled by vertices in U ) are divided into constituencies (modeled by vertices in V ), and then each constituency elects its own representative.Here, colors can represent various attributes.For instance, colors may represent political standings.A small margin of victory is particularly desirable in this case because it will lead to close elections, holding politicians accountable for their job.One could also strive for "fair" representation of different ethnic groups or age groups by modeling ethnicity or age with colors. 2 Other applications include the assignment of school children to schools (where colors may model sociodemographic attributes) or the assignment of reviewers to academic papers (where colors may model the level of expertise or academic background of reviewers).
Similar fairness considerations also arise in modern online systems (see, e.g., [30] for a survey).For instance, fairness is a pressing issue to counter targeted advertising or to improve recommender systems.Here one task is to ensure that the content (each perhaps represented by multiple vertices in U ) falling into different categories (colors) is assigned to users (vertices in V ) in a way that each user is presented with a "diverse" selection of content.Lastly, we mention that (Max-Min) Fair Matching has also applications outside of the "fairness" context: Imagine a centralized job market for companies (vertices in V ) and applicants (vertices in U ), each having a specific skillset (color).Firms may wish to balance between applicants with different skillsets so that they are able to place employees with various skillsets in each team (to be formed).For instance, it may be desirable for a software company to hire roughly the same number of frontend and backend developers.Related Work.Stoica et al. [31] introduced three problems where the task is to partition a set of colored vertices into subsets with a small margin of victory satisfying some global size constraints.Among these three, the most general is Fair Connected Regrouping, where one is given a vertex-colored graph G, an integer k, and a function that determines for each vertex which subsets it can be part of.The task is then to find a partitioning of G into k fair districts (i.e., connected components).In a follow-up work, Boehmer et al. [13] analyzed how the structure of G influences the (parameterized) computational complexity of Fair Connected Regrouping.The other two problems Stoica et al. [31] considered are special cases of Fair Connected Regrouping: One is Fair Regrouping where the connectivity constraints are dropped (corresponding to MoV Fair Matching).The other is Fair Regrouping_X, which is a special case of Fair Regrouping, where any vertex can belong to any district (corresponding to MoV Fair Matching on complete bipartite graphs; we study this special case in Section 6).They proved that Fair Regrouping is NP-hard for three colors (without any constraints on the degree of the graph) and is XP with respect to the number k of districts (i.e., polynomial-time solvable for constant k).They also showed that Fair Regrouping_X is XP with respect to the number of colors.
Coming back to Fair Matching as a matching problem, Ahmed et al. [4] proposed a global supermodular objective to model the fairness (which they call diversity) of a bipartite weighted many-to-many matching and developed a polynomial-time greedy heuristic for it.Ahmadi et al. [1] extended the work of Ahmed et al. [4] by generalizing the problem to the case where vertices can have multiple different colors and presented a pseudo-polynomial-time algorithm for it.Moreover, Dickerson et al. [17] applied this formulation of fairness to an online setting where vertices from the left side arrive over time and Ahmed et al. [3] applied it to the task of forming teams.
Fairness is also a popular topic when finding a stable many-to-one matching of vertices that have preferences over each other.Here, fairness constraints are typically modeled by imposing for each vertex from the right side certain lower and upper bounds on the number of vertices of each color that can be matched to it [7,12,14,22,24].
More broadly speaking, fairness has recently also been frequently applied to a variety of different problems from the area of combinatorial optimization.For instance, in the context of the Knapsack [29], Maximum Coverage [6] or s-t Path [10] problem, fairness means that all types are represented equally in the selected solution.Another example is Clustering, where each cluster is considered fair when each type accounts for a certain fraction of vertices in it [2,19,20].
The proof (or their completion) of all results marked by ( ) can be found in the appendix.
Let G = (U ∪ • V, E) be a bipartite graph, where U is the left side and V is the right side of G. Let n := |U | and k := |V | be the number of vertices in the left side and right side, respectively.For a vertex w ∈ U ∪ • V and an edge set M ⊆ E, let M (w) be the set of vertices matched to w in M , i.e., M (w) = {w ∈ U ∪ • V | {w, w } ∈ M }.We say that M ⊆ E is a many-to-one matching in G if |M (u)| ≤ 1 for every u ∈ U .A many-to-one matching M is left-perfect if |M (u)| = 1 for every u ∈ U .Note that we require M to be left-perfect as otherwise an empty set would constitute a trivial solution for our problem.
When clear from context, we refer to a left-perfect many-to-one matching as a matching.
be the set of vertices which are only adjacent to vertices in W .We drop the subscript • G when it is clear from context.Let C be the set of colors and let col : U → C be a function that assigns a color to every vertex of U .For U ⊆ U , let U c ⊆ U be the set of vertices u ∈ U of color c.For instance, given a matching M and a vertex v ∈ V , M (v) c denotes the set of vertices matched to v in M that have color c.We denote by Throughout the paper, we assume that the set C of colors is equipped with some linear order ≤ C , which serves as a tie breaker.So arg max over C is well-defined.We write max 1 for max and max 2 for the second largest element.
We now define our two fairness measures.For a subset of vertices | be the difference between the number of occurrences of the most and second most frequent color in U .Similarly, for a subset of vertices U ⊆ U , let MmM(U ) := max c∈C |U c | − min c∈C |U c | be the difference between the number of occurrences of the most and least frequent color in U .A subset of vertices U ⊆ U is -fair according to MoV (resp., Max-Min) if MoV(U ) ≤ (resp., MmM(U ) ≤ ). 5 A many-to-one matching M in G is -fair according to MoV (resp., Max-Min) if M (v) is -fair according to MoV (resp., Max-Min) for all v ∈ V .The considered fairness notion will always be clear from context.We now define our central problem Π Fair Matching for some fairness measure Π:

Input:
A bipartite graph G = (U ∪ • V, E), a set C of colors, a function col : U → C, and an integer ∈ N. Question: Is there a left-perfect many-to-one matching M ⊆ E which is -fair according to the fairness measure Π?
We also sometimes consider Π Fair Matching with size constraints where additionally given two integers p and q, we require that the matching M to be found satisfies p ≤ |M (v)| ≤ q for all v ∈ V .We refer to the case with p = 1 and q = n as the non-emptiness constraint.The non-emptiness constraint is arguably crucial for some applications when we want to partition the vertices in the left side into exactly k non-empty subsets.
Let I be an instance of some problem and let P(I) be an integer linear program (ILP) constructed from I. We say that P is complete if P(I) is feasible whenever I is a yes-instance.Conversely, we say that P is sound if I is a yes-instance whenever P(I) is feasible.In this work, we will make use of Lenstra's algorithm [25,26] that decides whether an ILP of size L with p variables is feasible using O(p 2.5p+o(p) • |L|) arithmetic operations.
We assume that the reader is familiar with basic concepts in parameterized complexity (see for instance [16]).As a reminder, an FPT algorithm for a parameter k is an algorithm whose running time on input I is f (k) • |I| O (1) for some computable function f . 5Notably, the definition of margin of victory of Stoica et al. [31] differs slightly from ours in that in their definition sets of vertices where the two most frequent colors have the same number of occurrences have a margin of victory of one (and not of zero).We chose our definition in accordance with Boehmer et al. [13] to be able to distinguish a tie between two colors from one color being one vertex ahead of another.Warmup: FPT Algorithms for k + |C| We prove that both Fair Matching problems are fixed-parameter tractable with respect to k + |C|: We present an integer linear programming (ILP) formulation of these problems whose number of variables is bounded in a function of the parameter k+|C| and subsequently employ Lenstra's algorithm [25,26].Notably, one can upper-bound the number of "types" (according to their neighborhoods and colors) of vertices in U by 2 To prove that the ILP we present in the following is complete, we use the following: ) be a bipartite graph and let M be a left-perfect many-to-one matching.Then, |ν(W ), the first inequality holds.For the second inequality, observe that every vertex u ∈ M (v) for v ∈ W satisfies u ∈ N (W ).
For proving that our ILP is sound, we use the following slightly more complicated Hall-like lemma: Then, there is a left-perfect many-to-one matching M such that |M (v)| = z v for every v ∈ V .
Proof.Assume that the conditions stated in the lemma hold.We prove the existence of such a matching M by making use of Hall's theorem [23].To do so, we introduce an auxiliary bipartite graph G as follows: In G , the vertices on one of the two sides are the vertices from U .The vertices on the other side are V := v∈V Z v , where Z v is a set of z v vertices.There is an edge between u ∈ U and v ∈ Z v ⊆ V if and only if {u, v} ∈ E. In order to apply Hall's theorem, we show that By the assumption of the lemma, we have Hall's theorem then implies that G admits a one-to-one matching M which matches all vertices from U .In fact, M is a perfect matching since Using Lemmas 1 and 2, we give an ILP formulation of Fair Matching with O(|C| • k) variables.

ILP formulation. Introduce a variable z c
v ∈ N for every v ∈ V and every c ∈ C. The variable z c v represents the number of vertices in U of color c that are matched to v. Suppose that the given instance admits a left-perfect -fair many-to-one matching M respecting the values of z c v .Then, for each c ∈ C, there is a matching As shown in Lemma 1, from this one can conclude that the following constraints must be fulfilled: Next, we encode the fairness requirement.For Max-Min, we need to have that for every pair of colors the number of vertices of these two colors assigned to some vertex v ∈ V differ by at most .Thus, we add the constraint To model -fairness for MoV Fair Matching, we introduce two new binary variables Informally speaking, the intended meaning of these variables is that when c is the most (resp., second most) frequent color among vertices matched to v. We ensure that the values of these variables are set accordingly as follows: For the first constraint, note that it becomes and that it is always fulfilled otherwise.Similarly for the second constraint, observe that it becomes and that it is always fulfilled otherwise.Finally, using a c v and b c v (and their meaning as proven above), we add the following constraint that encodes the -fairness in terms of margin of victory of M (v) for all v ∈ V : Lastly, we can also add linear constraints ensuring that the number of vertices from U matched to each vertex v ∈ V is between p and q: p ≤ c∈C z c v ≤ q for all v ∈ V.

Theorem 3. Max-Min/MoV Fair Matching with arbitrary size constraints can be solved in
Proof.We show that an instance (G = (U ∪ • V, E), C, col, , p, q) of Max-Min/MoV Fair Matching with size constraints admits an -fair left-perfect many-to-one matching if and only if the constructed ILP constructed is feasible.As described above, by Lemma 1, if the given instance is a yes-instance, there is an assignment to z c v satisfying all the constraints.Conversely, suppose that the ILP admits a solution later part follows from our first set of constraints for W = V ).By Lemma 2, it follows that, for each color c ∈ C, G c has a matching M c in which every vertex in U c is matched and the values of z c v for v ∈ V , are respected.Aggregating M c for all colors c yields a left-perfect -fair many-to-one matching for G respecting the given size constraints.Using Lenstra's algorithm [25,26], the feasibility of the ILP can be determined in the claimed time.

FPT Algorithms for k
In this section, we develop FPT algorithms for Max-Min/MoV Fair Matching for the parameterization |V | = k.We start with a discussion of the challenges for our algorithms.
Afterwards, we obtain a new result on submodular and supermodular functions.Using this, in Section 4.1 we present the algorithm for Max-Min Fair Matching, and in Section 4.2 the slightly more involved algorithm for MoV Fair Matching.
The crux of our algorithms is an ILP as in Section 3.However, since we look into the parameterization without |C|, it would be too costly to introduce variables for each color.To illustrate our idea to work around this issue, take Max-Min Fair Matching as an example.One of the straightforward ideas how to formulate this problem as an ILP with O(k) variables would be to introduce two variables x v ≤ y v for every vertex v ∈ V , where x v (resp., y v ) encodes the minimum (resp., maximum) number of vertices of some color c ∈ C matched to v. Informally speaking, to encode the ILP constraints from Section 3, we could now replace every occurrence of z c v with x v (resp., y v ) if the constraint in which z c v occurs imposes an upper (resp., lower) bound on z c v : Constraints 1 from Section 3 then translate to v∈W y v ≥ max c∈C |ν c (W )| and v∈W x v ≤ min c∈C |N c (W )| for every W ⊆ V .Moreover, we add the constraint y v − x v ≤ for all v ∈ V .Let P denote the ILP obtained this way.(See Section 4.1 for the formal construction of P.) Although it is easy to see that P is complete, it turns out to be nontrivial to prove its soundness.To highlight this challenge, suppose that P is feasible for {x v , y v | v ∈ V }.To show that this implies that there is an -fair matching M , we have to show that for every color c ∈ C, the graph G c has a matching M c such that Unfortunately, we cannot directly apply Lemma 2 (as we were able to do in Section 3, since we do not know the exact number of vertices of each color matched to a vertex from V but only upper and lower bounds): To construct an -fair matching from {x v , y v | v ∈ V } using Lemma 2, we have to show that for every color c ∈ C, there always exists a set of integers {z c v | v ∈ V } with the following properties: Finding an assignment of variables z c v that fulfill (i) and (iii) is trivial; setting z c v = y v suffices because P dictates that v∈W y v ≥ max c ∈C |ν c (W )| ≥ |ν c (W )| for every W ⊆ V .However, integers satisfying (i), (ii), and (iii) simultaneously are not trivially guaranteed to exist.To nevertheless prove their existence, we prove what we call the touching separation theorem, inspired by Frank's separation theorem [18] on submodular and supermodular functions.Our theorem implies that if there is a solution to P, then there is an assignment of variables z c v satisfying (i), (ii), and (iii).Submodular and supermodular functions are defined as follows: Definition 4. Let f : 2 S → N be a set function over a set S. We say that f is submodular if Modular functions admit a simpler characterization, which will be useful in several proofs: Frank's famous separation theorem [18] can be stated as follows: If f : 2 S → N is submodular and g : 2 S → N is supermodular, and g(X) ≤ f (X) for every X ⊆ S, then there exists a modular set function h : 2 S → N such that g(X) ≤ h(X) ≤ f (X) for every X ⊆ S. We prove an analogous separation theorem where the "lower-bound" function is the maximum of two functions-one being modular and the other being supermodular-and the "upper-bound" function is a modular function.(In general, the "lower-bound" function arising this way is neither submodular nor supermodular.)We additionally require that the modular function separating the two bounds "touches" the lower-bound function.Our proof uses a rather involved induction on the size of S.
Theorem 6 (Touching separation theorem).Let f, f : 2 S → N be two modular set functions and let g : 2 S → N be a supermodular set function.Suppose that f (∅) = f (∅) = g(∅) = 0 and max(f (X), g(X)) ≤ f (X) for every X ⊆ S.Then, there is a modular set function h : 2 S → N such that max(f (X), g(X)) ≤ h(X) ≤ f (X) for every X ⊆ S and h(S) = max T ⊆S f (T ) + g(S \ T ).
Proof.Our proof is based on the following claim which is a simple corollary of Lemma 2.4 from McCormick [27] (where we set T = ∅, f = −β, z = −α, and y = −γ in the statement of Lemma 2.4): Claim 7. Let α : 2 S → N be a modular function and β : 2 S → N be a supermodular function where β(X) ≤ α(X) for all X ⊆ S.Then, there is a modular function γ : 2 S → N such that β(X) ≤ γ(X) ≤ α(X) for every X ⊆ S and γ(S) = β(S).
Using Claim 7, we can now establish our theorem.Let g : 2 S → N be the following set function g (X) = max T ⊆X g(T ) + f (X \ T ) for all X ⊆ S.
We first prove that g is supermodular.For some subsets X, Y ⊆ S, let X ∈ arg max T ⊆X g(T ) + f (X \ T ) and Y ∈ arg max T ⊆X g(T ) + f (X \ T ).Using this, as f is modular and g is supermodular, we directly get that g is supermodular: We now turn to proving that g (X) ≤ f (X) for every X ⊆ S. Fix some X ⊆ S and let X ∈ arg max T ⊆X g(T ) + f (X \ T ).Then, as max(f (X), g(X)) ≤ f (X) and f is modular we get: Thus, applying Claim 7 (with α = f and β = g ), we get a modular function h(X) with g (X) ≤ h(X) ≤ f (X) and h(S) = g (S) = max T ⊆S f (T ) + g(S \ T ).Note that we clearly have that max(f (X), g(X)) ≤ g (X) for all X ⊆ S and thus max(f (X), g(X)) ≤ g (X) ≤ h(X) ≤ f (X).Thereby, the theorem follows.
To apply Theorem 6, we use a supermodular function arising from a bipartite graph: Lemma 8. Let G = (U ∪ • V, E) be a bipartite graph and let g : 2 V → N be a set function such that g(W ) = |ν(W )| for each W ⊆ V .Then, g is supermodular.
which shows that g is supermodular.
The rest of this section is organized as follows.In Section 4.1, we consider Max-Min Fair Matching.We first construct an ILP with O(k) variables and establish its soundness with the help of the touching separation theorem.Subsequently, we extend our ILP to incorporate the non-emptiness constraint, which turns out to be surprisingly challenging.Afterwards, in Section 4.2, we present our approach for MoV Fair Matching (the same for both the case with or without the non-emptiness constraint).Notably, we do not derive an ILP formulation for MoV Fair Matching directly, but instead introduce an auxiliary variant of the problem for which we construct an ILP with O(k 2 ) variables.As a last step, we show how MoV Fair Matching can be reduced to the auxiliary problem using the color coding technique together with some structural observations about fair matchings.

Max-Min Fair Matching
We now present an FPT algorithm for Max-Min Fair Matching.As mentioned, our algorithm, which follows a similar approach as used in Section 3, builds an ILP.The difference is that the ILP constructed here involves O(k) and not Θ(k • |C|) variables.We prove the correctness of the ILP in Theorem 9, crucially relying on Theorem 6.

ILP formulation.
We add two variables x v ≤ y v ∈ N for every v ∈ V .The intended meaning for these variables is that for every color c ∈ C, the number of vertices from U c matched to v is between x v and y v .We obtain the following constraints from Lemma 1: ( To encode -fairness, we add: Proof.Our ILP uses 2k variables and O(2 k ) constraints; the construction takes O (2 k ) time.Using Lenstra's algorithm [25,26], it is possible to check whether the constructed ILP is feasible in O (k O(k) ) time.It remains to prove the correctness of our ILP.The completeness of our ILP follows from Lemma 1.For the soundness, suppose that {x v , y v | v ∈ V } is a feasible solution for the ILP.For every color c ∈ C, we show the following: For the set U c ⊆ U of vertices of color c, there is a left-perfect matching M c in the bipartite graph from which the soundness of the ILP directly follows.To show the existence of such a matching M c , we will rely on Lemma 2. Note, however, that Lemma 2 asks for integers {z v | v ∈ V } meeting certain constraints, which we cannot choose arbitrarily as we have to respect the constraint Note that f and f are modular by Lemma 5 and that g is supermodular by Lemma 8.The constraints in the ILP ensure that max(f (W ), g(W )) ≤ f (W ) for every W ⊆ V .Consequently, Theorem 6 yields a set modular function h : Note that as h is modular and fulfills the constraints stated above, Combining these matchings yields an -fair matching in G.
Non-emptiness constraint.For a matching M found by our algorithm, we may have M (v) = ∅ for some v ∈ V .So the non-emptiness constraint may be violated.Unfortunately, there is seemingly no simple linear constraint to ensure that M (v) = ∅ for each v ∈ V . 6 Overcoming this challenge, we now develop an FPT algorithm for Max-Min Fair Matching with the non-emptiness constraint.We will build upon the ILP formulation for Theorem 9.However, the situation becomes substantially more complicated.First, observe that for = 0, it suffices to add the constraint y v > 0 for all v ∈ V because this ensures that every vertex v ∈ V is matched to at least x v = y v > 0 vertices of each color.
For > 0, we develop a more involved algorithm.We will start by describing its main ideas before presenting the formal proof.Suppose that there is an -fair many-to-one matching M such that M (v) = ∅ for each v ∈ V .By choosing an arbitrary element u v of M (v) for each v ∈ V , we obtain a matching Since there are possibly n Ω(k) choices for M , we cannot assume that M is given.Instead, our algorithm only "guesses" some structural properties of M , which we will incorporate into the above ILP for Max-Min Fair Matching by adding further constraints.(Our algorithm avoids guessing objects marked with a star.) For each v ∈ V , let χ(v) be the color of M (v).By iterating over all possible partitions V of V , we first guess a partition of V according to χ(v), i.e., two vertices v, v ∈ V belong to the same subset of V if and only if χ(v) = χ(v ).For each S ∈ V, let χ(S) be the color of χ(v) for all vertices v ∈ S. Let us fix some S ∈ V. We will formulate constraints that must be fulfilled when each vertex v in S is matched to its partner M (v) (which has color χ(S)).For this, let U S ⊆ U χ(S) be the set of vertices from U of color χ(S) incident to an edge in M and let G S be the graph obtained from G χ(S) by deleting all edges incident to U S and then adding the edges of M whose endpoint on the left side has color χ(S).Since every edge in M with an endpoint of color χ(S) is present in G S , these edges form a left-perfect many-to-one matching in G S .Thus, by Lemma 1, we should have v∈W y v ≥ |ν G S (W )| and there is a left-perfect matching in G S .We need to 6 Adding xv > 0 ensures that there is at least one vertex of each color matched to v. Adding yv > 0 is not enough, as the ILP only ensures that for each color at most yv vertices are matched to v.
evaluate |ν G S (W )| and |N G S (W )| to include these constraints into our ILP.Note, however, that we cannot compute these values without M given.In the following, we explain how we can nevertheless incorporate these constraints by guessing further structural aspects of M .First, we rewrite |ν G S (W )| and |N G S (W )| as follows: To see why the first equation holds, observe that we have only deleted edges when constructing ) and u has a neighbor outside of W in G χ(S) .The second equation follows similarly: As we only deleted edges, we have To evaluate the second term in each of these equations, we guess a function µ : To incorporate the constraints given (in particular, we do not even know χ(S)).Moreover, it would be costly to guess these values (which can be Ω(n)) for every S ∈ V and W ⊆ V or the values of χ(S) (which can be Ω(|C|)) for every S ∈ V. Instead, we relate these two values to max c∈C |ν c (W )| and min c∈C |N c (W )| by guessing their respective differences.Although these differences may be Ω(n), we discover that we can cap them at k: When they are larger, then the arising constraints are already covered by Constraint (2) from the original ILP.Formally, we guess X(S, W for each S ∈ V and W ⊆ V by iterating over all possible X, Y : V×2 V → {0, . . ., k} (for each of them we have at most (k+1 To account for the constraints v∈W y v ≥ |ν G S (W )| and v∈W x v ≤ |N G S (W )|, we now add the following constraint to the ILP for each S ∈ V and W ⊆ V : We later argue in the proof why these constraints need to be fulfilled.
Iterating over all described guesses and for each solving the constructed ILP, we get: Theorem 10.Max-Min Fair Matching with the non-emptiness constraint can be solved in O * (2 2 O(k) ) time.
Proof.We use the notation and intuition developed above and provide a formal description of the algorithm and its proof of correctness here.For the sake of completeness, some of the arguments that were part of the high-level discussion presented above get repeated.For = 0, the ILP previously developed for the Max-Min Fair Matching problem without non-emptiness constraint amended with the constraint y v > 0 for all v ∈ V solves the problem, as y v > 0 ensures that every vertex v ∈ V is matched to at least x v = y v > 0 vertices of each color and at least one vertex from each color needs to be matched to each v ∈ V in every matching satisfying the non-emptiness constraint in case = 0.
For > 0, we execute the algorithm described in the following once for all combinations of the following (and return yes as soon as one execution returns yes, and return no otherwise): A function µ : V → 2 V (there are 2 O(k 2 ) possibilities).
A partition V of V (there are k O(k) possibilities).
Two functions X, Y : V ×2 V → {0, . . ., k} (for each of them there are (k+1 possibilities).The intended meaning of these objects is as described above.sWe first check whether our guesses are compatible with each other: For c ∈ C and S ∈ V, we say that c is compatible with S if there is a matching k).Note that for each subset S ∈ V, the color χ(S) of vertices matched to S in M should be compatible with S. Essentially, we substitute χ(S) with compatible colors because it would be computationally too expensive to guess χ(S) for all S ∈ V. We check whether there exist different compatible colors for each S ∈ V via an auxiliary bipartite graph H constructed as follows.In the auxiliary, each vertex from the left side corresponds to a color c ∈ C and each vertex from the right side corresponds to a subset S ∈ V. We have an edge between two vertices if and only if the corresponding color and subset are compatible.We return no if H does not admit a (one-to-one) matching that covers the right side; otherwise we proceed.
We formulate an ILP as follows.For every v ∈ V , we again use two variables x v ≤ y v ∈ N, which encodes the bounds on the number of vertices of each color matched to v.For the -fairness, we add: y v − x v ≤ for all v ∈ V .Moreover, by Lemma 1, we have the following constraints: Moreover, for each S ∈ V we add the following constraints to enforce the non-emptiness constraint: The resulting ILP has O(k) variables and O(2 k ) constraints.We solve the ILP in O (k O(k) ) time using Lenstra's algorithm [25,26] and return yes if it admits a feasible solution and no otherwise.Doing this for all possible combinations specified in the beginning results in an overall running time of O (2 2 O(k) ).It remains to prove the completeness and soundness of the ILP.
Completeness.Assume that there is a left-perfect matching M such that M (v) = ∅ for each v ∈ V .For each v ∈ V , let u v be an arbitrary element of M (v).Moreover, we define We consider the execution of the algorithm for the following choices of our guesses: Let V be a partition of V according to χ(v), i.e., two vertices v, v ∈ V are part of the same set in V if and only if For each S ∈ V, let χ(S) be the color of χ(v) for all v ∈ S. For each S ∈ V and W ⊆ V , let X(S, W For the first part of the algorithm, let M := {{χ(S), S} | S ∈ V}.We claim that M is a one-to-one matching in H covering the right side (and thus that the algorithm did not return no in the first step).Note that by the construction of µ, X and Y , all edges in M are also part of H.Moreover, by the construction of V, it follows that χ(S) = χ(S ) for S = S ∈ V. Thus, M is a one-to-one matching in H covering the right side.
For each v ∈ V , let We claim that these variable assignments satisfy all constraints of the above constructed ILP.As M is -fair, they clearly satisfy the fairness constraint.Moreover as M is a left-perfect matching by Lemma 1 they also satisfy Constraints 5. To prove that they also satisfy Constraints 6, we use the notion introduced in the initial high-level discussion.Note that for each S ∈ V, M is also a left-perfect matching in G S .Thus, by Lemma 1 for every S ⊆ W it holds that To justify that our described variable assignments satisfy Constraints (6), let us fix some S ∈ V and W ⊆ V .We make a case distinctions.
Soundness.Assume that there exists a combination of µ : . ., k} such that the compatibility graph H has a one-to-one matching M covering the right side.Moreover, assume that {x v , y v | v ∈ V } is a solution for the constructed ILP.Then, using that the variables satisfy Constraints (5), we can prove as in the proof of Theorem 9 that for every color c Considering the remaining colors, let c be a color such that c = M (S) for some S ∈ V. Our goal is to show that there is a matching By the definition of compatibility, we have a matching for each v ∈ S. Now consider the graph G c obtained from G c by deleting all edges incident to a vertex u ∈ U that is incident to some edge in M c and then adding M c .Note that this is completely analogous to the construction of G S .We then have for each Here, we have the first inequalities since {x v , y v | v ∈ V } satisfy Constraints (6).
The second inequalities follows because c and S are compatible and thus The last inequalities follow from the construction of G c analogous to Equation ( 4).
As we showed in the proof of Theorem 9, this implies that there is a matching

MoV Fair Matching
We now develop an FPT algorithm for MoV Fair Matching for the parameter k, which also works with the non-emptiness constraint.Our algorithm has two parts.In the first part, we give an FPT algorithm (using an ILP) for an auxiliary problem called Targeted MoV Fair Matching.This is a variant of MoV Fair Matching, where for each v ∈ V , the two most frequent colors appearing in M (v) are given as part of the input.We establish the soundness of the ILP for Targeted MoV Fair Matching using again Theorem 6 and Lemma 2. In the second part, we present a (randomized) parameterized reduction from MoV Fair Matching to Targeted Mov Fair Matching using the color coding technique [5] (notably, the "colors" from the color coding technique are different from our colors).To apply this technique, we show that the colors that appear (second) most frequently in M (v) for some v ∈ V "stand out" in a fair matching that fulfills certain conditions.Then, the color coding technique essentially allows us to determine these colors.
Part I. First, we define an auxiliary problem, which we call Targeted MoV Fair Matching.The input for MoV Fair Matching is also part of the input for Targeted MoV Fair Matching.Moreover, Targeted MoV Fair Matching takes as input two functions µ 1 , µ 2 : V → C. In Targeted MoV Fair Matching, we ask for an -fair matching M such that for every vertex v ∈ V , µ 1 (v) (resp., µ 2 (v)) is the most (resp., second most) frequent color among the vertices M (v) matched to v in M .
We now develop an FPT algorithm for Targeted MoV Fair Matching by means of an ILP.Let C 1,2 = {µ 1 (v), µ 2 (v) | v ∈ V } be the set of colors that appear (second) most frequent among the vertices matched to some vertex in V and let C = C \ C 1,2 be the set of other colors.Notably, the size of C 1,2 is linearly bounded in our parameter k.For every v ∈ V , we introduce a variable y v which represents the number of vertices of color µ 2 (v) matched to v. The values of y v need to be chosen in a way such that, for every color c ∈ C , there is a matching M c in G c such that |M c (v)| ≤ y v for all v ∈ V .By Lemma 1, we obtain the following constraint which must be fulfilled and add it to the ILP: For the vertices of colors in C 1,2 , we impose constraints in the same way as in Section 3.For every c ∈ C 1,2 and v ∈ V , we introduce a variable z c v which represents the number of vertices of color c matched to v.Then, we add the following constraints according to Lemma 1.
Moreover, to ensure that µ • (v) is respected, we set for all v ∈ V : In case we impose the non-emptiness constraint, we additionally require that z ≥ 1 for all v ∈ V .Finally, we encode the -fairness: In order to show the correctness of the ILP, with the help of Theorem 6, we prove the following adaptation of Lemma 2, in which we show that there exists a matching of the vertices of colors from C to vertices from V respecting y v for all v ∈ V .
Proof.We use Theorem 6 and Lemma 2. Let f, f , g : 2 V → N be functions such that f (W ) = 0, f (W ) = v∈W z v , and g(W ) = |ν(W )| for every W ⊆ V .Then, f and f are modular by Lemma 5 and g is supermodular by Lemma 8.It follows from Theorem 6 that there is a modular function h : Using Lemmas 2 and 11, we can now show that the above constructed ILP is feasible if and only if the given Targeted MoV Fair Matching is a yes-instance.
Proposition 12. Targeted MoV Fair Matching can be solved in O (k O(k 2 ) ) time even with the non-emptiness constraint.
Proof.It is easy to see that our ILP uses O(k 2 ) variables and O(2 k ) constraints and that the construction takes O (2 k ) time.Using Lenstra's algorithm [26,25], this ILP can be solved in O (k O(k 2 ) ) time.It remains to prove the correctness of our ILP.
The completeness of our ILP follows from Lemma 1.For the soundness, suppose that Combining M c for all colors c ∈ C yields an -fair matching for G.
Part II.We will employ the color coding technique to reduce MoV Fair Matching to Targeted Mov Fair Matching.To do so, we introduce another auxiliary problem called Q-MoV Fair Matching.To define the problem, we first introduce additional notation.Suppose that M is a matching in the input graph ) is the most (resp., second most) frequent color among the vertices M (v) matched to v in M .When the maximum or second maximum is achieved by more than one color, we break ties according to a fixed linear order ≤ C on C. Let V = {v 1 , v 2 | v ∈ V } be a set containing 2|V | elements and let P(M ) be a partition of V into subsets S ⊆ V where for every S ∈ P(M ), v i , v j ∈ S if and only if . Using this, we define Q-MoV Fair Matching.Here, Q is a partition of V and we assume that Q is fixed.The input of Q-MoV Fair Matching is identical to the input of MoV Fair Matching.The difference is that Q-MoV Fair Matching asks for a left-perfect -fair many-to-one matching M in G consistent with Q, that is, P(M ) = Q.Clearly, an instance of MoV Fair Matching is a yes-instance if and only if there exists a partition Q of V such that the corresponding Q-MoV Fair Matching instance is a yes-instance.Since there are at most k O(k) ways to partition V (which is a set of 2k elements), we can afford to "guess" Q in our FPT algorithm.We thus focus on solving Q-MoV Fair Matching.
In particular, we assume without loss of generality that Q is top-color maximal, which is defined as follows.For a matching M , let σ(M | be the sum of the occurrences of the two most frequent colors in M (v) over all vertices v ∈ V .Let M Q be the set of all -fair left-perfect matchings consistent with Q.Then, let We solve Q-MoV Fair Matching using color coding.We make a case distinction based on whether > 0 or = 0. To apply the color coding method, we show a rather technical lemma stating that if a color c is among the two most frequent colors in M (v) for some v ∈ V in a certain fair matching M , then c needs to "stand out"-the number of its occurrence in the neighborhood of v in G is greater than for any other color c , unless c also "stands out".
We first prove this result for > 0 and afterwards an analogous, slightly weaker result for = 0. Lemma 13.Let I be a yes-instance of Q-MoV Fair Matching with > 0 and Q be top-color maximal.Then, an -fair left-perfect many-to-one matching M consistent with , 2}} be the set of colors which are one of the two most frequent colors in M (v) for some v ∈ V and let C M := C \ C M be the set of other colors.
Assume for the sake of contradiction that there is some v ∈ V and i ∈ [2] with Consider a left-perfect matching M obtained from M as follows.Initially, let M := M .We then repeat the following procedure and v is some vertex in V −v, and then add an edge {u, v}.Note that this is always possible, as We claim that M is a left-perfect -fair matching.It is easy to verify the left-perfectness of M .For the -fairness, since c ∈ C M , for every v ∈ V − v, the number of occurrences of the two most frequent colors in M (v ) has not changed compared to M (v ), i.e., max We consider three cases: Lemma 14.Let I be a yes-instance of Q-MoV Fair Matching with = 0 and Q be top-color maximal.Then, a 0-fair left-perfect many-to-one matching

(In other words, the constraint is satisfied for all but one color c
, 2}} be the set of colors which are one of the two most frequent colors in M (v) for some v ∈ V and let C M := C \ C M be the set of other colors.
Assume for the sake of contradiction that there is some v ∈ V and i ∈ [2] with Consider a left-perfect matching M obtained from M as follows.Initially, let M := M .For both colors c v , respectively, c v , we then repeat the following procedure and then add edge {u, v}.Note that this is always possible, as One can show that M is a left-perfect 0-fair many-to-one matching: For 0-fairness note that the two most frequent colors in M (v ) for all v ∈ V − v remain unchanged, while in M (v) we have that max . However, the existence of M contradicts assumption that Q is top-color maximal (using an analogous argument as in the proof of Lemma 13).
With Lemmas 13 and 14 at hand, we are ready to give a randomized reduction from Q-MoV Fair Matching to Targeted MoV Fair Matching.Lemma 15.Let I be an instance of Q-MoV Fair Matching.We can compute in polynomial time an instance J of Targeted MoV Fair Matching such that (i) J is a yes-instance with probability at least δ (where 1/δ ∈ k O(k) ) if I is a yes-instance and Q is top-color maximal, and (ii) J is a no-instance if I is a no-instance.
Proof.We first present a proof for the case > 0 and afterwards a proof for the case = 0.
Case: > 0 We describe a polynomial-time procedure to construct an instance J of Targeted MoV Fair Matching from a given instance I = (G = (U ∪ • V, E), C, col, ) of Q-MoV Fair Matching.We randomly assign each color c ∈ C to one of the subsets in Q with the intended meaning that if we assign color c ∈ C to S ∈ Q, then in a matching M in I one of the following holds: (i) for v 1 ∈ S, c appears as the most frequent color in M (v) and for v 2 ∈ S, c appears as the second most frequent color in M (v) and c appears nowhere else as the most or second most frequent color or (ii) c does not appear as the most or second most frequent color in M (v) for any v ∈ V .Formally let λ : C → Q be a function assigning each color to a subset in Q, where each assignment is chosen uniformly and independently at random. 7For every v ∈ V and i ∈ [2] with v i ∈ S for some S ∈ Q, we find , where arg max is taken over all colors c with λ(c) = S.Then, we construct an instance J of Targeted MoV Fair Matching, where is not consistent with Q, we let J be a trivial no-instance.Clearly, the construction of J takes polynomial time.
Suppose that I is a yes-instance and Q is top-color maximal.We show that in this case J is a yes-instance with probability at least δ with δ −1 ∈ k O(k) .Let M be an -fair left-perfect many-to-one matching M consistent with , where S i v ∈ Q denotes the subset in Q to which v i belongs.We claim that under this assumption on λ, the instance J constructed by our procedure is a yes-instance.In fact, we show that M is a solution of J (which also directly implies that there is a solution consistent with Q and thus that no trivial no-instance is returned).Since M is an left-perfect -fair matching in G, we only have to show that } be the set of colors which are among the two most frequent colors in M (v) for some v ∈ V and let C M := C \ C M be the set of other colors.By Lemma 13, for every v ∈ V , c ∈ C M , and i ∈ [2], we have Since we always break ties according to a fixed linear order (including when we find µ i M (v)), we have Recall that when constructing J we have defined , where the maximum is taken over the set Finally, observe that the probability that λ(µ i M (v)) = S i v for every v ∈ V and i ∈ [2] is at least |Q| −|Q| ≥ (2k) −2k , since λ is chosen uniformly and independently at random.Thus, if I is a yes-instance, J is a yes-instance with probability at least (2k) −2k .
If J is a yes-instance, then I is also a yes-instance, as, by construction of J , if J is not a trivial no instance, a solution M for J needs to satisfy P(M ) = Q and is thus also a solution for I.
Case: = 0 For = 0, we choose λ : C → Q ∪ {∅} uniformly and independently at random.Informally speaking, we wish to have every color in {c v | v ∈ V } (where c v is the color from Lemma 14) map to ∅ in λ.This means that these colors cannot be "falsely" picked as the most or second most frequent for some v. Thus, Lemma 13 serves as a viable analogue of Lemma 14 for the remaining part of the proof.The event that λ(c v ) = ∅ for all c ∈ {c v | v ∈ V } occurs with probability at least (|Q| + 1) −k .Moreover, the probability of the event that λ(µ i M (v)) = S for all v ∈ V and i ∈ [2] is at least (|Q| + 1) −|Q| ≥ (2k + 1) −2k .Since these two events are independent, using a similar argumentation as for > 0 one can show that the lemma also holds for = 0.
We repeat the algorithm of Lemma 15 independently δ −1 ∈ k O(k) times on the given instance I of Q-Fair Matching.If I is a yes-instance and Q is top-color maximal, then at least one instance of Targeted Mov Fair Matching returned by the algorithm is a yes-instance with probability at least 1 − (1 − δ) δ −1 ≥ 1 − 1/e.By Proposition 12, a yes-instance of Targeted Mov Fair Matching can be recognized in O (k O(k 2 ) ) time.We thus have a randomized algorithm to solve Recall that Q is a partition of a 2k-element set.So there are at most k O(k) choices for Q (one of which needs to be top-color maximal), which gives us the following theorem (we remark that our algorithm can be derandomized using a standard method [16]): )-time algorithm to solve MoV Fair Matching even with the non-emptiness constraint.

Complexity Dichotomies with respect to |C| and Maximum Degree
In this section, we study the computational complexity of Max-Min/MoV Fair Matching for fixed values of ∆ U , ∆ V , and |C|.Recall that ∆ U (resp., ∆ V ) is the maximum degree of all vertices in U (resp., V ).We identify several computational dichotomies regarding these parameters (see Figure 1).

Dichotomy with respect to |C|
We first show a dichotomy on |C|.In particular, Max-Min/MoV Fair Matching is polynomial-time solvable for |C| = 2 (even if there are arbitrary size lower bounds), while it is NP-hard for |C| = 3: Theorem 17. Max-Min/MoV Fair Matching is polynomial-time solvable for |C| = 2 and NP-hard for |C| ≥ 3. The polynomial-time result even holds in the presence of arbitrary size lower bounds.
We first prove that Max-Min/MoV Fair Matching is NP-hard for |C| ≥ 3 and then that it is polynomial-time solvable for |C| = 2.
Hardness.Stoica et al. [31] showed that MoV Fair Matching is NP-hard for |C| = 3.We show that Max-Min Fair Matching is also NP-hard even if there are three colors.

Proposition 18. Max-Min Fair Matching is NP-hard for
Proof.We reduce from the following NP-hard variant of 3-Dimensional Matching: Given three disjoint sets X, Y , and Z and a subset T ⊆ X × Y × Z of triplets where each element from X ∪ Y ∪ Z occurs in at most three triples from T , the question is whether there is a perfect 3D-matching, i.e., a subset of triples T ⊆ T such that each element from X ∪ Y ∪ Z occurs exactly in one triple from T [21, Problem SP1].Given an instance (X ∪ • Y ∪ • Z, T ) of 3-Dimensional Matching, we construct an instance of Max-Min Fair Matching as follows.We set = 0 and introduce three colors C = {α, β, γ}.For each triple t ∈ T , we add a vertex v t to V .For each element s ∈ X (resp., s ∈ Y and s ∈ Z), we introduce a vertex u s of color α (resp., β and γ) to U and connect it to the vertices from V corresponding to triples in which s occurs.Note that ∆ U , ∆ V ≤ 3.
Suppose that M is a fair matching for the constructed instance.Note that if M (v t ) is non-empty for some t ∈ T , then all vertices from U corresponding to the three elements from t must be assigned to M (v t ), as M (v t ) is 0-fair.Thus, each 0-fair left-perfect many-to-one matching in the constructed Max-Min Fair Matching instance corresponds to a perfect 3D-matching in the given 3-Dimensional Matching instance and vice versa.
Algorithm.We now show that Max-Min/MoV Fair Matching is polynomial-time solvable for |C| = 2. Our algorithm works for arbitrary size lower bounds.

Proposition 19. Max-Min/MoV Fair Matching can be solved in polynomial time for |C| = 2 even with arbitrary size lower bounds.
Proof.Let I = (G = (U ∪ • V, E), C, col, ) be an instance of Max-Min/MoV Fair Matching with C = {α, β} and size lower bound p.We will describe a polynomial-time algorithm that determines whether there is an -fair matching M such that |M (v)| ≥ p for every v ∈ V by reducing to Maximum Weighted Matching.
For this, we will construct a graph G = (V , E ) and a subset S ⊆ V of vertices such that there is a one-to-one matching M in G where all vertices from S are matched if and only if I is a yes-instance.Note that given G and S, we can determine in polynomial time whether such a matching M exists, as this problem can be easily reduced to an instance of Maximum Weighted Matching.
Construction.We give the general description of how we construct G and S. We define a graph G v for every v ∈ V , whose connected components all contain at most four vertices.In every connected component of G v , we mark at most one vertex by 1 and at most on vertex by 2 .Moreover, we mark some vertices by s .To construct G , we add the vertices U and the graph G v for every v ∈ V .Moreover, for every u ∈ U α (resp., u ∈ U β ) and v ∈ N G (u), we add an edge between u and every vertex marked by 1 (resp., 2 ) in G v .We include U and every vertex marked by s into S. Now we describe how to construct the G v 's.In fact, G v will look the same for all v ∈ V and only depends on and p (and n).Every connected component of G v is one of the six graphs H 1 , • • • , H 6 (with markers) depicted in Figure 2, where we include s i copies of H i into G v .The values of s i that are specified in Table 1, where we have four possible cases depending on whether > 0, p < and the parity of p − .
Table 1 The choice of si for i ∈ [6].
Correctness.For every graph H i , let A i be a set of row vectors x ∈ {0, 1} 2 such that the graph obtained by deleting from H i a vertex marked by 1 if x 1 = 1 and a vertex marked by 2 if x 2 = 1 has a matching in which all vertices marked by s are matched.Note that Let P be the collection of pairs (i, x), where i ∈ [6] and x ∈ A i .For m 1 , m 2 , p, ∈ N, we say that a vector a ∈ N P represents [m 1 , m 2 ] with respect to p and if where s ∈ N 6 is a vector such that s i is defined according to Table 1.We will show the following: For .This implies that we can find a matching M v in G where all vertices from G v that are in S are matched and the vertices from U that are matched to some vertex in G v are exactly M (v).More precisely, for each (i, x) ∈ P, the vertex marked by 1 (resp., 2 ) should be matched to some vertex from U α (resp., Notably, the constructed matching M v is disjoint for all v ∈ V .Thus, M = v∈V M v is a solution to the constructed instance.For the reverse direction, assume that there is a matching M in G matching all vertices from S. Then, for v ∈ V , let m 1 (resp., m 2 ) be the number of vertices from U α (resp., U β ) matched to a vertex from G v .As M matches all vertices from S, there exists a . By ( ), we obtain m 1 + m 2 ≥ p and |m 1 − m 2 | ≤ .Thus, the matching M where for every v ∈ V we match to v all vertices from U that are matched to a vertex from G v in M is a solution to the given instance.We now turn to the proof of ( ).We first consider the if part.Assume that for some m 1 , m 2 , p, ∈ N we have a vector a ∈ N P representing [m 1 , m 2 ] with respect to p and .We show that m 1 + m 2 ≥ p and [6] x∈Ai a (i,x) (x 1 − x 2 ), we have by Equation ( 9), It is straightforward to verify that s 3 + 2s 5 + s 6 ≥ p and s 2 + s 3 + s 4 + s 6 ≤ hold for every case given in Table 1.Thus, we have that m 1 + m 2 ≥ p and |m 1 − m 2 | ≤ , which concludes the first direction.
We now turn to the only-if part of ( ).Suppose for some m 1 , m 2 , p, ∈ N that m 1 +m 2 ≥ p and |m 1 − m 2 | ≤ .Without loss of generality, assume that m 1 ≤ m 2 .We show that there exists a vector a ∈ N P representing [m 1 , m 2 ] with respect to p and .For each (i, x) ∈ P, let e x i ∈ N P be a vector such that (e x i ) (i,x) = 1 and all other entries are 0. Further, for each i ∈ [6], let e i be a vector such that e i = 1 and all other entries are 0.
For = 0, we have For > 0, we make a case distinction based on the relation of p and .In the following, when we speak of some p, , m 1 , m 2 , then we always assume that m 1 +m 2 ≥ p and |m 1 −m 2 | ≤ .First we consider the case p < .We prove that there is an a with respect to p and by induction on ( − p, ) assuming that > 0 and p < .
Base case.Our base case is ( − p, ) = (1, 1) (as > 0 and > p), implying that = 1 and p = 0.In this case, we have + i∈ [2,4,6] s i e (0,1) i represents [m 1 , m 2 ] with respect to p and , as i∈ [2,4,6] We now move on to the second case p ≥ .We prove that there is an a ∈ N P representing [m 1 , m 2 ] with respect to p and by induction on (p − , p) assuming that p ≥ > 0. Notably we thus have p − < p.

Dichotomy with respect to Maximum Degree
We now present complexity dichotomies with respect to ∆ U and ∆ V .All NP-hardness results here hold for three colors, while all polynomial-time results hold for an arbitrary number of colors.We start by considering MoV (Section 5.2.1) and afterwards turn to Max-Min (Section 5.2.2).

MoV
Theorem 20.MoV Fair Matching is polynomial-time solvable if ∆ U ≤ 1 or ∆ V ≤ 4 (even with the non-emptiness constraint) and NP-hard otherwise.
Note that polynomial-time solvability for ∆ U = 1 is obvious, as in this case we know exactly where to assign each vertex from the left side.To prove Theorem 20, we first show that MoV Fair Matching is polynomial-time solvable for ∆ V ≤ 4 (even with the non-emptiness constraint) (Proposition 21) and that it is NP-hard for ∆ U = 2 and ∆ V = 5 (Proposition 22).
Algorithm.We start with giving an algorithm that solves MoV in polynomial-time for ∆ V ≤ 4. Our algorithm is a polynomial-time reduction to a polynomial-time solvable special case of General Factor, which we will define in the proof.

Proposition 21 ( ).
MoV Fair Matching is polynomial-time solvable for ∆ V ≤ 4 even with the non-emptiness constraint.Proof Sketch.We give a polynomial-time reduction to General Factor: In an instance of General Factor the input is an undirected graph H = (W, F ) and a degree list function L : W → 2 N such that L(w) ⊆ {0, . . ., deg G (w)} for every vertex w ∈ W .The problem asks for a spanning subgraph H = (W, F ) for F ⊆ F such that deg H (w) ∈ L(w) for every w ∈ W .By a result of Cornuéjols [15], General Factor is polynomialtime solvable if for every w ∈ W , the degree list L(w) has gaps of size at most one, i.e., {min L(w), min L(w)+1, . . ., max L(w)}\L(w) does not contain any two consecutive integers.Given an instance I = (G = (U ∪ • V, E), C, col, ) of MoV Fair Matching with ∆ V ≤ 4, we will construct an equivalent instance J = (H = (W, F ), L) of this polynomial-time solvable special case of General Factor.
In the following, we give an overview of our construction.For every v ∈ V , we add a subgraph but no other vertices from U .For the construction of H v , we make extensive case distinctions depending on N G (v) and .See Figure 3 for two examples.The construction of H v for all other cases are deferred to the appendix.The graph H is then the union of H v for all v ∈ V ; notably, a vertex u from U may appear in multiple subgraphs H v , in which case we identify all occurrences of u and merge them into one vertex.Moreover, for each u ∈ U , we set L(u) = {1}, which ensures that u is "matched" in every solution of J .
To show that I and J are equivalent, it suffices to show the following for every v ∈ V : A vertex set S ⊆ N G (v) is -fair if and only if there is a spanning subgraph To see why ( ) is sufficient, assume that ( ) holds true.For the forward direction, suppose that I is a yes-instance, i.e., there is a -fair left-perfect many-to-one matching M in G.
Then, M (v) ⊆ N G (v) is -fair for every v ∈ V .Hence, as we assume that ( ) holds, we have a subgraph H v for every v ∈ V that satisfies the degree constraints of ( ).Consider a spanning subgraph H whose edge set is the union of the edge set of H v over all v.It is easy to verify that H constitutes a solution for J .For the converse direction, suppose that J is a yes-instance, i.e., there is a spanning subgraph H = (W, F ) of H with deg(w) ∈ L(w) for every w ∈ W .Then, the subgraph of H induced by W v satisfies all the degree constraints of ( ).For v ∈ V , let S v ⊆ N G (v) be the set of vertices from U that have a neighbor in By ( ), S v is -fair.Moreover, since L(u) = {1} for every u ∈ U , every vertex appears in S v for exactly one vertex v ∈ V .It follows that a matching M with M (v) = S v for every v ∈ V is a -fair left-perfect many-to-one matching in I.We remark that we can adapt our algorithm to handle the non-emptiness constraint.Hardness.It was already proven by Stoica et al. [31] that MoV Fair Matching is NPhard.However, the maximum degree is unbounded in their reduction.We strengthen their result by showing that MoV Fair Matching is also NP-hard for three colors if the degree of vertices in U is at most two and the degree of vertices in V is at most five.
Proof.We reduce from an NP-hard variant of Satisfiability where each clause consists of exactly three literals and each variable occurs in exactly two clauses positively and in exactly two clauses negatively [11].An instance of Satisfiability consists of a set X of variables and a set Y of clauses.
Construction.We set = 0 and use three colors α, β, and γ.We will construct a graph G = (U ∪ • V, E) consisting of a variable gadget for each variable and a clause gadget for each clause.We start with describing the variable gadgets (see Figure 4 for an illustration).For each variable x, we do the following: We introduce three vertices u x , u +,α x , u −,α x ∈ U of color α, two vertices u +,β x , u −,β x ∈ U of color β, four vertices u +,1 x , u +,2 x , u −,1 x , u −,2 x ∈ U of color γ, and two vertices v + x , v − x ∈ V .We add edges such that v + x is adjacent to u x , u +,α x , u +,β x , u +,1 x , u +,2 x and v − x is adjacent to u x , u −,α x , u −,β x , u −,1 x , u −,2 x .Essentially, matching u x to v + x (resp., v − x ) equates to assigning false (resp., true) to the variable x.Whenever u x is matched to v + x (resp., v − x ), both u +,1 x and u +,2 x (resp., u −,1 x and u −,2 x ) must also be matched to v + x (resp., v − x ) in order to respect the 0-fairness constraint.We next describe the clause gadgets (see Figure 4 for an illustration).For each clause y ∈ Y , we do the following: We introduce three vertices u y , u 1 y , u 2 y ∈ U of color α, two vertices u 1,β y , u 2,β y ∈ U of color β, two vertices u 1,γ y , u 2,γ y ∈ U of color γ, and four vertices v y , v y , v 1 y , v 2 y ∈ V .We add edges such that v y is adjacent to u y , u 1 y , u 2 y , such that v y is adjacent to u y , and such that v i y is adjacent to u i y , u i,β y , u i,γ y for each i ∈ [2].Note that u y must be matched to either v y or v y .Moreover, all the neighbors of v y and v y in the clause gadget have color α.To achieve 0-fairness, it follows that v y or v y must be matched to at least one vertex of color β or γ (in fact this will be always γ) from a variable gadget.
Lastly, we connect variable gadgets and clause gadgets.For each y ∈ Y , let l 1 y , l 2 y , l 3 y be the literals in y.For every y ∈ Y and i ∈ [3], we add an edge as follows: If l i y = x and the literal l i y is the jth occurrence (j ∈ [2]) of x, then add an edge between u +,j x and v y (for i = 3, in this case we add an edge between u +,j x and v y ).If l i y = x and the literal l i y is the jth occurrence (j ∈ [2]) of x, then add an edge between u −,j x and v y (for i = 3, in this case we add an edge between u −,j x and v y ).This concludes the construction.It is easy to verify that ∆ U ≤ 2 and ∆ V ≤ 5.

Correctness. (⇒)
Let ϕ be a satisfying assignment of the given Satisfiability instance.We construct a matching M in G as follows.First, we add edges to M such that for every x ∈ X.Moreover, for every x ∈ X and i ∈ [2], we add to M an edge between u +,i x (resp., u −,i x ) and its neighbor in a clause gadget if x is true (resp., false) in ϕ.Now every vertex from the left side occurring in a variable gadgets is matched.We now discuss how to match the vertices in clause gadgets.We add to M edges {v i y , u i,β y } and {v i y , u i,γ y } for every y ∈ Y and i ∈ [2].Moreover, we do as follows for every y ∈ Y : If all literals are true in ϕ, then add {v y , u (⇐) Assume that there is a left-perfect -fair matching in the constructed MoV Fair Matching instance.We claim that the assignment ϕ, where x is set to true if u x ∈ M (v − x ) and to false if u x ∈ M (v + x ), is a satisfying assignment for the given formula.Assume for a contradiction that a clause y ∈ Y is not satisfied by ϕ.Note that u y ∈ M (v y ) or u y ∈ M (v y ).Since M (v y ) and M (v y ) are both 0-fair, at least one of M (v y ) and M (v y ) contains a vertex of color γ or β.Without loss of generality, assume that u +,1 x ) since otherwise M (v + x ) is not 0-fair.This, however, implies that x is true in ϕ, a contradiction.Notably this result also clearly shows hardness for arbitrary ∆ U ≥ 2 and ∆ V ≥ 5, as we can simply add an isolated trivial yes-instance with the respective vertex degrees to the constructed instance.

Max-Min
For Max-Min Fair Matching, we prove that fewer cases are polynomial-time solvable than for MoV Fair Matching:

3) (even with the non-emptiness constraint) and NP-hard otherwise.
Again note that the case ∆ u ≤ 1 is trivial.we add three vertices v 1 s , v 2 s , and v 3 s to V .Moreover, for each element s ∈ X, we do the following: We introduce three vertices u 1 s , u 2 s , and u 3 s of color α to U and connect each of them to a different vertex from V corresponding to one of the three triples in which s occurs.We connect u i s to v i s for each i ∈ [3].We add two vertices a 1 s and a 2 s of color β and two vertices b 1 s and b 2 s of color γ to U .We connect a 1 s to v 1 s and v 3 s , b 1 s to v 2 s and v 3 s , and a 2 s and b 2 s to v 1 s and v 2 s .Note that each of these four vertices has exactly two neighbors (see Figure 5 for an illustration).For each element s ∈ Y (resp., s ∈ Z), we do exactly the same except that vertices u i s have color β (resp., γ), vertices a i s have color γ (resp., α), and vertices b i s have color α (resp., β).It is easy to see that deg(u) = 2 for all u ∈ U and deg(v) ≤ 4 for all v ∈ V .The general idea of the reduction is that for each s ∈ X ∪ • Y ∪ • Z, exactly one of u 1 s , u 2 s , and u 3 s cannot be matched to one of v 1 s , v 2 s , and v 3 s .This implies that exactly one of u 1 s , u 2 s , and u 3 s must be matched to a vertex v t for some t ∈ T .As we show, this can be achieved in a 0-fair matching if and only if there is a perfect 3D-matching.
(⇒) Assume that there is a perfect 3D-matching T ⊆ T in the given 3-Dimensional Matching instance.We construct a 0-fair left-perfect many-to-one matching M as follows.For each t ∈ T and s ∈ t, we match the vertex u i s (for some i ∈ [3]) to v t where u i s is a vertex adjacent to v t .Then, M (v t ) is comprised of three vertices of distinct colors, and hence 0-fair.Furthermore, we define M (v 1 s ), M (v 2 s ), and M (v 3 s ) for each s ∈ X ∪ • Y ∪ • Z as follows.Note that exactly one of u 1 s , u 2 s , and u 3 s is already matched to v t for some t , and M (v 3 s ) are 0-fair.Thus, the constructed matching is 0-fair and clearly a left-perfect many-to-one matching.
(⇐) Assume that there is a 0-fair left-perfect many-to-one matching M in the constructed Max-Min Fair Matching instance.We show that {t ∈ T | M (v t ) = ∅} constitutes a perfect 3D-matching.As M is 0-fair, for every triplet t ∈ T with M (v t ) = ∅, every element s ∈ t satisfies u i s ∈ M (v t ) for some i ∈ [3].It thus suffices to show that for every s ∈ X ∪ • Y ∪ • Z, exactly one of u 1 s , u 2 s , and u 3 s is matched to v t for some t ∈ T in M with s ∈ t.Consider an element s ∈ X ∪ • Y ∪ • Z and let c (resp., c ) be the color of u 1 s , u 2 s , and u 3 s (resp., a 1 s and a 2 s ).As M is left-perfect, we have a s ) thus contains exactly two vertices of color c.This implies that exactly one of u Consequently, as M is left-perfect, for every s ∈ X ∪ • Y ∪ • Z, it holds that there is exactly one i ∈ [3] such that M (u i s ) = v t for some t ∈ T with s ∈ t.Thus, we can conclude that {t ∈ T | M (v t ) = ∅} is a perfect 3D-matching.This result also clearly shows hardness for arbitrary ∆ U ≥ 2 and ∆ V ≥ 4, as we can simply add an isolated trivial yes-instance with the respective vertex degrees to the constructed instance.

Fair Matching on Complete Bipartite Graphs
A natural special case of Fair Matching is when the underlying graph is complete, i.e., each vertex in U can be assigned to any vertex in V .This special case is also among the three problems introduced by Stoica et al. [31] (they called it Fair Regrouping_X).In fact, we find a precise characterization of yes-instances, which turns out to be surprisingly simple.However, it requires an intricate analysis to prove this, especially when the nonemptiness constraint is present.Afterwards, we prove an analogous result for Max-Min Fair matching.
To simplify notation, we assume that C = {c

With the non-emptiness constraint, I is a yes-instance if and only if it additionally satisfies:
> 0 and n ≥ k, or = 0 and n ≥ 2k.
Proof.We first prove the theorem without the non-emptiness constraint and later extend the proof.We assume that V = {v 1 , . . ., v k }.
No size constraints.We consider both directions separately and start by proving that if there is a left-perfect -fair many-to-one matching M in I, then We now prove the reverse direction: then there is a left-perfect -fair many-to-one matching M in I. To do so, we assume that I satisfies this constraint and present an algorithm that constructs M .
We refer to the following algorithm as Algorithm 1.Let U := U and let i := 1.We do the following as long as there are at least |U ci+1 | + vertices of color c 1 in U : Delete |U ci+1 | + vertices of color c 1 from U and match them to v i .Delete |U ci+1 | vertices of color c i+1 from U and match them to v i .Increment i by 1.
Proof.As a reminder, we assume that V = {v 1 , . . ., v k } and that . We first prove the theorem for p = 0 and later extend the proof to the case p = 1.
No size constraints.We consider both directions separately.Assume that there is a leftperfect -fair many-to-one matching M in I, then as M is -fair, it holds that We now prove the reverse direction: We construct M as follows.For each color c ∈ C, we execute the following procedure as long as there are still unassigned vertices in U c .Set i := 1 and assign a vertex from U c not assigned yet to v i and increase i by one if i < k and set i := 1 otherwise.The constructed matching M is clearly a left-perfect many-to-one matching so it remains to prove that M (v i ) is -fair for each v i ∈ V .For the sake of contradiction assume that there is a v i ∈ V such that M (v i ) is not -fair, i. Theorems 27 and 28 imply that Max-Min/MoV Fair Matching on a complete bipartite graph are solvable in linear time even with the non-emptiness constraint.

Conclusion
In this work, we have investigated the (parameterized) computational complexity of the Fair Matching problem.Two concrete directions of open questions are: We have provided algorithms that solve Fair Matching even if we require that every vertex in the right side is matched to at least one vertex.Can we extend our algorithms to handle arbitrary size constraints?In particular, does Fair Matching remain fixedparameter tractable with respect to k? We have shown in Section 3 that Fair Matching is indeed FPT with respect to k + |C| even for arbitrary size constraints.However, it does not seem straightforward to incorporate arbitrary size constraints in the ILPs given in Section 4. The complexity of Fair Matching on complete bipartite graphs (Section 6) is also open when arbitrary size constraints are present.Is Fair Matching solvable in O (2 k ) time?Note that the ILP presented in Section 4.1 (which solves Max-Min Fair Matching without the non-emptiness constraint) is an ILP where the constraint matrix involves only zeros and ones when = 0. Can we exploit such a structure in the constraint matrix to obtain a faster algorithm?For future research, it would also be natural to study other variants of the Fair Matching problem.For instance, we may relax the left-perfect constraint studied in this work and consider a variant where the objective is to maximize the matching size under a fairness constraint.One may also look into other fairness notions such as proportionality constraints [28].
Conversely, we prove that a modular function satisfies f (X) = f (∅) + x∈X (f (x) − f (∅)) for every X ⊆ S by induction on |X|.For X = {x}, we have f (∅) + x ∈X (f (x ) − f (∅)) = f (x).For |X| > 1, let x ∈ X be an element of X.By the modularity of f , we have Here, the equality holds as f is modular and the second equality is due to induction hypothesis.

B
Remainder of the Proof of Proposition 21.
Proposition 21 ( ).MoV Fair Matching is polynomial-time solvable for ∆ V ≤ 4 even with the non-emptiness constraint.
Proof.Recall that we need to construct a subgraph H v for every v ∈ V that satisfies the following: A vertex set S ⊆ N G (v) is -fair if and only if there is a spanning subgraph We now describe the construction of H v for v ∈ V for different situations depending on N G (v) and .We omit the proofs of ( ) for each H v , since they are rather straightforward when H v is given and start by considering the case without the non-emptiness constraint.For U ⊆ U , let Count(U ) denote the |C|-dimensional vector whose ith entry is the number of occurrences of the ith most frequently occurring color in U , i.e., max i c∈C |U c |.To simplify notation, we omit trailing zero entries in Count(U ).We consider more than a dozen of cases depending on and Count(N (v)) and start by discussing some easy cases: If N G (v) consists of vertices of one color, then independent of , H v consists of a vertex v 1 with L(v 1 ) = {0, . . ., } and all vertices from N G (v), where v 1 is adjacent to all vertices from N G (v).So we may assume that N G (v) has at least two colors.Moreover, if ≥ Count(N G (v)) 1 , then any subset S ⊆ N G (v) is -fair.In this case, H v consists of a vertex v 1 with L(v 1 ) = {0, . . ., deg G (v)} and all vertices from N G (v), where v 1 is adjacent to all vertices from N G (v).So we may also assume that < Count(N (v)) 1 .From < Count(N (v)) 1 , ∆ V ≤ 4, and that N G (v) has at least two colors for each vertex v ∈ V , it follows that ≤ 2 needs to hold.For all remaining cases the construction of H v is given in Figure 6 (for = 2), Figure 8 (for = 1), and Figure 7 (for = 0).
If we impose the non-emptiness constraint, i.e., in the matching M to be found M (v) = ∅ for each v ∈ V holds, then we need to slightly modify the above presented constructions for H v .For = 0 and = 2 these modifications are straightforward.For = 0, for instance, for Count(N (v)) = (2, 1, 1) (Figure 7f), we need to change the set of allowed degrees for v 4 to {0, 1} (thereby forcing that two of v 1 , v 2 and v 3 are matched to a vertex from U ), and for Count(N (v)) = (2, 2) (Figure 7e), we need to delete the edge between v 1 and v 2 (thereby forcing that both v 1 and v 2 are matched to vertices from U ).For = 2, we need to adapt the construction presented in Figure 6 by changing the set of allowed degrees of v 1 to {0, 2, 3}.For = 1 the modifications are more intricate.Thus, we explicitly present the constructions for this case in Figure 9.

Figure 9
The construction of Hv for the case that = 1 with non-emptiness constraint.
m 1 , m 2 , p, ∈ N, we have m 1 + m 2 ≥ p and |m 1 − m 2 | ≤ if and only if there exists a vector a ∈ N P representing [m 1 , m 2 ] with respect to p and .( ) From ( ) we can easily establish the correctness of our construction: Assume that an -fair matching M in G is given with |M (v)| ≥ p for all v ∈ V .Then for some v ∈ V , let m 1 = |M (v) α | and m 2 = |M (v) β |.We then have m 1 + m 2 ≥ p and |m 1 − m 2 | ≤ .By ( ), there is a vector a ∈ N P representing [m 1 , m 2 ]

)
Hv for = 0 and N (v) has two vertices of color α, one vertex of color β, and one vertex of color γ.

Figure 3
Figure 3 Exemplary constructions of Hv.

Figure 4 A
Figure 4 A variable gadget (left) and clause gadget (right) from the proof of Proposition 22.Vertices of color α are depicted as triangles, vertices of color β as down-pointing triangles, and vertices of color γ as squares.A dotted line denotes an edge between a variable gadget and a clause gadget.

Figure 5
Figure 5 The connection between v 1 s , v 2 s , v 3 s and a 1 s , a 2 s , b 1 s , b 2 s .
1 , . . ., c |C| } and that |U ci | ≥ |U ci+1 | for each i ∈ [1, |C| − 1] and set |U ci | := 0 for i > |C|.Theorem 27.A MoV Fair Matching instance I = (G = (U ∪ • V, E), C, col, ) with G being a complete bipartite graph is a yes-instance if and only e., there are two colors c , c ∈ C with |M (v i ) c | ≥ |M (v i ) c | + + 1.By the construction of M it holds for each color c ∈C that |M (v j ) c | ≥ |M (v i ) c | ≥ |M (v j ) c | − 1 for j < i and |M (v i ) c | − 1 ≤ |M (v j ) c | ≤ |M (v i ) c | for j > i .Thus, from |M (v i ) c | ≥ |M (v i ) c | + + 1 it follows that |M (v i ) c | − |M (v i ) c | ≥ for all i ∈ [k].Consequently, |U c |−|U c | = |M (v i ) c |−|M (v i ) c |+ j∈[k]−i * |M (v j ) c |−|M (v j ) c | ≥ +1+(k−1) > k, a contradictionto our initial assumption on I. Non-emptiness constraint.We again consider both directions separately.Assume that there is a left-perfect -fair many-to-one matching M in I with M (v) = ∅ for all v ∈ V .Then ,as argued above since M is -fair, |U c1 | ≤ k + |U c |C| | needs to hold.As M (v) = ∅ for every v ∈ V , n ≥ k holds.Moreover, if = 0, then there is at least one vertex of each color in M (v) for every v ∈ V .Thus, |U c1 | ≥ k follows.For the reverse direction, assume that I fulfills |U c1 | ≤ k + |U c |C| | and that > 0 and n ≥ k or = 0 and |U c1 | ≥ k.We make a case distinction based on |U c1 |.If |U c1 | ≥ k, then the procedure the case without the non-emptiness constraint produces a left-perfect -fair many-to-one matching M with |M (v)| ≥ 1 for all v ∈ V .If |U c1 | < k, then it holds that > 1 and |U c | < k for each c ∈ C. As n ≥ k, it is clearly possible to construct a left-perfect many-to-one matching M of vertices from U to vertices from V such that |M (v)| ≥ 1 and |M (v) c | ≤ 1 for each v ∈ V and c ∈ C. As M is clearly -fair, the statement follows.
H v (u) = 1 for every u ∈ S, deg H v (u) = 0 for every u ∈ N (v) \ S, and deg H v (v ) ∈ L(v ) for every v ∈ W v \ U . ( )

Figure 6
Figure 6The construction of Hv for the case that = 2.

Figure 8
Figure 8The construction of Hv for the case that = 1.
Using this observation, it is straightforward to give an ILP formulation of Max-Min/MoV Fair Matching using O(2 k • |C|) variables.Instead, we follow a theoretically more involved but more efficient approach.For this, we use a structural property of our problem related to Hall's theorem, which decreases the number of variables in our ILP to O(|C| • k).We reuse some of the results from this section in Section 4, where we prove that Max-Min/MoV Fair Matching are actually fixed-parameter tractable with respect to k.
1 y }, {v y , u 2 y }, and {v y , u y }.If only l 1 y and l 2 y are true, then add {v y , u 1 y }, {v 2 y , u 2 y }, and {v y , u y }.If only l 1 y (or l 2 y ) and l 3 y are true, then add {v y , u 1 y }, {v 2 y , u 2 y }, and {v y , u y }.
3 s }) has no vertex of color c other than a 1 s and a 2 s , and thus as M is left-perfect and a 1 s , a 2 s Stoica et al. [31] presented a straightforward XP algorithm for MoV Fair Matching on a complete graph with size constraints parameterized by |V | but left open the classical complexity.We partially settle this open question by proving that MoV Fair Matching on complete bipartite graphs is polynomial-time solvable even with the non-emptiness constraint.