A Refined Complexity Analysis of Fair Districting over Graphs
aa r X i v : . [ c s . G T ] F e b A Refined Complexity Analysis of Fair Districting overGraphs ∗ Niclas Boehmer † Tomohiro Koana ‡ Rolf NiedermeierTU Berlin, Algorithmics and Computational Complexity, Germany { niclas.boehmer,tomohiro.koana,rolf.niedermeier } @tu-berlin.de Abstract
We study the NP-hard
Fair Connected Districting problem: Partition a vertex-coloredgraph into k connected components (subsequently referred to as districts) so that in eachdistrict the most frequent color occurs at most a given number of times more often than thesecond most frequent color. Fair Connected Districting is motivated by various real-world scenarios where agents of different types, which are one-to-one represented by nodes ina network, have to be partitioned into disjoint districts. Herein, one strives for “fair districts”without any type being in a dominating majority in any of the districts. This is to e.g. preventsegregation or political domination of some political party.Our work builds on a model recently proposed by Stoica et al. [AAMAS 2020], therebyalso strengthening and extending computational hardness results from there. More specifi-cally, with
Fair Connected Districting we identify a natural, already hard special caseof their
Fair Connected Regrouping problem. We conduct a fine-grained analysis of the(parameterized) computational complexity of
Fair Connected Districting , proving thatit is polynomial-time solvable on paths, cycles, stars, caterpillars, and cliques, but alreadybecomes NP-hard on trees. Motivated by the latter negative result, we perform a param-eterized complexity analysis with respect to various graph parameters, including treewidth,and problem-specific parameters, including the numbers of colors and districts. We obtaina rich and diverse, close to complete picture of the corresponding parameterized complex-ity landscape (that is, a classification along the complexity classes FPT, XP, W[1]-hardness,and para-NP-hardness). Doing so, we draw a fine line between tractability and intractabil-ity and identify structural properties of the underlying graph that make
Fair ConnectedDistricting computationally hard.
Stoica et al. [36] recently introduced a graph-based view on fair (re)districting, employing “marginof victory” as the measure of representation fairness. In their path-breaking work, motivated byapplications in political districting and in fighting racial segregation in schools, they performedtheoretical as well empirical studies, the latter clearly supporting the relevance and practicalimpact of studying the introduced computational problems. While the main contribution of theirwork certainly is with respect to modeling and performing promising empirical studies (basedon greedy heuristics), addressing one of their two main scenarios (in which districts shall beconnected), we significantly extend and deepen their theoretical findings.Dividing agents into groups is a ubiquitous task. Electoral districting is a prime example inthis direction: All voters are assigned to political districts, where each district chooses its own ∗ This work was initiated at the research retreat of the Algorithmics and Computational Complexity group heldin September 2020 in Zinnowitz, Germany. † Supported by the Deutsche Forschungsgemeinschaft (DFG), project MaMu, NI 369/19. ‡ Supported by the Deutsche Forschungsgemeinschaft (DFG), project FPTinP, NI 369/16. fair , where a district is deemed fair if the margin ofvictory in the district is smaller than a given bound. The margin of victory of a district is thenumber of agents that need to be deleted such that there is a tie for the most frequent type in thedistrict. We refer to Stoica et al. [36] for an extensive discussion and motivation of this scenarioand its real-world applications.In this paper, we take upon the studies of Stoica et al. [36] and their call to search for tractablespecial cases of fair districting over graphs. We focus on the
Fair Connected Districting ( FCD ) problem, a natural special case of their
Fair Connected Regrouping problem. In FCD , given a graph G = ( V, E ) with each vertex having some color from a set C and integers k and ℓ , the question is whether it is possible to partition G into k non-empty connected districtseach having margin of victory at most ℓ . The major difference to Fair Connected Regrouping is that
FCD does not impose any constraints on district sizes or to which districts an agent canbe assigned. It is easy to see that
FCD generalizes the known NP-hard
Perfectly Balanced ConnectedPartition problem [12, 10], which asks for a partition of a graph into two connected componentsof the same size. This motivates a parameterized complexity analysis and the study of restrictionsof the underlying graph in order to find tractable special cases. Specifically, we analyze thecomputational complexity of
FCD on specific graph classes and the parameterized complexity of
FCD with respect to several problem-specific parameters (such as | C | and k ) as well as severalparameters measuring structural properties of the underlying graph (such as its treewidth or vertexcover number). Our main reference point is Stoica et al. [36] who introduced the NP-hard
Fair ConnectedRegrouping problem, which is more general than our problem.
Fair Connected Regrouping differs from
FCD in that we are additionally given a global upper and lower bound on the sizeof the districts, a numbering of the districts, and a function that determines for each vertex towhich of the k districts the vertex can belong. Moreover, Stoica et al. [36] considered special casesof Fair Connected Regrouping : Fair Regrouping (omitting connectivity constraints) and
Fair Regrouping X (omitting connectivity constraints and any restriction to which districtsvertices can belong). In addition, they proposed for each of the variants a greedy heuristic andevaluated them using synthetic and real-world data from UK general elections and US publicschools.
FCD is relevant in context of district-based elections. Several papers have studied how topartition a set of voters such that the overall distribution of representatives “fairly” reflects the The two other, closely related, and somewhat simpler problems they study do not demand connectedness. We mention in passing that Stoica et al. [36] use a slightly different definition of margin of victory. While welook at the number of vertices that need to be deleted to have a tied most frequent color, they examine the numberof vertices that need to change their color such that the most frequent color changes. We chose our definition tobe able to distinguish the case of two tied most frequent colors from the case where one color appears once morethan the others (which both have margin of victory one in the model of Stoica et al. [36]). Clearly, there exist alsoother fairness measures, e.g., the difference between the occurrences of the most and least frequent color. Whilethese are natural as well, our definition is particularly appealing if each district may be only associated with itsmost frequent color in case its margin of victory is significantly high.
Gerrymandering is a well-studiedcomputational problem in the context of district-based elections; it can be seen as a counterpartto what we study here. In
Gerrymandering , the task is to partition a set of voters into multipledistricts obeying certain conditions such that a designated alternative wins in as many districts aspossible. An intuitive strategy to solve this problem, which is notably not optimal [33], is to createmany districts where the designated alternative wins only by a small margin and to fill all otherdistricts with as many voters as possible that do not favor the designated alternative. Initially,
Gerrymandering has been predominantly studied from the perspective of social and politicalscience [16, 30, 20]. More recently, however, different variants of
Gerrymandering have beenconsidered from an algorithmic perspective [28, 13]. Notably, the study of
Gerrymandering over graphs, which is pretty much analogous to our setting, very recently gained significantlyincreased interest by various research groups [4, 11, 18, 21]. A similar model for graph-basedredistribution scenarios and political districting has been studied under the name “network-basedvertex dissolution” [5].Numerous additional questions related to
Gerrymandering have been investigated, includingthe influence of the distribution of voters for a party on the party’s power to gerrymander [7],the influence of the voting rule on the misrepresentation of parties [2], and the influence of thedistricting mechanism on the behavior of voters [9].Partitioning agents of different types into maximally balanced groups is conceptually closelyrelated to studies of social segregation. In computer science, social segregation is, for instance,quite extensively studied in the context of Schelling’s segregation model [35]: While initially thework in this context was mostly concerned with the theoretical analysis of segregation patterns[19, 8, 6, 3], recently Schelling’s model has been approached from a game-theoretic perspective [14,1].
Motivated by the results of Stoica et al. [36], we formulate the
Fair Connected Districting ( FCD ) problem and conduct a detailed study of its (parameterized) computational complexity.We study the influence of problem-specific parameters (the number | C | of colors, the number k of districts, and the margin of victory ℓ ) and the structure of the underlying graph on the com-putational complexity of FCD . In particular, we study
FCD on various graph classes, some ofwhich are characterized by a (graph) parameter. We focus on the graph parameters feedback edgenumber (fen), feedback vertex number (fvn), max leaf number (mln), treewidth (tw), and vertexcover number (vc). We begin by showing that
FCD is NP-hard even if | C | = k = 2 and ℓ = 0but polynomial-time solvable on paths, cycles, stars, caterpillars, and cliques. In contrast, FCD on trees turns out to be NP-hard and even W[1]-hard with respect to | C | + k . Figure 1 surveysour parameterized tractability and intractability results. We highlight the following three results: • For cliques and stars (even if the center vertex has a weight for each color), we obtain aprecise characterization of yes-instances resulting in a linear-time algorithm for
FCD onthese graphs (Theorem 1 and Proposition 5). • We develop an XP-algorithm for
FCD parameterized by tw + | C | using a dynamic programon the tree decomposition empowered by some structural observations on FCD (Theorem 4). • We identify several complexity dichotomies. For instance,
FCD is polynomial-time solvableon trees with diameter at most three (Corollary 9), but NP-hard and W[1]-hard with re-spect to | C | + k on trees with diameter four (Corollary 6). Similarly, FCD is NP-hard andW[1]-hard with respect to | C | + k on graphs with pathwidth at least two (Corollary 5) butpolynomial-time solvable on pathwidth-one graphs (Corollary 4).Contrasting the intractability of FCD on even very special graphs (Proposition 2 andTheorem 3), we discover some interesting tractable special cases, for instance, linear-time al-gorithms for cliques (Theorem 1) and stars (Proposition 5) and polynomial-time algorithms for3 w − Th. 3 fvn − Th. 3 fen − Th. 3tw + k − Th. 5 fvn + k − Th. 5 | C | + k − Pr. 2tw + | C | Th. 4 Th. 3tw + | C | + k Th. 4 Th. 3 fen + k Pr. 7 Th. 3 mlnTh. 2 ? vcTh. 6 ?vc + | C | Th. 7 − Figure 1: Overview of our parameterized complexity results for
Fair Connected Districting ( FCD ). Each box represents one parameterization of
FCD (see Section 2 for definitions of theparameters). An arc from one box for a parameter p to another box for a parameter p ′ indicatesthat p can be upper-bounded in a function of p ′ . For parameters that are placed in the red area, weprove that FCD is para-NP-hard. For parameters in the orange area, we prove W[1]-hardness andpresent an XP-algorithm. For parameters in the yellow area, we construct an XP-algorithm but donot know whether the problem is W[1]-hard. The green area indicates fixed-parameter tractability.For each parameter, in the second row, we reference on the left the respective algorithmic resultand on the right the respective hardness result (if known).graphs that consist of a constant number of paths and cycles (Theorem 2) or graphs with a con-stant vertex cover number (Theorem 6). Moreover, assuming that the number | C | of colors isconstant, which is realistic for some applications, FCD is polynomial-time solvable on tree-likegraphs, that is, graphs having constant treewidth (Theorem 4).Lastly, we remark that while the values of the parameters | C | and k have a strong influence onthe complexity of FCD , the maximally allowed margin of victory ℓ has only little impact as nearlyall hardness results already hold for ℓ = 0 and all our algorithmic results hold for arbitrary ℓ . Organization
The paper is structured as follows. In Section 2, we formally introduce
FairConnected Districting and the graph parameters we examine. In Section 3, we present somefirst results on
Fair Connected Districting mostly concerning NP-hardness. Subsequently,we show in Section 4 that
Fair Connected Districting on cliques, which is closely related to
Fair Regrouping X studied by Stoica et al. [36], is polynomial-time solvable. In Section 5, wethen consider
Fair Connected Districting on very special graph classes such as paths andcycles as well as on graphs that can be partitioned into a bounded number of those. In Section 6,we shift our attention to trees and graphs that are tree-like. Lastly, in Section 7, we analyze theinfluence of the vertex cover number on the complexity of
Fair Connected Districting .We defer several (parts of) proofs (marked by ( ⋆ )) to an appendix. For a, b ∈ N , let [ a, b ] denote { a, a + 1 , . . . , b − , b } and let [ b ] denote [1 , b ]. Fair Connected Districting
Throughout the paper, all graphs G = ( V, E ) are undirectedand have no self-loops or multi-edges. By convention, we will use n := | V | . Given a graph G = ( V, E ) and a vertex set V ′ ⊆ V , let G [ V ′ ] be the graph G induced by the vertices from V ′ .Let C = { c , . . . , c | C | } be the set of colors. We assume that each vertex v ∈ V has a single color c ∈ C determined by a given coloring function col : V C . For a vertex set V ′ ⊆ V , let χ c ( V ′ )4enote the number of vertices of color c in V ′ . Moreover, let χ ( V ′ ) ∈ N | C | denote the vectorin which the i th entry contains the number of vertices of color c i in V ′ , i.e, χ i ( V ′ ) = χ c i ( V ′ ).For a vector x = ( x , . . . x t ) ∈ N t , let i ∗ x denote an index with the highest entry in x , i.e., i ∗ x ∈ arg max i ∈ [ t ] x i . The margin of victory MOV( x ) of a vector x is defined as the differencebetween the largest and second largest entry in x , i.e., MOV( x ) := x i ∗ x − max i ∈ [ t ] \{ i ∗ x } x i . If t = 1,then we set MOV( x ) := x . Accordingly, we define the margin of victory MOV( V ′ ) of a vertex set V ′ ⊆ V as MOV( V ′ ) := MOV( χ ( V ′ )). For ℓ ∈ N , we call a vertex set V ′ ℓ -fair if MOV( V ′ ) ≤ ℓ .We use the term district to refer to a vertex set V ′ ⊆ V . We say that a color c i ∈ C is the j th mostfrequent color in a district V ′ if χ i ( V ′ ) is the j th largest entry in χ ( V ′ ) (we break ties arbitrarilyunless stated otherwise).Using these definitions, we are now ready to present our central problem: Fair Connected Districting (FCD)
Input:
A graph G = ( V, E ), a set C of colors, a function col : V C assigning each ver-tex one color from C , a number k ≤ | V | of districts, and a maximum margin of victory ℓ . Question:
Does there exist a partition of the vertices into k non-empty districts( V , . . . , V k ) such that, for all i ∈ [ k ], V i is ℓ -fair and G [ V i ] is connected? Graph Parameters
In the following, we define several popular graph parameters for an undi-rected graph G = ( V, E ) that we examine. The diameter of G is the maximum distance betweenany pair of vertices. The max leaf number mln( G ) (for a connected graph G ) is the maximumnumber of leaves over all spanning trees of G . A vertex set V ′ ⊆ V is a vertex cover of G if atleast one endpoint of every edge in E is in V ′ . We denote the size of a smallest vertex cover of G as the vertex cover number vc( G ). An edge set E ′ ⊆ E is a feedback edge set if ( V, E \ E ′ ) is aforest. The feedback edge number fen( G ) is the size of a smallest feedback edge set. Analogously,a vertex set V ′ ⊆ V is a feedback vertex set if G [ V \ V ′ ] is a forest. The feedback vertex number fvn( G ) is the size of a smallest feedback vertex set. A tree decomposition of a graph G = ( V, E ) isa pair ( T, { B x } x ∈ V T ), where T = ( V T , E T ) is a rooted tree and B x ⊆ V for each x ∈ V T such that1. S x ∈ V T B x = V ,2. for each edge { u, v } ∈ E , there exists an x ∈ V T with u, v ∈ B x , and3. for each v ∈ V , the set of nodes x ∈ V T with v ∈ B x induces a connected subtree in T .The width of ( T, { B x } x ∈ V T ) is max x ∈ V T | B x | −
1. The treewidth tw( G ) of G is the minimumwidth of all tree decompositions of G . The pathwidth pw( G ) of G is defined analogously with theadditional constraint that T is a path.If the graph G is clear from context, then we simply omit it and write mln, fen, fvn, tw,and pw. For all our parameterized algorithmic results with respect to one of these parameters,we assume that the corresponding structure is given as part of the input. For instance, in ouralgorithm parameterized by tw, we assume that we are given a tree decomposition. However, notethat in all cases, the worst-case running time of our algorithms would not change if we computethe structure by ourselves using known parameterized algorithms from the literature. Parameterized Complexity Theory A parameterized problem L consists of a problem in-stance I and a parameter value k ∈ N . Then L lies in XP with respect to k if there exists analgorithm deciding L in |I| f ( k ) time for some computable function f . Furthermore, L is called fixed-parameter tractable with respect to k if there exists an algorithm deciding L in f ( k ) |I| O (1) time for a computable function f . The corresponding complexity class is called FPT. There is ahierarchy of complexity classes for parameterized problems: FPT ⊆ W[1] ⊆ W[2] ⊆ XP, where it iscommonly believed that all inclusions are strict. Thus, if L is shown to be W[1]-hard, then thecommon belief is that it is not fixed-parameter tractable. For instance, computing a clique of sizeat least k in a graph is known to be W[1]-hard with respect to the parameter k . One can showthat L is W[ t ]-hard, t ≥
1, by a parameterized reduction from a known W[ t ]-hard parameterized5roblem L ′ . A parameterized reduction from L ′ to L is a function that maps an instance ( I ′ , k ′ )of L ′ to an instance ( I , k ) of L such that ( I ′ , k ′ ) is a yes-instance for L ′ if and only if ( I , k ) is ayes-instance for L . Moreover, we require that k is bounded in a computable function of k ′ andthat the transformation takes at most f ( k ′ ) |I| O (1) time for some computable function f . Finally,note that saying that a parameterized problem is para-NP-hard means that it is NP-hard even forconstant parameter values. In this section, we make preliminary observations on the computational complexity of
FCD .First, we prove that
FCD is para-NP-hard with respect to the combined three problem-specificparameters | C | + k + ℓ . This strong general hardness result motivates the study of various restrictedgraph classes in subsequent sections.The NP-hardness of FCD easily follows from the fact that it generalizes the NP-hard
Maxi-mally Balanced Connected Partition problem:
Maximally Balanced Connected Partition
Input:
A graph G = ( V, E ) and an integer t . Question:
Does there exist a partition ( V , V ) of the vertex set V such that G [ V ]and G [ V ] are connected and min( | V | , | V | ) ≥ t ?It is NP-hard even to approximate t with an absolute error guarantee of | V | − ǫ for any ε > G = ( V, E ) , t )of Maximally Balanced Connected Partition , construct an equivalent instance of
FCD bycoloring all vertices in G in the same color, setting k = 2 and ℓ = | V | − t . From this the hardnessof FCD directly follows:
Proposition 1.
FCD is NP-hard even if | C | = 1 , k = 2 , and the input graph G is bipartite. For ǫ > , given a vertex-colored graph G = ( V, E ) and an integer k , it is NP-hard to approximatewith an absolute error guarantee of | V | − ǫ the minimum ℓ such that the resulting FCD instanceis a yes-instance.
The NP-hardness persists for | C | ≥
2. For the proof, we reduce from the special case of
Maximally Balanced Connected Partition with t = | V | , which is known as PerfectlyBalanced Connected Partition . This problem is NP-hard on bipartite graphs [12]. OurNP-hardness holds even if ℓ = 0. Proposition 2 ( ⋆ ) . FCD on a graph G is NP-hard, even if ℓ = 0 , | C | = 2 , k = 2 , and G isbipartite.Proof Sketch. We describe a polynomial-time Turing reduction from
Perfectly BalancedConnected Partition to FCD .Given an instance ( G = ( V, E )) of
Perfectly Balanced Connected Partition with n := | V | , for each pair of vertices ( v, v ′ ) ∈ V , construct an instance of FCD : Set C = { c , c } , k = 2, and ℓ = 0. Color all vertices of the given graph G with c . Moreover, modify G byintroducing n new vertices of color c . Connect half of these vertices to v and the other half to v ′ .Return yes if one of the constructed FCD instances is a yes-instance, and no otherwise.Proposition 2 strengthens an NP-hardness result of Stoica et al. [36]: They showed that
FCD is NP-hard for | C | = 2 and k = 2 albeit with additional restrictive constraints, where one canspecify the subsets of districts to which each vertex is assigned.Lastly, using a simple dynamic program, we show that an instance of FCD on a disconnectedgraph is polynomial-time solvable whenever
FCD can be solved in polynomial time on its connectedcomponents. This will play a crucial role, e.g., in the proof of Theorem 2.6 roposition 3 ( ⋆ ) . Let G be a class of graphs such that FCD is polynomial-time solvable onany graph G ∈ G . Then, FCD is polynomial-time solvable on any graph from G ′ , where G ′ is theclass of graphs obtained by taking disjoint unions of graphs from G . Fair Regrouping X is among the three fair regrouping problems Stoica et al. [36] introduced.This problem basically corresponds to
FCD without any connectivity constraints (so the under-lying graph is a clique). The only difference is that
Fair Regrouping X also has global upperand lower bounds on the size of every district. Stoica et al. [36] presented a straightforward XPalgorithm for
Fair Regrouping X parameterized by the number k of districts but left open theclassical complexity of this problem. We partially settle this open question by proving that FCD on cliques (which corresponds to
Fair Regrouping X without constraints on the size of eachdistrict) is polynomial-time solvable. In fact, we find a precise characterization of yes-instances,which yields a linear-time algorithm. To simplify notation, in the following theorem, we assumethat χ c i ( V ) ≥ χ c i +1 ( V ) for each i ∈ [1 , | C | −
1] and χ c i ( V ) = 0 for i > | C | . Theorem 1. An FCD instance ( G = ( V, E ) , C, k, ℓ ) with G being a clique is a yes-instance ifand only if • ℓ > or | V | ≥ k and • χ c ( V ) ≤ ℓk + P i ∈ [ k ] χ c i +1 ( V ) .Proof. Let I = ( G = ( V, E ) , C, k, ℓ ) be an FCD instance, where G is a clique. To prove thetheorem, we consider both directions of the statement separately. We start by proving thatif I is a yes-instance, then it needs to satisfy the two constraints stated in the theorem: If ℓ = 0, then each district contains at least two vertices and thus it holds that | V | ≥ k forany yes-instance. Moreover, for any solution ( V , . . . , V k ), for each i ∈ [ k ], let c ′ i denote themost frequent color in V i among C \ { c } . Since V i is ℓ -fair for each i ∈ [ k ], we then have χ c ( V ) = P i ∈ [ k ] χ c ( V i ) ≤ P i ∈ [ k ] ( χ c ′ i ( V i ) + ℓ ) ≤ ℓk + P i ∈ [ k ] χ c i +1 ( V ).We now prove the reverse direction: If I fulfills the two constraints stated in the theorem,then it is a yes-instance. To do so, we assume that I satisfies χ c ( V ) ≤ ℓ · k + P i ∈ [ k ] χ c i ( V ) (and | V | ≥ k if ℓ = 0) and present an algorithm that constructs a solution ( V , . . . , V k ) for I . Thealgorithm is split in two parts. In the first part, we partition the vertices in k ′ districts for some k ′ < k that are all ℓ -fair. In the second part, we modify this partitioning by adding more non-empty districts (we do so by deleting vertices from the already constructed districts) to mach thegiven number k of districts. In the second part, we distinguish between the case ℓ > ℓ = 0.We now start by describing the first part of the algorithm. Let V ′ := V and let i := 1. We dothe following as long as there are at least χ c i +1 ( V ′ ) + ℓ vertices of color c in V ′ : • Move χ c i +1 ( V ′ ) + ℓ vertices of color c from V ′ to V i . • Move χ c i +1 ( V ′ ) vertices of color c i +1 from V ′ to V i . • Increment i by 1.If there are vertices of color c left in V ′ , then we create an additional district V i consisting ofmin( χ c i +1 ( V ′ ) , χ c ( V ′ )) vertices of color c i +1 and χ c ( V ′ ) vertices of color c . Finally, we add theremaining vertices in V ′ to V . Suppose that the above procedure results in non-empty districts( V , . . . , V k ′ ). By the assumption that χ c ( V ) ≤ ℓ · k + P i ∈ [ k ] χ c i ( V ), it holds that k ≥ k ′ .Moreover, by construction, district V i is guaranteed to be ℓ -fair for every i ∈ [ k ′ ]. If k ′ = k , thenwe are done. So assume that k ′ < k .We now come to the second part of the algorithm that deletes vertices from ( V , . . . , V k ′ ) andputs them into new districts to obtain more non-empty districts and to match the given number k of districts. We distinguish two cases: 7f ℓ >
0, then we do the following until we have k non-empty districts. Choose an arbitrarydistrict V i of size at least two and some vertex v ∈ V i of the most frequent color in V i . We delete v from V i and put v into its own district. Clearly, a district consisting of one vertex is 1-fair.Moreover, V i remains ℓ -fair: Unless MOV( V i ) = 0, deleting v does not increase MOV( V i ). Since | V | ≥ k , this procedure eventually results in k districts that are ℓ -fair.It remains to consider the case ℓ = 0. Here, the way we obtain more non-empty districtsbecomes more intricate. We again describe an algorithm that takes as input the ℓ -fair districts( V , . . . , V k ′ ) created above and constructs from this a solution to the given instance I . We startby executing the following steps excessively one after each other until the number of districtsreaches k : • If | V i | > i ∈ [2 , k ′ ], then remove one vertex of color c and another of color c i +1 from V i to put them into a new district. Observe that V i remains 0-fair and that the new districtis also 0-fair. • If V contains vertices of more than three colors, then choose two vertices v, v ′ of distinctcolors in C \ { c , c } to obtain another 0-fair district { v, v ′ } . As the number of occurrencesof the two most frequent colors in V i does not change, V remains 0-fair. • If V contains vertices of exactly three colors c , c , c ′ and χ c ( V ) = χ c ( V ) > χ c ′ ( V ), thendelete one vertex v of color c and another v ′ of color c to make a new district { v, v ′ } . Aswe remove both a vertex of color c can c , V remains 0-fair.Suppose that after executing this procedure we still have less than k districts. For some color c ′ ∈ C \ { c , c } , we then have α := χ c ( V ) = χ c ( V ) = χ c ′ ( V ) and χ c ( V ) = 0 for c ∈ C \ { c , c , c ′ } .Since every district (except for V ) is of size two, we have ( n − α ) + 1 districts. Thus, it sufficesto show that V can be partitioned into k ′′ := k − ( n − α ) districts that are all 0-fair. By theassumption that n ≥ k , we have 2 k ′′ ≤ α .As argued above, it remains to show that the constructed V can be partitioned into κ κ > κ ≤ α . For each i ∈ [3], let v i , . . . , v αi be the vertices ofcolor c i ( c ′ i for i = 3) in V . Observe that V can be partitioned into κ districts whenever κ ≤ α :Let the j th district be { v j , v j , v j } for each j ∈ [ κ −
1] and let the κ th district be the set of allother vertices. Now we address the remaining case by proving via induction on α that there is apartition of V into κ κ > α with 2 κ ≤ α . It clearly holds for α = 1.For α = 2, V can be partitioned into κ = 3 0-fair districts: { v , v } , { v , v } , { v , v } . Supposethat α ≥
3. If α is odd, then V \ { v α , v α , v α } can be partitioned into κ − v α , v α , v α form a 0-fair district, we obtain a desired partition of V .If α is even, then V \ { v α − , v α , v α − , v α , v α − , v α } can be partitioned into κ − α = 2, { v α − , v α , v α − , v α , v α − , v α } can be partitionedinto three 0-fair districts. Thus, we have constructed a desired partition of V into κ districts.Theorem 1 directly implies the following. Corollary 1.
FCD on cliques is solvable in linear time.
In this section, we continue our complexity analysis on special graph classes. We developpolynomial-time algorithms for simple graphs, i.e., paths, cycles, stars and caterpillars. Sub-sequently, we show that
FCD is in XP when parameterized by the max leaf number, whichgeneralizes polynomial-time solvability on paths and cycles.
We start by proving that
FCD is cubic-time solvable on paths using a simple dynamic program.8 roposition 4.
FCD on paths can be solved in O ( k · n ) time.Proof. Let G = ( { v , . . . , v n } , {{ v i , v i +1 } | i ∈ [ n − } ) be the input path. We first create atable A [ i, j ], where A [ i, j ] for i ≤ j ∈ [ n ] is true if and only if { v i , . . . , v j } is ℓ -fair. We then createa table T with entries T [ i, t ] for i ∈ [ n ] and t ∈ [ k ]. The intended meaning of an entry T [ i, t ] isthat it is true if there is a partition of the vertices { v , . . . , v i } into t paths that are all ℓ -fair. Notethat the input is a yes-instance if and only if T [ n, k ] is true.We initialize table T by setting T [ i,
1] for i ∈ [ n ] to A [1 , i ]. Subsequently, for t >
1, we updatethe table using: T [ i, t ] = _ j ∈ [ i − T [ j, t − ∧ A [ j + 1 , i ] . The table A can be filled in O ( n ) time. To see this, note that for a fixed i ∈ [ n ], wecan compute all A [ i, n − j ] for j ∈ [0 , n − i ] in linear time by starting for j = 0 with com-puting χ ( { v i , . . . , v n − j } ) and, subsequently, for increasing j > χ ( { v i , . . . , v n − j } ) = χ ( { v i , . . . , v n − j +1 } ) − χ ( { v n − j +1 } ) (which can be done in constant time). Moreover, table T con-sists of k · n entries. We spend O ( n ) time for every entry; this results in an overall running timeof O ( k · n ).To solve FCD on cycles, we iterate over all vertices of the cycle as the starting point of thefirst district and split the cycle at this point to convert it into a path. Subsequently, we employthe algorithm from above, which results in a running time of O ( k · n ): Corollary 2.
FCD on cycles is solvable in O ( k · n ) time. Next, we proceed to stars, for which we derive a precise characterization of yes-instances. Infact, we consider a more general problem, in which some set X of leaves must belong to the samedistrict as the center district. This proves useful in the speed-ups of algorithms to be presentedin Propositions 6 and 8. Proposition 5.
Let ( G = ( X ∪ Y, E ) , C, col , k, ℓ ) be an FCD instance where G is a star withcenter vertex v ∈ X . It is possible to decide in linear time whether there exists a partition of X ∪ Y into k connected ℓ -fair districts such that all vertices from X are part of the same district.Proof. In the following, we call a partition of the vertices in X ∪ Y into k connected districts asolution if each district is ℓ -fair and all vertices from X are part of the same district to whichwe refer as the center district. Note that each solution consists of the center district and severaldistricts consisting of a single vertex from Y . We now describe a linear-time algorithm that decideswhether a given FCD instance admits a solution.We start with several special cases: For ℓ = 0, a solution exists if and only if MOV( X ∪ Y ) = 0and k = 1. If | C | = 1, then all solutions containing k districts are isomorphic, i.e., they contain k − | Y | ≥ k − ℓ ≥ χ c ( Y ∪ X ) − ( k − C = { c } .Let c ∈ C be the most frequent color in X ∪ Y and c ∈ C be the second most frequent colorin X ∪ Y . If χ c ( X ) > χ c ( X ∪ Y ) + ℓ , then the given instance has no solution because the centerdistrict cannot be ℓ -fair.Having dealt with respective special cases separately, we now present a precise characterizationof yes-instance assuming that | C | > ℓ >
0, and χ c ( X ) ≤ χ c ( X ∪ Y ) + ℓ . Let c ⋆ be the mostfrequent color in X . Further, let c ⋆ = c ⋆ be the most frequent color in X among colors c ′ such that χ c ′ ( X ∪ Y ) ≥ χ c ⋆ ( X ) − ℓ . Note that c ⋆ is always well-defined. If c ⋆ = c , then, by the definitionof c it holds that χ c ( X ∪ Y ) ≥ χ c ⋆ ( X ∪ Y ) > χ c ⋆ ( X ) − ℓ . On the contrary, if c ⋆ = c , then, byour assumption that χ c ( X ) ≤ χ c ( X ∪ Y ) + ℓ , we have χ c ( X ∪ Y ) ≥ χ c ⋆ ( X ) − ℓ .Let b l := max(0 , χ c ( X ∪ Y ) − χ c ( X ∪ Y ) − ℓ ) and b u := max(0 , χ c ⋆ ( X ) − χ c ⋆ ( X ) − ℓ ). Then, X ∪ Y can be partitioned into k connected districts that are all ℓ -fair such that all vertices from X are part of the same district if and only if k ∈ [ b l + 1 , | Y | + 1 − b u ].9e first prove the forward direction, i.e., that the existence of a solution implies that k ∈ [ b l + 1 , | Y | + 1 − b u ]. For any solution, the center district contains at most χ c ( X ∪ Y ) + ℓ verticesof color c . Thus, at least χ c ( X ∪ Y ) − χ c ( X ∪ Y ) − ℓ vertices of color c have to be part ofa non-center district, which implies that k > b l . Next, we show that k ≤ | Y | + 1 − b u . Thecenter district has at least χ c ⋆ ( X ) vertices of color c ⋆ . Since the center district is ℓ -fair, it hasat least χ c ⋆ ( X ) − ℓ vertices of color c for some color c ∈ C \ { c ⋆ } . It follows that there are atleast χ c ⋆ ( X ) − χ c ( X ) − ℓ vertices of color c in Y that are included in the center district. So wehave k ≤ | Y | + 1 − b u .We now prove the backward direction, i.e., that k ∈ [ b l + 1 , | Y | + 1 − b u ] implies the existenceof a solution. Recall that χ c ( X ) ≤ χ c ( X ∪ Y ) + ℓ . So we have χ c ( Y ) = χ c ( X ∪ Y ) − χ c ( X ) ≥ χ c ( X ∪ Y ) − χ c ( X ∪ Y ) − ℓ , and hence χ c ( Y ) ≥ b l . A solution consisting of b l + 1 districts exists:Put all vertices from X ∪ Y in one district and move b l vertices of color c from Y each in theirown district. Let S be the center district in this solution. A solution consisting of | Y | + 1 − b u districts is also guaranteed to exist: Put the vertices of X and b u vertices of color c ⋆ from Y intothe center district; put all remaining vertices from Y into their own district. Let S ′ be the centerdistrict in this solution. Note that from these two solutions, we can construct a solution consistingof k ∈ [ b l + 1 , | Y | + 1 − b u ] districts. For this, we start with the first solution and one by one movevertices from Y ∩ ( S \ S ′ ) from the center district into their own district while maintaining that thecenter district is ℓ -fair. Such a vertex always exists: If there is a vertex v with the most frequentcolor of the center district in Y ∩ ( S \ S ′ ), then we move v from S into its own district (removing v only increases the margin of victory by one if the center district is currently 0-fair). Otherwise,we remove the remaining vertices from Y ∩ ( S \ S ′ ) in an arbitrary order (doing so results in an ℓ -fair center district, since otherwise S ′ would not be ℓ -fair).Proposition 5 directly implies that FCD is linear-time solvable on stars, even if the centervertex has a weight for each color, i.e., the center vertex represents multiple vertices.
Corollary 3.
FCD is linear-time solvable on stars.
Lastly, we extend our polynomial-time algorithm for paths from Proposition 4 to caterpillargraphs. A caterpillar graph is a tree where every vertex is either on a central path (spine) or aneighbor of a vertex on the central path.
Proposition 6.
FCD on caterpillars can be solved in O ( k · n ) time.Proof. Let G = ( V, E ) be the given caterpillar, let ( u , . . . , u p ) denote the spine (central path)of G and let U = { u , . . . , u p } . Moreover, for i ∈ [ p ], let U i consist of u i and all vertices from V \ U adjacent to u i . We solve the problem by extending our algorithm for paths from Proposition 4.As a first step, we introduce a table A [ i, j, t ] for i ≤ j ∈ [ n ] and t ∈ [ k ]. An entry A [ i, j, t ] isset to true if there exists a partition ( V , . . . , V t ) of S i ′ ∈ [ i,j ] U i ′ into t districts such that: • V contains u j for every j ∈ [ i, j ], and • V j is ℓ -fair and G [ V j ] is connected for every j ∈ [ t ].We can fill table A in O ( k · n ) time using Proposition 5 for each A [ i, j, t ] (it is necessary toslightly restructure G [ S i ′ ∈ [ i,j ] U i ′ ]). Using A , we now apply dynamic programming. To this end,we introduce a table T [ i, t ] for i ∈ [ n ] and t ∈ [ k ]. Entry T [ i, t ] is set to true if it is possible topartition the vertices from S j ∈ [ i ] U j into t connected districts that are ℓ -fair. We initialize thetable by setting T [ i,
1] to true if S j ∈ [ i ] U j is ℓ -fair. Subsequently, for t >
1, we update the tableusing: T [ i, t ] = _ j ∈ [ i − ∧ t ′ ,t ′′ ∈ [ t ]: t ′ + t ′′ = t T [ j, t ′ ] ∧ A [ j + 1 , i, t ′′ ] . Table T has k · n entries each computable in O ( k · n ) time. This leads to an overall runningtime of O ( k · n ). 10ote that a graph G has pw( G ) = 1 if and only if G is a disjoint union of caterpillars. ByProposition 3 and Proposition 6, it follows that FCD is polynomial-time solvable on all graphswith pathwidth one.
Corollary 4.
FCD on a graph G with pw( G ) = 1 is polynomial-time solvable. Now, we generalize the polynomial-time solvability on paths and cycles to a larger graph class.More precisely, we develop an XP-algorithm for the max leaf number (mln). Recall that the maxleaf number of a connected graph G is the maximum number of leaves over all spanning trees of G . Notably, any path or cycle has mln = 2. In order to develop a polynomial-time algorithm forconstant mln, we use the notion of branches . Definition 1. A branch in a graph is either a maximal path in which all inner vertices have degreetwo or a cycle in which all but one vertex have degree two. Using a classical theorem of Kleitman and West [23], Eppstein [15] showed that any graph hasat most O (mln ) branches. For notational brevity, we assume that every branch in B that is acycle has exactly one endpoint, namely, the vertex in B with degree at least three (if there is nosuch vertex in B , then we fix an arbitrary vertex as its endpoint). Theorem 2.
FCD can be solved in n O (mln ) time.Proof. Let B be the set of all branches and let X be the set of all endpoints of all branches.Suppose that there exists a solution V = ( V , . . . , V k ). Observe that there are at most | X | subsetsin V containing at least one vertex from X . Without loss of generality, assume that V i has at leastone vertex of X for i ∈ [ k ′ ], and let X i = X ∩ V i . Let us now consider the relationship between adistrict V i for i ∈ [ k ′ ] and a branch B = ( v , . . . , v l ) ∈ B (if B is a cycle, then v = v l ). Since V i induces a connected subgraph in G , the following holds: • If v , v l / ∈ X i , then V i and B are disjoint: Since V i is connected and contains at least onevertex from X \ { v , v l } , V i contains no inner vertices from B . • If v ∈ X i and v l / ∈ X i , then there is an integer j ∈ [ l −
1] such that V i ∩ { v , . . . , v l } = { v , . . . , v j } (for v / ∈ X i and v l ∈ X i , the situation is symmetric). • If v , v l ∈ X i for some i ∈ [ k ], then there are two integers j, j ′ ∈ [ l ] such that V i ∩{ v , . . . , v l } = { v , . . . , v j } ∪ { v l − j ′ +1 , . . . , v l } . Note that V i contains all vertices of B when j + j ′ = l .For all other districts V i , i ∈ [ k ′ + 1 , k ], it holds that there exists a branch ( v , . . . , v l ) ∈ B with V i ⊆ { v , . . . , v l − } .Utilizing these observations, our algorithm proceeds as follows. We iterate over all possiblecombinations of the following (note that the number of combinations is n O ( |B| ) = n O (mln ) ): • An integer k ′ ∈ [ k ]. • A partition X = ( X , . . . , X k ′ ) of X into k ′ subsets. • For every branch B = ( v , . . . , v l ) ∈ B , two integers j B , j ′ B ∈ [ l ] with j B + j ′ B ≤ l .For every i ∈ [ k ′ ] and every branch B = ( v , . . . , v l ) ∈ B , let V i,B be the vertex set defined asfollows: • If v , v l / ∈ X i , then V i,B := ∅ . • If v ∈ X i and v l / ∈ X i , then V i,B := { v , . . . , v j B } . Symmetrically, if v / ∈ X i and v l ∈ X i ,then V i,B := { v l − j ′ B +1 , . . . , v l } . • If v , v l ∈ X i , then V i,B = { v , . . . , v j B } ∪ { v l − j ′ B +1 , . . . , v l } .11or i ∈ [ k ′ ], let V i := S B ∈B V i,B . Our algorithm checks whether the set V i is ℓ -fair for every i ∈ [ k ′ ]. If there is a V i that is not ℓ -fair, then we proceed to the next combination. So assumethat V i is ℓ -fair for all i ∈ [ k ′ ]. Then, it remains to determine whether the vertices V \ S i ∈ [ k ′ ] V i canbe partitioned into k − k ′ districts that are ℓ -fair. Since G [ V \ S i ∈ [ k ′ ] V i ] is a disjoint union of pathsas all endpoints are contained in S i ∈ [ k ′ ] V i , this can be done in polynomial time by Propositions 3and 4.We leave open whether FCD parameterized by mln is fixed-parameter tractable or W[1]-hard.However, we conjecture that it is W[1]-hard, making
FCD a promising candidate for a problemthat is in XP with respect to mln yet W[1]-hard (we are not aware of any such problem).
After we have seen in the last section that
FCD is polynomial-time solvable on paths, cycles, stars,and caterpillars, we now turn to trees. In Section 6.1, we prove that these polynomial-time resultsdo not extend to trees. In particular, we prove that
FCD on trees is NP-hard and W[1]-hardparameterized by | C | + k . We complement this negative result with an XP-algorithm for FCD ontrees parameterized by | C | and another parameterized by k . In fact, both XP-algorithms furtherextend to tree-like graphs: In Section 6.2, we prove that FCD parameterized by the treewidthof the given graph plus | C | is in XP. Subsequently, in Section 6.3, we consider the feedback edgenumber (fen), which is an alternative measure for tree-likeness. We prove that FCD parameterizedby fen + k is in XP. Lastly, in Section 6.4, we show that there is presumably no analogous resultfor the treewidth and the feedback vertex number (fvn) by showing that FCD is NP-hard evenif fvn = 1, tw = 2, and k = 2. In this subsection, we show that
FCD on trees is NP-hard. Simultaneously, we show that
FCD parameterized by the number k of districts and the number | C | of colors is W[1]-hard. To thisend, we present a parameterized reduction from the following version of Grid Tiling which isW[1]-hard with respect to t [31] (in this subsection, all indices are taken modulo t ): Grid Tiling
Input:
A collection S of t (tile) sets S i,j ⊆ [ m ] × [ m ], i, j ∈ [ t ], where each S i,j consistsof n pairs and the first entries of all pairs (tiles) from S i,j sum up to the same number X and the second entries of all pairs from S i,j sum up to the same number Y . Question:
Can one choose one tile ( x i,j , y i,j ) ∈ S i,j for each i, j ∈ [ t ] such that x i,j = x i +1 ,j and y i,j = y i,j +1 ?Without loss of generality, we assume that n > FCD instancehas a center district (which contains the center vertex ). The center district further contains somelarge number Z of vertices of two “dummy” colors c and c ′ . The instance is constructed suchthat in a solution the number of vertices of any color in the center district can be at most Z .By definition, each tile ( x, y ) belongs to one of t tile sets S i,j ∈ S . We construct a star T i,jx,y foreach tile such that for each tile set S i,j ∈ S , all but exactly one star T i,jx,y need to be containedin the center district. Thus, the center district (respectively its complement) basically encodes aselection of one tile from each tile set. Moreover, we construct the FCD instance in such a waythat for two stars from two “adjacent” tile sets the respective first or second entries of the tilesneed to match; otherwise the number of vertices of some color in the central district will exceed Z . Construction.
Let ( S , t, m, n, X, Y ) be an instance of Grid Tiling . We construct an in-stance of
FCD as follows.First of all, we set ℓ = 0 and k = t + 1. For each i, j ∈ [ t ], we introduce three distinct colors b i,j , d i,j , and c i,j . Moreover, we introduce three distinct colors c , c ′ , and c ⋆ . Now, we fix some12onstants which we use later. Let W := 5 n ( t + t ) + 1, Z := 2( n − · m · W , f ( i, j ) := i · t + j ,and g ( i, j ) := t + t + i · t + j .We are now ready to construct the vertex-colored graph G = ( V, E ). We start by introducinga center vertex v center of color c ⋆ . In a solution, we call the district containing v center the centerdistrict . We attach to v center Z vertices of color c ′ and Z vertices of color c .For each i, j ∈ [ t ] and ( x, y ) ∈ S i,j , we construct a star T i,jx,y and connect its center to v center .We color the center of T i,jx,y in c ⋆ . Moreover, T i,jx,y has the following leaves: • Z n − + W · x − f ( i, j ) vertices of color d i,j , • Z n − − W · x − f ( i ′ , j ) vertices of color d i ′ ,j for i ′ := i + 1 mod k , • Z n − + W · y − g ( i, j ) vertices of color b i,j , • Z n − − W · y − g ( i, j ′ ) vertices of color b i,j ′ for j ′ := j + 1 mod k , and • max( Z n − + W · x − f ( i, j ) , Z n − + W · y − g ( i, j )) vertices of color c i,j .We start with a simple observation on the total number of vertices of some of the colors: Observation 1 ( ⋆ ) . For each i, j ∈ [ t ] , it holds that χ d i,j ( V ) = nn − Z − nf ( i, j ) and χ b i,j ( V ) = nn − Z − ng ( i, j ) . For all i, j ∈ [ k ] , it holds that χ c i,j ( V ) ≤ Z . Using Observation 1, we now prove the forward direction of the correctness of the construction.
Lemma 1.
If the given
Grid Tiling instance is a yes-instance, then the constructed
FCD instance is a yes-instance.Proof.
Let S = { ( x i,j , y i,j ) ∈ S i,j | i, j ∈ [ t ] } be a solution for the given Grid Tiling instance.From this we construct a solution of the
FCD instance as follows. For each ( x i,j , y i,j ) ∈ S , wecreate a separate district and put into this district all vertices from the star corresponding to( x i,j , y i,j ). We put all other vertices in the center district. Note that this construction respectsthe given number k = t + 1 of districts and that all districts are by construction connected.It remains to argue that all created districts are 0-fair. Since every star is 0-fair by construction,all non-center districts are 0-fair. For the center district, note that it contains Z vertices of color c and Z vertices of color c ′ . Thus, it is sufficient to argue that there is no color such that thenumber of its occurrences in the center district exceeds Z . For color c i,j this directly follows fromObservation 1. Next we consider color d i,j for some i, j ∈ [ t ]. All stars with some vertices ofcolor d i,j are part of the center district, except for the one corresponding to ( x i,j , y i,j ) and theone corresponding to ( x i − ,j , y i − ,j ). Since S is a solution, we have x i − ,j = x i,j . Consequently,exactly Zn − − f ( i, j ) vertices of color d i,j are excluded from the center district. Now it followsfrom Observation 1 that the number of vertices of color d i,j in the center district is at most Z .An analogous argument also holds for b i,j for i, j ∈ [ t ], which concludes the proof.We given an overview of the proof of the other direction here (for details, see Appendix B.1).We first observe that for every star, all of its vertices have to belong to the same district. Subse-quently, we prove that the center district can contain at most Z vertices of each color. We thenshow that in order to respect this bound, exactly one star corresponding to a tile from each tile setmust be excluded from the center district. Again exploiting the fact that every color has at most Z occurrences in the center district, we show that those excluded tiles form indeed a solution tothe given Grid Tiling instance:
Lemma 2 ( ⋆ ) . If the constructed
FCD instance is a yes-instance, then the given
Grid Tiling instance is a yes-instance.
From Lemma 1 and Lemma 2 the correctness of the reduction follows:13 heorem 3.
FCD on trees is NP-hard and W[1]-hard with respect to | C | + k . Recall that by Corollary 4,
FCD can be solved in polynomial time on all graphs with pathwidthone (disjoint unions of caterpillars). Observe that the tree constructed in the reduction above hasonly pathwidth two: Graph G ′ obtained from G by deleting v center is a disjoint union of stars.Thus, G ′ admits a path decomposition of width one. Placing v center into every bag yields a pathdecomposition of G of width two. This results in the following. Corollary 5.
FCD on graphs G with pw( G ) = 2 is NP-hard and W[1]-hard with respect to | C | + k . Moreover, as the tree constructed in the previous reduction has diameter four (it consists of acenter vertex and centers of stars attached to it), we can conclude that
FCD is computationallyintractable even on trees with a small constant diameter:
Corollary 6.
FCD is NP-hard and W[1]-hard with respect to | C | + k on trees with diameter four. + | C | Motivated by the hardness result from the previous subsection, we started to search for an XP-algorithm for the parameters | C | and k for FCD on trees. Here, we study the parameter | C | and show that there exists an XP-algorithm with respect to this parameter applying to tree-likegraphs, that is, we present an XP-algorithm with respect to | C | + tw, where tw is the treewidthof the underlying graph.Given a graph G = ( V, E ), a tree decomposition ( T = ( V T , E T ) , { B x } x ∈ V T ) of G is nice if eachnode x ∈ V T has one of the following types : Leaf node.
A leaf of T with B x = { v } for v ∈ V . Introduce vertex v node. An internal node of T with one child y such that B x = B y ∪ { v } . Introduce edge { u, v } node. An internal node of T with one child y such that u, v ∈ B x = B y . Forget v node. An internal node of T with one child y such that B x = B y \ { v } for v ∈ B y . Join node.
An internal node of T with two children y and z such that B x = B y = B z .We additionally require that every edge is introduced exactly once. We will implicitly assumethat every introduce edge { u, v } node is labeled by { u, v } . Given a tree decomposition, a nice treedecomposition of equal width can be computed in linear time [24]. Theorem 4 ( ⋆ ) . FCD can be solved in O ( n O (tw ·| C | ) ) time.Proof (First Part). Suppose that we are given an instance I = ( G, C, col , k, ℓ ) of
FCD admittinga solution V = { V , . . . , V k } . Let ( T = ( V T , E T ) , { B x } x ∈ V T ) be a tree decomposition of G . For x ∈ V T , let y ∈ V T (and z ∈ V T ) be the child node(s) of x if x has one (two) child node(s) in T .For x ∈ V T , let G x be the graph whose vertices and edges are those introduced in a node from thesubtree of T rooted at x . Further, let U x be the set of vertices in G x . Our algorithm is a dynamicprogram that traverses T from bottom to top.Observe that each district V i ∈ V from the solution is of one of the following three types withrespect to each x ∈ V T :(i) V i ∩ B x = ∅ , i.e., the district V i overlaps with the vertices in the bag of x .(ii) V i ∩ B x = ∅ and V i ⊆ U x , i.e., the district V i is disjoint from B x but fully contained invertices from bags from the subtree rooted at x .(iii) V i ∩ B x = ∅ and V i ⊆ V \ U x , i.e., the district V i is disjoint from B x and does not containany vertex occurring in a bag from the subtree rooted at x . Note that, in the following, we refer to the elements of V as vertices and the elements of V T as nodes. V i ∈ V of type (i), the induced subgraph G x [ V i ] can have multiple connectedcomponents, in which case G [ V i ] includes some vertices or edges not in G x .For each x ∈ V T , our dynamic program keeps track of the following information:(1) the intersection of B x and every V i ∈ V of type (i),(2) the intersection of B x with the connected components of the subgraph G x [ V i ] for all districts V i ∈ V of type (i),(3) the number of occurrences of color c for every color c ∈ C in V i ∩ U x for every district V i ∈ V of type (i), and(4) the number of districts of type (ii).We capture this information in the following variables: For each x ∈ V T , let (1) B be a partitionof B x , (2) D be a partition of B x with each subset from D being contained in some subset of B ,(3) ζ : B → N | C | be some function, and (4) κ ∈ N be some integer with κ ≤ k .On an intuitive level, moving in the tree from the bottom to the top, we keep track of thenumber of “completed” districts (type (ii) districts). Moreover, for each “unfinished” district(type (i) district), we store its color distribution, and how the vertices from the current bag aredistributed to the unfinished districts. In addition, for each unfinished district, we keep track ofwhich of its vertices from the current bag are already connected over vertices that have alreadybeen added to the district and edges that have already been introduced in the respective subtree.It is necessary to keep track of the connectivity of vertices from one district (stored in D ), as weneed this information to ensure that we make the district connected by adding further verticesto it. Moreover, we cannot directly infer it from B , as we cannot remember all vertices putin the districts so far. A formal description of the resulting dynamic program can be found inAppendix B.2Since a tree is of treewidth one, we have the following: Corollary 7.
FCD on trees can be solved in n O ( | C | ) time. + k In this section, we consider the number k of districts as our parameter for FCD on trees. Weshow that there is a simple XP-algorithm with respect to k for FCD on trees, which naturallyextends to an XP-algorithm with respect to fen + k , where fen is the number of edges that needto be deleted to make the given graph a tree: Proposition 7.
FCD can be solved in n O (fen + k ) time.Proof. Suppose that there is a solution ( V , . . . , V k ). The number of edges whose endpoints bothlie in the same district is at least P ki =1 ( | V i | −
1) = n − k . Since the input graph G = ( V, E ) hasat most n + fen − n + fen − − ( n − k ) = fen + k − E ′ ⊆ E of size at mostfen + k −
1, we verify whether (
V, E \ E ′ ) has k connected components each of which being ℓ -fair.Overall, it takes ( n + fen − fen + k − · n O (1) = n O (fen + k ) time to do so.Moreover, as the treewidth of a graph is upper-bounded in a function of its feedback edgenumber, we can conclude from Theorem 4 that FCD parameterized by fen + | C | is in XP. However,Proposition 7 raises the question whether there is an XP-algorithm with respect to tw + k . Weanswer this question negatively in the next subsection.15olor c color c ′ color c ′′ color c y color c y color c y color c x color c x color c x v ⋆ v ⋆ v v v v v v v v Figure 2: Example of the hardness reduction from Theorem 5 for the
Not-All-Equal 3-Sat instance X = { x , x , x } , Y = { y = { x , x , x } , y = { x , x , x } , y = { x , x , x }} . Thedistrict marked in red corresponds to the solution setting x to true and x and x to false. = = We now consider a third way to measure the distance of a graph from being a tree, that is, thenumber of vertices to delete to make it a tree (feedback vertex number fvn). As tw +1 ≤ fvn, fromTheorem 4 it follows that there exists an XP-algorithm for fvn + | C | . In this subsection, we provethat the feedback vertex number is a less powerful in context of this problem than the similarlydefined feedback edge number by showing that FCD is NP-hard even for fvn = 1 and k = 2.Notably, this also implies that there is no hope for an XP-algorithm for tw + k .For the NP-hardness proof, we reduce from the NP-hard Not-All-Equal 3-Sat problem [34]where the input is a set X of n boolean variables and a set Y of m clauses over X such that eachclause y ∈ Y contains three different literals, and the question is whether there exists a truthassignment to the variables in X such that for each clause y ∈ Y at least one literal is set to trueand at least one literal is set to false. Notably, given an assignment fulfilling these constraints, theassignment that assigns all variables in X the opposite truth value also fulfills the constraints.The general idea of the construction is that we introduce one vertex for each literal and thatthe two districts in the solution correspond to two opposite truth assignments of the variablesfrom X that are both solutions of the Not-All-Equal 3-Sat instance.
Construction
Given an instance ( X = { x , . . . , x n } , Y = { y , . . . , y m } ) of Not-All-Equal3-Sat , we construct an instance of
FCD as follows. We add a color c xi for each variable x i ∈ X and a color c yj for each clause y j ∈ Y . In addition, we add three colors c , c ′ , and c ′′ . Moreover,we set k = 2 and ℓ = 0. Let Z := 2 · n · m + 1.We start the construction of the vertex colored graph G = ( V, E ) by introducing two centralvertices v ⋆ and v ⋆ of color c . We will construct the instance in a way that these two vertices16eed to lie in different districts. For each central vertex v ⋆i , i ∈ { , } , we introduce 3 Z vertices ofcolor c ′ and 3 Z vertices of color c ′′ and connect them to v ⋆i .Subsequently, for each variable x i ∈ X , we introduce two literal vertices v i and v i of color c and connect both these vertices to the two central vertices. For each literal vertex ˜ v i ∈ { v i , v i } , weintroduce 3 Z − i vertices of color c xi and connect them to ˜ v i (these vertices make sure that the twoliteral vertices end up in different districts). For each clause y j ∈ Y in which x i occurs positively,we introduce Z + j vertices of color c yj and connect them to v i . For each clause y j ∈ Y in which x i occurs negatively, we introduce Z + j vertices of color c yj and connect them to v i (these verticesensure that there is no clause in which all three literal vertices corresponding to literals from theclause lie in the same district). See Figure 2 for a visualization of the construction.We start by showing the forward direction of the correctness of the construction. Lemma 3.
If the given
Not-All-Equal 3-Sat instance is a yes-instance, then the constructed
FCD instance is a yes-instance.Proof.
Let X ′ ⊆ X be the set of variables set to true in a solution to the given Not-All-Equal3-Sat instance. From this, we construct a solution ( V , V ) to the constructed FCD instance asfollows. We include v ⋆ and all leaves attached to it in V . Moreover, we include in V the followingvertices: v i and all leaves attached to it for all x i ∈ X ′ and v i and all leaves attached to it for all x i ∈ X \ X ′ . We include all other vertices in V .It is easy to verify that V and V are both connected. We will show that V is 0-fair. Bysymmetry, an analogous argument will show that V is 0-fair. First, observe that V containsexactly 3 Z vertices of color c ′ and 3 Z vertices of color c ′′ . We show that χ ˜ c ( V ) ≤ Z for everycolor ˜ c ∈ C . For color c , we have that χ c ( V ) ≤ χ c ( V ) = n + 2 < Z . For each variable x i ∈ X , as the two corresponding literal vertices are part of different districts, we have that χ c xi ( V ) = 3 Z − i < Z . For each clause y j ∈ Y , as X ′ is a solution, either one or two literalvertices corresponding to literals in y j and the attached leaves are part of V . Thus, the numberof vertices of color c yj in V is either Z + j or 2 Z + 2 j . As Z > m , it follows that χ c yj ( V ) < Z .Thus, both districts V and V are 0-fair.We show the backward direction of the correctness of the construction in Appendix B.3. Thegeneral idea is to show that the two central vertices need to be part of different districts, eachcontaining at most 3 Z vertices of the same color. Using this, it can be shown that each districtcan only contain one of the two literal vertices for each variable and only one or two literal verticesfrom each clause. Thereby, both districts in a solution induce a valid truth assignment: Lemma 4 ( ⋆ ) . If the constructed
FCD instance is a yes-instance, then the given
Not-All-Equal 3-Sat instance is a yes-instance.
Observing that { v ⋆ } is a feedback vertex set of the constructed graph, Theorem 5 followsdirectly from Lemma 3 and Lemma 4: Theorem 5.
FCD is NP-hard for fvn = 1 and k = 2 . From this, we can directly conclude that
FCD is also para-NP-hard with respect to the com-bined parameter treewidth plus number k of districts. Corollary 8.
FCD is NP-hard for tw = 2 and k = 2 . Motivated by our hardness results for graphs with constant treewidth, we now turn to the size vcof a minimum vertex cover, a parameter greater than the treewidth. In this section, we presenttwo parameterized algorithms for the vertex cover number, namely, an XP-algorithm for the singleparameter vc and an FPT-algorithm for the combined parameter vc + | C | . Unfortunately, we wereunable to settle whether FCD parameterized by vc is W[1]-hard or fixed-parameter tractable. In17ontrast, we develop an FPT-algorithm for the number of vertices with degree at least two (aparameter that is typically larger than vc).Both algorithms for the vertex cover number rely on the following lemma.
Lemma 5 ( ⋆ ) . Let S be a vertex cover of minimum size and V = ( V , . . . , V k ) a solution to an FCD instance on a graph G . There are at most vc districts in V that contain at least one vertexfrom S . Moreover, for every V i ∈ V with S ∩ V i = ∅ , there is a set J i ⊆ V i \ S of at most | S ∩ V i | − vertices such that ( S ∩ V i ) ∪ J i induces a connected subgraph. We first show that
FCD parameterized by vc is in XP. The intuitive idea is as follows. Wefirst guess how the vertex cover is partitioned into districts in the sought solution, which givespartial (not necessarily connected) districts. For every partial district, we then guess some verticesoutside the vertex cover to include such that the partial district becomes connected, the two mostfrequent colors, and their respective occurrences in the resulting district. The remaining problemcan be reduced to
Maximum Weighted Matching . Theorem 6 ( ⋆ ) . FCD is solvable in n O (vc) time.Proof (First Part). Suppose there is a solution V = ( V , . . . , V k ) to the given FCD instance. Let S be a vertex cover of minimum size and let I = V \ S . We will construct an instance of MaximumWeighted Matching for each choice of the following: • An integer k ′ ≤ vc. If ℓ = 0, then we consider only one choice for k ′ , namely k ′ = k . • A partition of S into k ′ non-empty subsets S , . . . , S k ′ . There are at most vc vc such partitions. • For every i ∈ [ k ′ ], a set J i ⊆ I of at most | S i | − G [ S i ∪ J i ] is connectedand J i ∩ J i ′ = ∅ for i = i ′ ∈ [ k ′ ]. We can assume that | J i | ≤ | S i | − J i is at most Q i ∈ [ k ′ ] n | S i |− ≤ n vc . • For every i ∈ [ k ′ ], a pair ( c i , c ′ i ) of colors, which have the largest numbers of occurrencesin V i among all colors. There are at most | C | choices for all pairs of colors. • For every i ∈ [ k ′ ], the numbers z c i , z c ′ i of occurrences of color c i and c ′ i , respectively, with z c i − ℓ ≤ z c ′ i ≤ z c i . Since z c i ≤ n and z c ′ i ≤ n , there are at most n choices.Since | C | ≤ n , we consider at most n O (vc) choices. Let I ′ = I \ S i ∈ [ k ′ ] J i . Now the questionis whether it is possible to partition the vertices V into k districts ( V , . . . , V k ) such that, for i ∈ [ k ′ , k ], V i consists of a single vertex from I ′ , and for i ∈ [ k ′ ], S i ∪ J i ⊆ V i , G [ V i ] is connected, χ c i ( V i ) = z c i , χ c ′ i ( V i ) = z c ′ i and χ c ( V i ) ≤ χ c ′ i ( V i ) for all c ∈ C \ { c i } . This can be decidedby reducing the problem to an instance of Maximum Weighted Matching as described inAppendix C.Since
Maximum Weighted Matching can be solved in polynomial time, the algorithm runsin n O (vc) .Recall that we have seen in Corollary 6 that FCD is even NP-hard and W[1]-hard with respectto | C | + k on trees with diameter four. In contrast to this, since a tree of diameter at most threehas a vertex cover of size at most two, by Theorem 6, the following holds. Corollary 9.
FCD is polynomial-time solvable on trees with diameter at most three.
Using a similar approach as for Theorem 6, we show that
FCD is fixed-parameter tractablewith respect to vc + | C | . The overall idea is the following: We guess the partition of the vertex coverinto the districts. We categorize vertices outside the vertex cover according to their neighborhoodand color. We formulate the resulting problem as an ILP whose number of variables only dependson vc + | C | . Subsequently we employ Lenstra’s FPT-algorithm for ILPs [27, 22] to obtain thefollowing: Theorem 7 ( ⋆ ) . FCD parameterized by vc + | C | is fixed-parameter tractable.
18t remains open whether
FCD is fixed-parameter tractable or W[1]-hard with respect to vc.However, we can prove fixed-parameter tractability with respect to the number of vertices withdegree at least two. Neglecting connected components consisting of only two vertices, the setof vertices with degree greater than one is always also a vertex cover; therefore, this parameterupper-bounds the vertex cover number in connected graphs on at least three vertices. The idea ofthe algorithm is to guess the partitioning of the degree-two vertices into the districts. Then, foreach of these districts, there exists a set of degree-one vertices where each of these vertices eitherbelongs to the district or needs to form its own district. We can reduce the distribution of degree-one vertices to solving
FCD on stars with a weighted center vertex as analyzed in Proposition 5.
Proposition 8 ( ⋆ ) . Let p be the number of vertices with degree at least two. FCD is solvable in O ( p p · k · n ) time. We initiated a thorough study of the NP-hard
Fair Connected Districting ( FCD ) problem.We considered
FCD on specific graph classes and analyzed the parameterized complexity of
FCD with a focus on the number of districts, the number of colors, and various graph parameters. Wehave shown that while
FCD can be solved on simple graph classes in polynomial time (mostlyusing approaches based on dynamic programming), on trees it is already NP-hard and W[1]-hardwith respect to the combined parameter number of colors plus number of districts. Nevertheless,for graph parameters such as the vertex cover number and the max leaf number, we were able todevelop XP-algorithms.As to challenges for future research, note that we left open whether
FCD is fixed-parametertractable or W[1]-hard with respect to the parameters vertex cover number and max leaf number.The former question is particularly intriguing because it is closely related to an open questionof Stoica et al. [36] on the parameterized complexity of
Fair Regrouping with respect to thenumber of districts.From a broader perspective, there are several natural extensions of
FCD . For instance, in real-world applications, as already suggested by Stoica et al. [36], there may exist a global lower andupper bound on the size of each district, or it is required that the district sizes are balanced. Whilequite some of our algorithmic results are still applicable with global upper and lower bounds (forinstance, our two algorithms for the vertex cover number) others do not translate (for instance,the algorithm for cliques). Moreover, we did not study the generalization of
FCD where eachvertex has an integer weight for each color (such a study has been done in the context of
Ger-rymandering by Cohen-Zemach et al. [11] and Ito et al. [21]). Weighted
FCD is motivated bythe following application scenarios: First, in some settings we might be restricted to put a certaingroup of agents always in the same district (those can be combined into one vertex). Second, ifeach vertex represents a voter and the colors represent alternatives, then voters might want togive points to different alternatives (such as done in the context of positional scoring rules).Lastly, one can modify the definition of
FCD . For instance, as done, among others, by Lewen-berg et al. [28] and Eiben et al. [13] in the context of
Gerrymandering and, among others, byLu et al. [29] and Fotakis and Tzamos [17] in the context of facility location problems, instead ofplacing agents on a social network, the agents may be placed in a metric space. The task is thento place k ballot boxes in the space where each agent is assigned to the closest ballot box. References [1] Aishwarya Agarwal, Edith Elkind, Jiarui Gan, and Alexandros A. Voudouris. Swap stabilityin Schelling games on graphs. In
Proceedings of the 24th AAAI Conference on ArtificialIntelligence (AAAI ’20) , pages 1758–1765. AAAI Press, 2020. 3192] Yoram Bachrach, Omer Lev, Yoad Lewenberg, and Yair Zick. Misrepresentation in districtvoting. In
Proceedings of the 25th International Joint Conference on Artificial Intelligence(IJCAI ’16) , pages 81–87. AAAI Press, 2016. 3[3] George Barmpalias, Richard Elwes, and Andy Lewis-Pye. Digital morphogenesis via schellingsegregation. In
Proceedings of the 55th IEEE Annual Symposium on Foundations of ComputerScience (FOCS ’14) , pages 156–165. IEEE Computer Society, 2014. 3[4] Matthias Bentert, Tomohiro Koana, and Rolf Niedermeier. The complexity of gerrymanderingover graphs: Paths and trees.
CoRR , abs/2102.08905, 2021. 3[5] Ren´e van Bevern, Robert Bredereck, Jiehua Chen, Vincent Froese, Rolf Niedermeier, andGerhard J. Woeginger. Network-based vertex dissolution.
SIAM J. Discrete Math. , 29(2):888–914, 2015. 3[6] Prateek Bhakta, Sarah Miracle, and Dana Randall. Clustering and mixing times for segrega-tion models on ̥
2. In
Proceedings of the 25th Annual ACM-SIAM Symposium on DiscreteAlgorithms (SODA ’14) , pages 327–340. SIAM, 2014. 3[7] Allan Borodin, Omer Lev, Nisarg Shah, and Tyrone Strangway. Big city vs. the great out-doors: Voter distribution and how it affects gerrymandering. In
Proceedings of the 27thInternational Joint Conference on Artificial Intelligence (IJCAI ’18) , pages 98–104. ijcai.org,2018. 3[8] Christina Brandt, Nicole Immorlica, Gautam Kamath, and Robert Kleinberg. An analysis ofone-dimensional Schelling segregation. In
Proceedings of the 44th Symposium on Theory ofComputing Conference (STOC ’12) , pages 789–804. ACM, 2012. 3[9] Brian Brubach, Aravind Srinivasan, and Shawn Zhao. Meddling metrics: the effects of mea-suring and constraining partisan gerrymandering on voter incentives. In
Proceedings of the21st ACM Conference on Economics and Computation (EC ’20) , pages 815–833. ACM, 2020.3[10] Janka Chleb´ıkov´a. Approximating the maximally balanced connected partition problem ingraphs.
Inf. Process. Lett. , 60(5):223–230, 1996. 2, 6[11] Amittai Cohen-Zemach, Yoad Lewenberg, and Jeffrey S. Rosenschein. Gerrymandering overgraphs. In
Proceedings of the 17th International Conference on Autonomous Agents andMultiAgent Systems (AAMAS ’18) , pages 274–282. IFAAMAS, 2018. 3, 19[12] Martin E. Dyer and Alan M. Frieze. On the complexity of partitioning graphs into connectedsubgraphs.
Discrete Appl. Math. , 10(2):139–153, 1985. 2, 6[13] Eduard Eiben, Fedor V. Fomin, Fahad Panolan, and Kirill Simonov. Manipulating districtsto win elections: Fine-grained complexity. In
Proceedings of the 34th AAAI Conference onArtificial Intelligence (AAAI ’20) , pages 1902–1909. AAAI Press, 2020. 3, 19[14] Edith Elkind, Jiarui Gan, Ayumi Igarashi, Warut Suksompong, and Alexandros A. Voudouris.Schelling games on graphs. In
Proceedings of the 28th International Joint Conference onArtificial Intelligence (IJCAI ’19) , pages 266–272. ijcai.org, 2019. 3[15] David Eppstein. Metric dimension parameterized by max leaf number.
J. Graph AlgorithmsAppl. , 19(1):313–323, 2015. 11[16] Robert S Erikson. Malapportionment, gerrymandering, and party fortunes in congressionalelections.
Am. Political Sci. Rev. , 66(4):1234–1245, 1972. 3[17] Dimitris Fotakis and Christos Tzamos. On the power of deterministic mechanisms for facilitylocation games.
ACM Trans. Econ. Comput. , 2(4):15:1–15:37, 2014. 192018] Sushmita Gupta, Pallavi Jain, Fahad Panolan, Sanjukta Roy, and Saket Saurabh. Gerry-mandering on graphs: Computational complexity and parameterized algorithms.
CoRR ,abs/2102.09889, 2021. 3[19] Nicole Immorlica, Robert Kleinberg, Brendan Lucier, and Morteza Zadomighaddam. Ex-ponential segregation in a two-dimensional schelling model with tolerant individuals. In
Proceedings of the 28th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA ’17) ,pages 984–993. SIAM, 2017. 3[20] Samuel Issacharoff. Gerrymandering and political cartels.
Harv. Law Rev. , 116:593–648, 2002.3[21] Takehiro Ito, Naoyuki Kamiyama, Yusuke Kobayashi, and Yoshio Okamoto. Algorithmsfor gerrymandering over graphs. In
Proceedings of the 18th International Conference onAutonomous Agents and MultiAgent Systems (AAMAS ’19) , pages 1413–1421. IFAAMAS,2019. 3, 19[22] Ravi Kannan. Minkowski’s convex body theorem and integer programming.
Math. Oper.Res. , 12(3):415–440, 1987. 18, 30[23] Daniel J. Kleitman and Douglas B. West. Spanning trees with many leaves.
SIAM J. DiscreteMath. , 4(1):99–106, 1991. 11[24] Ton Kloks.
Treewidth, Computations and Approximations , volume 842 of
Lecture Notes inComputer Science . Springer, 1994. 14[25] Zeph Landau and Francis Edward Su. Fair division and redistricting.
AMS Special Sessionson The Mathematics of Decisions, Elections, and Games , pages 17–36, 2013. 3[26] Zeph Landau, Oneil Reid, and Ilona Yershov. A fair division solution to the problem ofredistricting.
Soc. Choice Welf. , 32(3):479–492, 2009. 3[27] Hendrik W. Lenstra. Integer programming with a fixed number of variables.
Math. Oper.Res. , 8:538–548, 1983. 18, 30[28] Yoad Lewenberg, Omer Lev, and Jeffrey S. Rosenschein. Divide and conquer: Using geo-graphic manipulation to win district-based elections. In
Proceedings of the 16th Conferenceon Autonomous Agents and Multiagent Systems (AAMAS ’17) , pages 624–632. ACM, 2017.3, 19[29] Pinyan Lu, Xiaorui Sun, Yajun Wang, and Zeyuan Allen Zhu. Asymptotically optimalstrategy-proof mechanisms for two-facility games. In
Proceedings 11th ACM Conference onElectronic Commerce (EC ’10) , pages 315–324. ACM, 2010. 19[30] David Lublin.
The Paradox of Representation: Racial Gerrymandering and Minority Interestsin Congress . Princeton University Press, 1999. 3[31] D´aniel Marx. On the optimality of planar and geometric approximation schemes. In
Proceed-ings of the 48th Annual IEEE Symposium on Foundations of Computer Science (FOCS ’07) ,pages 338–348, 2007. 12[32] Clemens Puppe and Attila Tasn´adi. A computational approach to unbiased districting.
Math.Comput. Model. , 48(9-10):1455–1460, 2008. 3[33] Clemens Puppe and Attila Tasn´adi. Optimal redistricting under geographical constraints:Why “pack and crack” does not work.
Econ. Lett. , 105(1):93–96, 2009. 3[34] Thomas J. Schaefer. The complexity of satisfiability problems. In
Proceedings of the 10thAnnual ACM Symposium on Theory of Computing (STOC ’78) , pages 216–226. ACM, 1978.16 2135] Thomas C Schelling. Models of segregation.
Am. Econ. Rev. , 59(2):488–493, 1969. 3[36] Ana-Andreea Stoica, Abhijnan Chakraborty, Palash Dey, and Krishna P. Gummadi. Mini-mizing margin of victory for fair political and educational districting. In
Proceedings of the19th International Conference on Autonomous Agents and Multiagent Systems (AAMAS ’20) ,pages 1305–1313. IFAAMAS, 2020. 1, 2, 3, 4, 6, 7, 1922
Missing Proofs from Section 3
Proposition 2 ( ⋆ ) . FCD on a graph G is NP-hard, even if ℓ = 0 , | C | = 2 , k = 2 , and G isbipartite.Proof. We present a polynomial-time Turing reduction from
Perfectly Balanced ConnectedPartition to FCD . To this end, we assume that we have access to an oracle for
FCD . Construction.
Given an instance ( G = ( V, E )) of
Perfectly Balanced Connected Parti-tion with n := | V | , for each pair of vertices ( v, v ′ ) ∈ V , we construct an instance of FCD : We set C = { c , c } , k = 2, and ℓ = 0. We color all vertices of the given graph G in color c . Moreover,we modify G by introducing n new vertices of color c . We connect half of these vertices to v andthe other half to v ′ . Subsequently, we query our oracle for FCD on the resulting instance andreturn yes if the oracle returns yes; otherwise, we continue with the next pair of vertices. Afterthe oracle rejected all instances, we return no.We now prove the correctness of the reduction by showing that there exists a pair of vertices( v, v ′ ) ∈ V for which the constructed FCD instance is a yes-instance if and only if the given
Perfectly Balanced Connected Partition is a yes-instance.Let ( V , V ) be a solution to the FCD instance constructed for some pair of vertices ( v, v ′ ) ∈ V .As ℓ = 0 and we enforce that both V and V need to be non-empty, it needs to hold that bothdistricts contain vertices of both colors. Moreover, as both V and V are connected, all verticesof color c adjacent to v need to be in the same district as v (and similarly for v ′ ). Thus, v and v ′ need to be in different districts, each consisting of n vertices of color c and n vertices of color c . Thereby, after removing all vertices of color c , ( V , V ) is a solution to the given PerfectlyBalanced Connected Partition instance.To prove the reverse direction, let ( V , V ) be a solution to the given Perfectly BalancedConnected Partition instance. Let v ∈ V be some vertex from V and v ′ ∈ V be some vertexfrom V . Then, the FCD instance constructed for ( v, v ′ ) is a yes-instance, as it is possible to addthe n vertices of color c attached to v to V and the n vertices of color c attached to v ′ to V toarrive at a solution to the FCD instance constructed for pair ( v, v ′ ) ∈ V . Proposition 3 ( ⋆ ) . Let G be a class of graphs such that FCD is polynomial-time solvable onany graph G ∈ G . Then, FCD is polynomial-time solvable on any graph from G ′ , where G ′ is theclass of graphs obtained by taking disjoint unions of graphs from G .Proof. Let G ′ ∈ G ′ and let G , . . . , G p ∈ G be the connected components of G ′ . Clearly, everydistrict is contained in the vertex set of G i for some i ∈ [ p ]. We solve the problem using a simplesubset-sum like dynamic program. To this end, we introduce a table T [ i, j ] for i ∈ [ p ] and j ∈ [ k ].An entry T [ i, j ] is set to true if one can partition the vertices of G , . . . , G i into j connected ℓ -fairdistricts. We also use a table H where H [ i, j ] for i ∈ [ p ] and j ∈ [ k ] is true if the vertex set of G i can be partitioned into j connected ℓ -fair districts. Note that H can be computed in polynomialtime by our initial assumption.To initialize T , we set T [1 , j ] to H [1 , j ] for all j ∈ [ k ]. Subsequently, for increasing i >
1, weupdate T as follows: T [ i, j ] = _ j ′ ,j ′′ ∈ [ j ] j ′ + j ′′ = j T [ i − , j ′ ] ∧ H [ i, j ′′ ] . In the end, we return T [ p, k ]. This algorithm runs in O ( p · k ) = O ( n ) time (aside from thecomputation of H ). B Missing Proofs from Section 6
B.1 Missing Proofs from Subsection 6.1
We start by showing some bounds on the total number of vertices from each color.23 bservation 1 ( ⋆ ) . For each i, j ∈ [ t ] , it holds that χ d i,j ( V ) = nn − Z − nf ( i, j ) and χ b i,j ( V ) = nn − Z − ng ( i, j ) . For all i, j ∈ [ k ] , it holds that χ c i,j ( V ) ≤ Z .Proof. For each i, j ∈ [ t ], vertices of color d i,j occur in 2 n different stars, that is, in all starscorresponding to tiles from S i,j and S i − ,j . As the first entries of all tiles from S i,j and of alltiles from S i − ,j sum up to X , it follows that χ d i,j ( V ) = nn − Z − nf ( i, j ). The same reasoningapplies for all colors b i,j proving that χ b i,j ( V ) = nn − Z − ng ( i, j ). Lastly, for some i, j ∈ [ t ],vertices of color c i,j appear only in stars corresponding to tiles from S i,j , each of them containingat most Z n − + W · m such vertices. Thus, the number of vertices of color c i,j is upper-boundedby n · ( Z n − + W · m ). As W · m = n − Z , this is smaller than Z from which χ c i,j ( V ) ≤ Z follows.It remains to prove the correctness of the backward direction of the construction (Lemma 2).To do so, we start by observing that the vertices from one star need to be part of the same district. Observation 2.
For each tile ( x, y ) ∈ S , all vertices from the corresponding star need to be partof the same district in a solution to the constructed FCD instance.Proof.
As we set ℓ = 0 in the constructed FCD instance, there cannot exist a district containingjust a single vertex. Thus, all vertices from a star need to belong to the same district as the centerof the star.Using this observation, we make some more involved arguments dealing with the possiblenumber of vertices of a color in the center district in a solution. In the following, let V center denotethe center district in a solution to the constructed FCD instance.
Lemma 6.
For each i, j ∈ [ t ] , if χ d i,j ( V center ) ≥ Z , then it holds that χ d i,j ( V center ) = ( nn − Z − nf ( i, j )) − a ( Z n − − f ( i, j )) + W q for some a ∈ { , , } and q ∈ [ − m, m ] .Proof. Let us consider some i, j ∈ [ t ]. By Observation 2, for every star T i,jx,y , all the verticesfrom T i,jx,y are in V center or no vertex from T i,jx,y is in V center .By construction, every star with some vertex of color d i,j contains Z n − + W · x − f ( i, j )vertices of this color for some x ∈ [ − m, m ]. So if more than two stars containing a vertex of color d i,j are not included in V center , then the number of vertices of color d i,j in the center district is atmost Z − Z n − + 3 mW , which by the definition of Z is less than Z .Thus, we can assume that the number a of stars with some vertex of color d i,j that are notpart of the center district is at most two. Since there are in total nn − Z − nf ( i, j ) vertices of color d i,j by Observation 2, the lemma holds.Analogously, we can prove similar bounds for the number of vertices of color b i,j for some i, j ∈ [ t ] in the center district. Lemma 7.
For each i, j ∈ [ t ] , if χ b i,j ( V center ) ≥ Z , then it holds that χ b i,j ( V center ) = ( nn − Z − ng ( i, j )) − a ( Z n − − g ( i, j )) + W v for some a ∈ { , , } and v ∈ [ − m, m ] . Using these two lemmas, we can now prove that there are at most Z vertices of the same colorin the center district in a solution to the constructed FCD instance.
Lemma 8.
For every color q , χ q ( V center ) ≤ Z .Proof. We claim that for two distinct colors q, q ′ with χ q ( V center ) , χ q ′ ( V center ) > Z , it holds that χ q ( V center ) = χ q ′ ( V center ). The statement of the lemma directly follows from the claim, as V center needs to be 0-fair.Assume for a contradiction that χ q ( V center ) = χ q ′ ( V center ) > Z for some colors q = q ′ Sincethere are at most Z vertices of color c, c ′ , c ⋆ , c i,j for i, j ∈ [ t ], q and q ′ are among the colors b i,j and24 i,j for i, j ∈ [ t ]. By Lemmas 6 and 7 as it holds that χ q ( V center ) = χ q ′ ( V center ), from this it followthat 2 nh ( i, j ) + a (cid:0) Z n − − h ( i, j ) (cid:1) + W v = 2 nh ′ ( i ′ , j ′ ) + a ′ (cid:0) Z n − − h ′ ( i ′ , j ′ ) (cid:1) + W v ′ , where a, a ′ ∈{ , , } , v, v ′ ∈ [ − m, m ], h ( i, j ) ∈ { f ( i, j ) , g ( i, j ) } , h ′ ( i ′ , j ′ ) ∈ { f ( i ′ , j ′ ) , g ( i ′ , j ′ ) } . Rewritingyields that ( a ′ − a ) Z n − = 2 n (cid:0) h ( i, j ) − h ′ ( i ′ , j ′ ) (cid:1) + W ( v − v ′ ) − ah ( i, j )+ a ′ h ′ ( i ′ , j ′ ). Since the righthand side is smaller than Z n − we have a = a ′ , and thus 0 = (2 n − a ) · ( h ( i, j ) − h ′ ( i ′ , j ′ ))+ W ( v − v ′ ).Moreover, as W > n (2 t + 2 t ) taking modulo W yields (2 n − a ) · h ( i, j ) ≡ (2 n − a ) · h ′ ( i ′ , j ′ ), andthus h ( i, j ) = h ′ ( i ′ , j ′ ). However, this implies that q = q ′ , which is a contradiction.Using Lemma 8, we can prove that each solution to the constructed FCD instance induces aselection of one tile from each tile set in the given
Grid Tiling instance:
Lemma 9.
For each i, j ∈ [ t ] , exactly one star T i,jx,y for some ( x, y ) ∈ S i,j is not part of V center .Proof. Lemma 6 and Lemma 8 imply that for each i, j ∈ [ t ] at least two stars containing verticesof color d i,j are not part of V center . As each star T i,jx,y contains vertices of colors d i,j and d i +1 ,j and as there exist t non-center districts in the end, this means that for each i, j ∈ [ t ] exactly twostars containing vertices of this color are not part of V center .For the sake of contradiction, let us assume that there exists i, j ∈ [ t ] such that two starscorresponding to tiles from S i,j are not part of V center . This implies by our previous observationthat all other stars containing vertices of color d i +1 ,j need to belong to V center . However, in thiscase, at most Zn − − W · d i +1 ,j are not part of V center . By Observation 1, thisimplies that the number of vertices of color d i +1 ,j in V center is at least Z + 2 W − nf ( i, j ). As W > n ( t + t ), this number is greater than Z , contradicting Lemma 8.We are now ready to prove the correctness of the backward direction of the construction. Lemma 2 ( ⋆ ) . If the constructed
FCD instance is a yes-instance, then the given
Grid Tiling instance is a yes-instance.Proof.
Let V be a solution to the constructed FCD instance and let V center ∈ V be the districtcontaining v center . Lemma 9 implies that for each i, j ∈ [ t ] exactly one star corresponding to a tilefrom S i,j is not part of V center . Let S := { ( x i,j , y i,j ) ∈ S i,j | i, j ∈ [ t ] ∧ T i,jx,y is not part of V center } be a set of all tiles corresponding to excluded stars (one for each i, j ∈ [ t ]). We claim that S is avalid solution to the given Grid Tiling instance.For the sake of contradiction, assume that this is not the case. That is, there either (a) exist i, j ∈ [ t ] such that x i,j = x i − ,j or (b) exist i ′ , j ′ ∈ [ t ] such that y i ′ ,j ′ = y i ′ − ,j ′ . Let us start byassuming that (a) is the case. Note that it is possible to assume without loss of generality that x i,j < x i − ,j , as from the fact that there exists some x i,j = x i − ,j it follows that there also existssome ˜ i ∈ [ t ] such that x ˜ i,j < x ˜ i − ,j . The only stars containing vertices of color d i,j that are not partof V center are the star corresponding to ( x i,j , y i,j ), which contains Z n − + W · x i,j − f ( i, j ) vertices ofthis color, and the star corresponding to ( x i − ,j , y i − ,j ), which contains Z n − − W · x i − ,j − f ( i, j )vertices of this color. This implies that at most Zn − + W · ( x i,j − x i − ,j ) − f ( i, j ) ≤ Zn − − W − f ( i, j )vertices of this color are not part of V center , where the inequality holds by our assumption that x i,j < x i − ,j . Combining this with Observation 1, it follows that the number of vertices of color d i,j in V center is at least Z + W − n − f ( i, j ). By the definition of W , this is strictly greaterthan Z . Applying Lemma 8, we reach a contradiction.The same argument can also be applied if (b) holds, which proves that S is a solution to thegiven Grid Tiling instance.
B.2 Missing Proofs from Subsection 6.2
Theorem 4 ( ⋆ ) . FCD can be solved in O ( n O (tw ·| C | ) ) time. roof (Second Part). It remains to formally describe the dynamic program we use. For allcombinations of the variables B , D , ζ , and κ (as defined in the main body), we compute A x ( B , D , ζ, κ ) ∈ { , } such that A x ( B , D , ζ, κ ) = 1 if and only if there is a partition of thevertices U x into exactly |D| + κ subsets ( W , . . . , W |D| + κ ) with the following properties: • For every i ∈ [ |D| + κ ], W i is connected in G x [ W i ]. • Exactly κ subsets from ( W , . . . , W |D| + κ ) are disjoint from B x . Moreover, all of them are ℓ -fair. • For every subset W i intersecting B x , it holds that W i ∩ B x ∈ D . • For every B ∈ B , it holds that ζ ( B ) = P i ∈ [ |D| + κ ] ,W i ∩ B = ∅ χ ( W i ).From the subsets in the partitioning ( W , . . . , W |D| + κ ), κ are ℓ -fair connected districts of type (ii)with respect to x . The other |D| subsets are partly contained in B x and restricted to B x form thepartition D describing the intersection of B x with the connected components of G x [ V i ] for districts V i of type (i).Observe that a given instance of FCD is a yes-instance if and only if there exists a partition B r of B r for the root r of T and a function ζ r such that ζ r ( B ) is fair for all B ∈ B r and A r ( B r , B r , ζ, k − |B r | ) = 1.We compute A x ( B , D , ζ, κ ) by traversing the nodes V T of the tree T from bottom to top.Depending on the type of the current node x ∈ V T , we apply one of the following five cases. Leaf node x . For a leaf node x with B x = { v } , we have A x ( { v } , { v } , ζ,
0) = 1 if and only if ζ ( { v } ) = χ ( { v } ). Introduce vertex v node x . Note that v is isolated in G x . Thus, A x ( B , D , ζ, κ ) = 0 if { v } isnot contained in D . Otherwise we have A x ( B , D , ζ, κ ) = A y ( B ′ , D ′ , ζ ′ , κ ) , where B ′ = ( B \ { B } ) ∪ { B \ { v }} for B ∈ B with v ∈ B ( B ′ = B \ { B } if B = { v } ), D ′ = D \ ,and ζ ′ ( B ′ ) = ζ ( B ) − χ ( { v } ) if B ′ = B \ { v } (we assume that ζ ′ ( ∅ ) is a zero vector here) and ζ ′ ( B ′ ) = ζ ( B ′ ) otherwise. Introduce edge { u, v } node x . If u and v belong to distinct subsets of B , then we clearly have A x ( B , D , ζ, κ ) = A y ( B , D , ζ, κ ). We also have the same recurrence if u and v belong to the samesubset of D . Otherwise, we have A x ( B , D , ζ, κ ) = A y ( B , D , ζ, κ ) ∨ _ D ′ A y ( B , D ′ , ζ, κ ) , where W is over all partitions D ′ of B y from which D can be obtained by removing D u , D v ∈ D ′ with u ∈ D u and v ∈ D v from D ′ and adding D u ∪ D v to D ′ . Forget v node x . We have two cases. In the first case, the district V i ∈ V to which v belongsdoes not intersect B x . Then { v } should be added to both B and D . Let us define A x ( B , D , ζ, κ ) = _ ζ ′ ( A y ( B ∪ , D ∪ , ζ ′ , κ − , where W is over all functions ζ ′ such that ζ ′ ( B ) = ζ ( B ) for all B ∈ B and MOV( ζ ′ ( { v } )) ≤ ℓ .Note that we also need to decrease κ , as V i is an additional district of type (ii) for the node x . Inthe other case, the district in which v is contained intersects B x . In this case, it holds that A x ( B , D , ζ, κ ) = _ B ′ , D ′ A y ( B ′ , D ′ , ζ, κ ) , W is over all partitions B ′ and D ′ of B y such that B ′ = ( B \ { B } ) ∪ ( B ∪ { v } ) and D ′ =( D\{ D } ) ∪ ( D ∪{ v } ) for some B ∈ B and D ∈ D . All in all, we have A x ( B , D , ζ, κ ) = A x ( B , D , ζ, κ ) ∨ A x ( B , D , ζ, κ ). Join node x . Note that two vertices u, w ∈ D for some D ∈ D can reach each other in G x viaconnections in G y and G z . So we have A x ( B , D , ζ, κ ) = _ D y , D z ,ζ y ,ζ z ,κ y ,κ z A y ( B , D y , ζ y , κ y ) ∧ A z ( B , D z , ζ z , κ z ) . Here, W is over all D y , D z , ζ y , ζ z , κ y , κ z such that all the following hold: • D are the connected components of the graph whose vertex set is B x and edge set is {{ u, w } | ( ∃ D y ∈ D y : u, w ∈ D y ) ∨ ( ∃ D z ∈ D z : u, w ∈ D z ) } . • ζ y ( B ) + ζ z ( B ) = ζ ( B ) − χ ( B ) for every B ∈ B . • κ y + κ z = κ .Now we examine the running time. Note that there are tw O (tw) partitions of B x for every node x of T . Since ζ ( B ) ∈ { , . . . , n } | C | for every B ∈ B x and x ∈ V T , there are at most n O (tw ·| C | ) states for ζ . It is easy to see that the computation of all values takes n O (tw ·| C | ) time. B.3 Missing Proofs from Subsection 6.4
It remains to prove the correctness of the backward direction of the reduction described in Sub-section 6.4 (Lemma 4). For this, note that the
FCD instance is constructed such that the twocentral vertices need to end up in different districts and for each x i ∈ X , the two literal vertices v i and v i need to end up in different districts. Thus, the two districts correspond to two inversetruth assignments. Subsequently, we will prove that there is no clause in which all correspondingvertices are in the same district. This will show that the two truth assignments induced by thetwo districts are a solution to the given Not-All-Equal 3-Sat instance.We start by observing that all leaves need to lie in the same district as the vertex they areattached to.
Observation 3.
In a solution to the constructed
FCD instance, all leaves attached to a vertex v ∈ V need to lie in the same district as v .Proof. If a leaf is not in the same district as its neighbor, then the leaf needs to form its owndistrict. However, this is not possible, as we require each district to be 0-fair.Next, we show that indeed the two central vertices v ⋆ and v ⋆ always lie in different districts. Observation 4.
The two central vertices v ⋆ and v ⋆ cannot belong to the same district in anysolution to the constructed FCD instance.Proof.
Assume that v ⋆ and v ⋆ belong to the same district. By Observation 3, the other district V ′ needs to consist of a single literal vertex v i or v i for some x i ∈ X and all leaves attached to it.The most frequent color appearing in V ′ is c xi which occurs 3 Z − i > m times. The second mostfrequent color is either c yj for some j ∈ [ m ] occurring Z + j < m times or c occurring once. Thus,the district cannot be 0-fair.To prove that, for each variable, the two corresponding literal vertices need to be part ofdifferent districts and that not all literal vertices corresponding to literals from a clause can lie inthe same district, we prove that neither district can contain more than 3 Z vertices of the samecolor. Lemma 10.
For any solution to the constructed
FCD instance, neither district contains morethan Z vertices of the same color. roof. Assume that there exists a solution with a district V ′ containing more than 3 Z vertices ofthe same color. Since V ′ is 0-fair, there are two colors q and q ′ with χ q ( V ′ ) = χ q ′ ( V ′ ) > Z . Wehave χ c ( V ′ ) ≤ χ ( V ) = n + 2 < Z and χ c ′ ( V ′ ) = χ c ′′ ( V ′ ) = 3 Z by Observation 4. Thus, we have q, q ′ ∈ { c xi | x i ∈ X } ∪ { c yj | y j ∈ Y } .For x i ∈ X , there are two literal vertices each of which have 3 Z − i leaves of color c xi attached toit. For y j ∈ Y , there are three literal vertices each of which have Z + j leaves of color c yj attachedto it. It follows from Observation 3 that χ c xi ( V ′ ) ∈ { , Z − i, Z − i } for each x i ∈ X and that χ c yj ( V ′ ) ∈ { , Z + j, Z + 2 j, Z + 3 j } for each y j ∈ Y . Since i ≤ n , j ≤ m , Z = 2 · n · m + 1, and χ q ( V ′ ) = χ q ′ ( V ′ ) for q, q ′ ∈ { c xi | x i ∈ X } ∪ { c yj | y j ∈ Y } , we have χ q ( V ′ ) = χ q ′ ( V ′ ) = 0, whichcontradicts χ q ( V ′ ) = χ q ′ ( V ′ ) > Z .Recalling that 3 Z − i vertices of color c xi are attached to each literal vertex corresponding to x i ∈ X and that 6 Z − i > Z , the next observation directly follows from the previous lemma andObservation 3. Observation 5.
Let ( V , V ) be a solution of the constructed FCD instance. Then, for each x i ∈ X , exactly one of the two corresponding literal vertices v i and v i is part of V and the otheris part of V . We are now ready to prove the backward direction of the correctness of our construction.
Lemma 4 ( ⋆ ) . If the constructed
FCD instance is a yes-instance, then the given
Not-All-Equal 3-Sat instance is a yes-instance.Proof.
Let ( V , V ) be a solution to the constructed FCD instance. From Observation 5, it followsthat for each x i ∈ X , exactly one of v i and v i is part of V . Let ϕ be the truth assignment inducedby V , i.e., ϕ sets x i to true if v i ∈ V and x i to false if v i ∈ V . We claim that ϕ is a solution to thegiven Not-All-Equal 3-Sat instance. Firstly, for the sake of contradiction, assume that thereexists a clause y j ∈ C containing only literals that are satisfied by ϕ . However, by Observation 3,this implies that all vertices of color c yj are part of V , contradicting Lemma 10 as there exist3 Z + 3 j such vertices. Secondly, for the sake of contradiction, assume that y j contains no literalsatisfied by ϕ . However, by Observation 3, this implies that all vertices of color c yj are part of V ,contradicting again Lemma 10. Consequently, ϕ is a solution. C Missing Proofs from Section 7
Lemma 5 ( ⋆ ) . Let S be a vertex cover of minimum size and V = ( V , . . . , V k ) a solution to an FCD instance on a graph G . There are at most vc districts in V that contain at least one vertexfrom S . Moreover, for every V i ∈ V with S ∩ V i = ∅ , there is a set J i ⊆ V i \ S of at most | S ∩ V i | − vertices such that ( S ∩ V i ) ∪ J i induces a connected subgraph.Proof. As each vertex is only contained in one district, the first part of the lemma follows from thedefinition of vc. To prove the second part, fix some V i ∈ V . Obviously, G [ S ∩ V i ] can only consistof at most | S ∩ V i | connected components. We now want to decrease the number of connectedcomponents by adding vertices from V i \ S . As G [ V i \ S ] is an independent set, if it is possible toconnect any two components from G [ S ∩ V i ] using vertices from V i \ S , then this can be done byadding only a single vertex. Moreover, as G [ V i ] is connected, such a vertex v is guaranteed to exist.We add v to J i . Using this argument repeatedly, we can construct a set J i such that G [( S ∩ V i ) ∪ J i ]is connected. As each vertex from J i decreases the number of connected components by one, itneeds to hold that | J i | ≤ | S ∩ V i | − Theorem 6 ( ⋆ ) . FCD is solvable in n O (vc) time.Proof (Second Part). Recall that we want to decide whether for a given combination it is possibleto partition the vertices V into k districts ( V , . . . , V k ) such that, for i ∈ [ k ′ , k ], V i consists of a singlevertex from I ′ , and for i ∈ [ k ′ ], S i ∪ J i ⊆ V i , G [ V i ] is connected, χ c i ( V i ) = z c i , χ c ′ i ( V i ) = z c ′ i and28 c ( V i ) ≤ χ c ′ i ( V i ) for all c ∈ C \ { c i } . First, we reject the current combination, if χ c i ( S i ∪ J i ) > z c i or χ c ′ i ( S i ∪ J i ) > z c ′ i or χ c ( S i ∪ J i ) > z c ′ i for one c ∈ C \ { c i } . To decide whether it is possibleto distribute the vertices I ′ to construct such a partition, we reduce to Maximum WeightedMatching , where given a graph G ′ = ( V, E ), a weight function w : E N , and an integer t , thequestion is whether there exists a matching containing edges of summed weight at least t .We construct a bipartite graph G ′ and the weight function w as follows. The left bipartitionof G ′ consists of all vertices v ∈ I ′ . For every i ∈ [ k ′ ], we add the following vertices to the rightbipartition: • For each color c ∈ { c i , c ′ i } , we add z c − χ c ( S i ∪ J i ) vertices (call them A ) and connect themvia an edge of weight two to all vertices v ∈ I ′ of color c (in G ) which have at least oneneighbor in S i in G . • For each color c ∈ C \ { c i , c ′ i } , we add z c ′ i − χ c ( S i ∪ J i ) vertices and connect them via anedge of weight one to all vertices v ∈ I ′ of color c (in G ) which have at least one neighbor in S i in G .We then add the set A ′ of k − k ′ vertices to the right bipartition and connect them via an edge ofweight two to all vertices of I ′ . Lastly, we set t := | I ′ | +( k − k ′ )+ P i ∈ [ k ′ ] P c ∈{ c i ,c ′ i } (cid:0) z c − χ c ( S i ∪ J i ) (cid:1) .If the constructed Maximum Weighted Matching instance is a yes-instance, we return yes;otherwise, we continue with the next combination. Note that every matching M of weight at least t in G ′ matches all vertices from the left bipartition and all vertices from A and A ′ in the rightbipartition. This follows from the fact that overall ( k − k ′ ) + P i ∈ [ k ′ ] P c ∈{ c i ,c ′ i } (cid:0) z c − χ c ( S i ∪ J i ) (cid:1) edges of weight two exists and that the left bipartition contains | I ′ | vertices. From M , we canconstruct a solution of the given FCD instance by putting each vertex v ∈ I ′ into the districtcorresponding to the vertex v is matched to in M . Moreover, for all i ∈ [ k ′ ], we add S i ∪ J i to V i .As all vertices from I ′ and all vertices from A ′ are matched in M , the vertices are partitioned intoexactly k non-empty district. Moreover, as all vertices from A are matched, for i ∈ [ k ′ ], it holdsthat χ c i = z c i and χ c ′ i = z c ′ i and thus that the resulting districts are ℓ -fair. Theorem 7 ( ⋆ ) . FCD parameterized by vc + | C | is fixed-parameter tractable.Proof. Suppose there is a solution V = ( V , . . . , V k ). Let S be a vertex cover of minimum size.Then I = V \ S is an independent set. Let k ′ be the number of districts in V that contain at leastone vertex of S . By Lemma 5, we have k ′ ≤ vc. Assume without loss of generality that exactlyfor every i ∈ [ k ′ ], S i = ∅ where S i = S ∩ V i . Then, for every i ∈ { k ′ + 1 , . . . , k } , we have V i = { v } where v is some vertex from I .We say that a vertex v ∈ I has type ( c, X ) for c ∈ C and X ⊆ S if the color of v is c and itsneighborhood is X . Let T denote the set of all types (note that |T | = 2 vc · | C | ). For type T ∈ T ,let n T be the number of vertices of type T , and for type T with n T > v T ∈ I be an arbitraryvertex of type T . Our algorithm will construct an ILP instance for each choice of the following: • An integer k ′ ≤ vc. If ℓ = 0, then we consider only one choice for k ′ , namely k ′ = k . • A partition of S into non-empty subsets S , . . . , S k ′ . There are at most vc vc such partitions. • For every i ∈ [ k ′ ], a set T i of at most | S i | − G [ S i ∪ J i ] is connected for J i = { v T | T ∈ T i } . The guesses need to satisfy that |{ i | T ∈ T i }| ≤ n T for each T ∈ T .Note that we can assume that |T i | ≤ | S i | − vc · | C | types, the number of choices for all T i is at most Q i ∈ [ k ′ ] (2 vc · | C | ) | S i |− ≤ vc · | C | vc . • For every i ∈ [ k ′ ], a pair ( c i , c ′ i ) of colors, which have the largest numbers of occurrences in V i among all colors with χ c i ( V i ) ≥ χ c ′ i ( V i ). There are at most | C | choices for all pairs ofcolors.To decide on the distribution of the vertices from I , we now construct an ILP. For the ILPformulation, we introduce an integer variable x i,T for each i ∈ [ k ′ ] and T ∈ T . The variable x i,T T that we put in V i . Clearly, there are at most n T vertices for each type T ∈ T that belong to one of V , . . . V k ′ : X i ∈ [ k ′ ] x i,T ≤ n T . Then for every i ∈ [ k ′ ] and T ∈ T i , at least one vertex of type T is included in T i : x i,T ≥ . Further for every i ∈ [ k ′ ], only vertices from I that are adjacent to a vertex from S i can be partof V i . Thus, for all types T = ( c, X ) ∈ T with X ∩ S i = ∅ it holds that: x i,T = 0 . Moreover, there are exactly k − k ′ vertices which are contained in none of V , . . . , V k ′ : X T ∈T n T − X i ∈ [ k ′ ] x i,T = k − k ′ . For i ∈ [ k ′ ] and c ∈ C , let n i,c be the number of vertices of color c in V i : n i,c = χ c ( S i ) + X T ∈T ,X ∩ S i = ∅ with T =( c,X ) x i,T . Finally for every i ∈ [ k ′ ], the following two constraints will ensure that the district V i is ℓ -fair. n i,c ′ i ≤ n i,c i ≤ n i,c ′ i + ℓ, and n i,c ′ i ≥ n i,c for all c ∈ C \ { c i } . For the running time, observe that we construct at most 2 O (vc ) · | C | vc ILP instances. Since eachILP instance uses at most vc · vc · | C | variables, it can be solved in f (vc + | C | ) · n O (1) time for somecomputable function f due to a result of Lenstra [27, 22]. Proposition 8 ( ⋆ ) . Let p be the number of vertices with degree at least two. FCD is solvable in O ( p p · k · n ) time.Proof. For the sake of simplicity, we assume that the graph does not contain connected componentsof size two (we can deal with them easily separately). Let X ⊆ V be the set of vertices with degreeat least two and Y = V \ X be the set of degree-one vertices. We iterate over all combinations ofthe following: • An integer k ′ ≤ k . If ℓ = 0, then we only consider k ′ = k . • A partition of X into k ′ non-empty subsets X , . . . , X k ′ . There are at most p p such partitions.For i ∈ [ k ′ ], let Y i ⊆ Y be the set of vertices from Y that are adjacent to a vertex from X i . If ℓ = 0, then we accept if ( X ∪ Y , . . . , X k ∪ Y k ) is a solution and otherwise continue with the nextiteration.For each i ∈ [ k ′ ], we put all vertices from X i in district V i . Each vertex v ∈ Y i is either partof V i or forms its own district. Thereby, for each i ∈ [ k ′ ], we know by applying Proposition 5 aninterval [ α i , β i ] for the number of ℓ -fair districts in which the vertices X i ∪ Y i can be partitioned insuch a way or we know that no solution exists (in this case, we continue with the next iteration).We now check whether the given k lies between P i ∈ [ k ′ ] α i and P i ∈ [ k ′ ] β i and return the answer.As there exist p p partitions of X , the running time of the algorithm is O ( p p · k · nn