Mathematics of Nested Districts: The Case of Alaska

ABSTRACT In eight states, a “nesting rule” requires that each state Senate district be exactly composed of two adjacent state House districts. In this article, we investigate the potential impacts of these nesting rules with a focus on Alaska, where Republicans have a 2/3 majority in the Senate while a Democratic-led coalition controls the House. Treating the current House plan as fixed and considering all possible pairings, we find that the choice of pairings alone can create a swing of 4–5 seats out of 20 against recent voting patterns, which is similar to the range observed when using a Markov chain procedure to generate plans without the nesting constraint. The analysis enables other insights into Alaska districting, including the partisan latitude available to districters with and without strong rules about nesting and contiguity. Supplementary materials for this article are available online.


Introduction: Nesting
A great deal of recent attention has been given to the problem of detecting gerrymandering using mathematical and statistical tools. Much of this work has been restricted to gerrymandering in its classical form: the manipulation of district boundaries to favor one party or another. However, some states' rules of redistricting create other opportunities to extract partisan advantage from control of the process. For example, many states favor plans that keep counties and cities intact rather than splitting them between districts; Iowa even requires that congressional plans keep all of its counties intact within districts.
Some observers worry about whether such seemingly neutral rules would turn out to have partisan or racial consequences for representation. (See, for instance, [12]). In this paper, we will focus on a class of redistricting principles called nesting rules, which require or encourage that state-level Senate districts be composed of pairs of neighboring State House or Assembly districts.
Our present case study is the state of Alaska, where 40 House districts are paired into 20 Senate districts. We start by focusing on the scenario in which House districts are fixed first, then subsequently paired into Senate districts. We select two recent elections to get a baseline of partisan preference at the precinct level, then compare the current Senate plan to all others that can be formed from the current House districts by pairing. Across all these scenarios, we will discuss when and why the choice of pairing, or perfect matching, can have a sizeable impact on electoral outcomes.

Perfect matching interpretation
There are eight states that currently have two single-member House/Assembly districts   When nesting is mandated, procedures can still vary. According to the Brennan Center's Citizen's Guide to Redistricting [22]: "Sometimes, a nested redistricting plan is created by drawing Senate districts first, and dividing them in half to form Assembly districts; sometimes the Assembly districts are drawn first, and clumped together to form Senate districts." This paper will focus on the second case: matching, rather than splitting.

Proof of concept
We begin by constructing a toy example to illustrate that matchings matter. Consider the map shown in Figure     The districts can be matched the eight different ways listed here, leading to the Democratic party getting anywhere from 25% to 100% of the Senate seats. The two perfect matchings corresponding to the extreme outcomes are shown here.
In this toy example, we discover that the choice of matching can swing the outcome for Democrats from 1 seat to 4 seats out of four. Below, we carry out a similar analysis on real-world data.

Mathematical literature on perfect matchings
In our motivating example, we considered the Senate outcomes for every possible perfect matching in a small graph. Enumerating all perfect matchings in a given graph is a classical problem in the mathematical field of combinatorics; it has captured significant attention because it is at once quite elementary and extremely difficult to compute for arbitrary graphs [36]. The matching problem is also of great interest to physicists studying dimer coverings (domino tilings) of lattices, which are used to estimate thermodynamic behavior of liquids [20]. In 1961, three statistical physicists, Temperley, Fisher, and Kasteleyn, independently and nearly simultaneously derived the formula for the number of perfect matchings of an m × n grid [18,34] and subsequently proposed the FKT algorithm for efficiently computing the number of perfect matchings of any planar graph (that is, in any graph that can be drawn in the plane without edges crossing). The algorithm is discussed in more detail in Appendix B in the supplement. For surveys on the mathematics of matching, see [24] and Volume A of [31]. 3

Paper outline
The central research question here is to quantify the partisan advantage available to an agent who is empowered only to select a House-to-Senate pairing. In Alaska, where there are only 40 House districts which are patterned in a not very dense manner, it might seem that there is only limited advantage to be gained. However, we will demonstrate that the choice of pairings alone can create a swing of 4-5 seats out of 20 against recent voting patterns. In fact, we will see that even though pairings give a far simpler model of how to create Senate districts, they give just as much partisan latitude as making Senate districts from scratch.
We begin by reviewing pertinent background on Alaska politics, demographics, and redistricting rules in §2, culminating in the selection of two recent elections-the Governor and U.S. House races of 2018-to serve as our electoral baselines for the remainder of the analysis. In §3, we begin by describing the construction of dual graphs that model the adjacencies of geographical units-in this case, House districts. Next, we overview the algorithmic approaches we apply to those graphs in the rest of the paper. These methods include enumerating matchings with a classic algorithm called FKT, constructing sets of matchings with a depth-first algorithm we call prune-and-choose described in Appendix C, and finally varying the underlying districts with a Markov chain. The proof of validity for prune-and-choose is found in Appendix C.2.
In the remainder of the paper, we report on the results of these algorithmic investi-  in recent presidential races, making it a rare city of its size to do so. 5 Although it is one of the "reddest" states in national terms, the Republican-Democratic split is not the fundamental divide in Alaskan politics. Extremely conservative Republicans are sometimes balanced by a tenuous coalition of moderate Republicans, Democrats, and Independents, which currently aligns to give net Democratic control in the state House. In 2018, an Independent, Libertarian, or Nonpartisan candidate ran in nine of the 40 House districts; an Independent won in one district and one Democratic candidate changed his affiliation to undeclared after winning [4]. In areas where the Democratic party label is an obstacle to election, running as an Independent can be a successful political strategy.
The majority caucus in the House originally consisted of 25 members: all 15 Democrats, the two unaffiliated members, and eight Republicans [4]. 6 On the other hand, one state Senator elected as a Democrat caucuses with the Republican majority in that body [2].

Racial demographics and the Voting Rights Act
The 2010 Census reports Alaska's racial demographics as roughly 6% Hispanic, with non-Hispanic population comprising 63% White, 3.5% Black, 5.5% Asian, and 15% Alaska Native or other Native American as shares of the total. An additional 9% of residents are recorded as belonging to other races, or to two or more races. Figure 4 shows the proportion of Alaska Native or other Native American residents across the state. The large Alaska Native population has long been singled out for federal protection under the Voting Rights Act of 1965, specifically Section 5 of the VRA, which required 6 Twenty-one members (15 Democratic,4 Republican, and two unaffiliated) voted together to elect the current Speaker (who ran for his House seat as a Democrat but became unaffiliated just days before being elected Speaker). Four more Republicans joined to establish the majority caucus. In May 2019, however, one Republican left the House majority coalition [4,3]. covered jurisdictions to seek prior federal approval (or "preclearance") for any changes to districts or other voting laws. Alaska's inclusion owed to a long history of discriminatory "literacy tests"-in this case, English-language tests used to deny voting eligibility to Native residents-making Alaska one of only nine states covered in full by the special protections

Redistricting rules and practices
Following a 1998 state constitutional amendment, a five-member Alaska Redistricting Board was formed to draw new district lines after each decennial census [16]. The House speaker, Senate president, and Chief Justice of the state Supreme Court each choose one member of the board, and the Governor chooses two. At least three members of the board must approve a redistricting plan for it to be adopted. The board must draw maps in accordance with the state Constitution, which requires that House districts be "contiguous and compact territory containing as nearly as practicable a relatively integrated socio-economic area.... [and] contain[ing] a population as near as practicable to the quotient obtained by dividing the population of the state by forty" while Senate districts are simply "...composed as near as practicable of two contiguous house districts" without further constraints [32]. 9 Balancing the requirements of the VRA and the guidelines of the state Constitutioncompactness in particular-means that Alaska's House and Senate districts have to be drawn in a coordinated fashion in most of the state. However, Alaska's relatively urban centers of Anchorage and Fairbanks are both predominantly white and made up of small, regular pieces. This homogeneity of demographics and geography provides addi-tional flexibility in these regions for the map drawer to construct House districts first, without considering potential Senate pairings.
Allegations of partisan intent have frequently been leveled at the redistricting process in Alaska. The maps drawn after the 2000 Census were accused of being a Democratic gerrymander, while Democrats have called the post-2010 maps (drawn by a board with a 4-1 Republican majority) a Republican gerrymander [25]. The fact that a Democratic-led caucus controls the House while Republicans have 2/3 control of the Senate lends credence to the possibility that not the House districts themselves, but their pairing to form Senate districts, is chosen for Republican advantage. That possibility is investigated below.

Our choice of election data
In Alaska, three types of races occur statewide. The entire state votes for a Governor and Lieutenant Governor, elected on a single ticket, every four years; they elect one member to the U.S. House of Representatives every two years; and they elect a U.S. Senator for a term of 6 years in the Class 2 and Class 3 cycles.
We consider only those elections which occurred after the implementation of new maps  The list includes all candidates with at least 5% of the vote in any race. 10 We will use the Cong18 and Gov18 races as the fundamental electoral data for the Gov18-N party share Gov18-A party share Cong18-N party share Cong18-A party share U.S. House race, 33.36% of reported ballots were unprecincted. In the 2018 Governor race, 11 We note that the question of preferring endogenous or exogenous election data for redistricting analysis is a live one in political science, as reflected for instance in the article, rejoinder, and response between Best et al and McGhee in the March 2018 issue of the Election Law Journal [7,26,6]. Our research group inclines to the use of well-chosen exogenous (statewide) election data in general, but we further note that using endogenous data would be forbidding in the Alaska legislature. Besides a significant number of uncontested races, these legislative races also feature a proliferation of minor parties (described above), making a regression analysis particularly inadequate to cleanly model voters' preferences between the two major parties. 34.18% of ballots were unprecincted. (For ease of reference, we will call all unprecincted ballots "absentee" below.) We report results for each election both including and excluding the absentee ballots. Thus our four election treatments can be labeled Gov18-N, Gov18-A, Cong18-N, and Cong18-A, where the N versions drop absentee ballots from the tally and the A versions include them. In §5, we need to know the precinct location of the votes; for this, we assign absentee ballots to precincts in numbers proportional to precinct population.

Data and methods
All experiments in this paper were performed on an Ubuntu 16.04 machine with 64 GB memory and an Intel Xeon Gold 6136 CPU (3.00GHz). Algorithmic descriptions of the FKT method for enumerating matchings and the Prune-and-Choose method for generating matchings are given in Appendix B and C of the Supplementary Material, respectively.

Election results, shapefiles, and dual graphs
Election data were gathered from the Alaska elections website [1] and demographic data were obtained from the 2010 Census. Absentee and early voting information was only available by House district, so precinct-level data was assigned by prorating by population.
We prepared the geospatial data with the MGGG Preprocessing Suite, which uses areal interpolation for blocks not fully contained in precincts [30]. The cleaned and processed version of the data is available on GitHub [28].
In the 2010 Census, Alaska had 45,292 census blocks, of which over a third (18,263) are water-only. Alaska has 441 precincts, ranging in population from a minimum of 44 Beginning with a shapefile of the geography, in this instance precincts, we use geospatial libraries in Python to create a dual graph in GerryChain whose nodes are the geographic units, and where two units are connected by an edge if their units share a positive-length boundary in the shapefile [27]. We then adjust edges to better correspond to plausible notions of adjacency, especially when water is involved, as described below.

Water adjacency
For areas connected only by water, a decision must be made about whether to count them as adjacent. To illustrate the impact of this seemingly minor issue, we construct three different dual graphs of the precinct map, which we call the tight, restricted, and the permissive graphs.
Permissive adjacency is the closest match to the AK Division of Elections precinct shapefile. The dual graph of those precincts is nearly connected using this approach, except for one gap in the Kodiak archipelago and five additional island precincts of the West coast. We manually added all visually reasonable connections in these cases. Among the 441 precincts, this process produces 1151 edges. Aggregating the precincts into the 40 current House districts produces a House district dual graph with 100 edges. Figure 6: The Cook Inlet is a body of water stretching up from the Gulf of Alaska; its Knik Arm and Turnagain Arm surround the densest part of Anchorage, separating it from rural precincts to the north and south. Following precinct adjacencies provided by the state would allow districts to jump across the water, while a more restrictive notion of adjacency would not. On the right, we see that the precinct shapefile gives no guidance on how the islands are allowed to be connected to the mainland by districts.
To construct our more restricted notion of adjacency, we consulted the Census Bureau Cartographic Boundary shapefile, which is clipped to land, i.e., excludes water from its geographic units. With this as a guide, we removed certain connections across water (see Figure 6). This reduces the number of edges modestly, from 1151 to 1109 for the precinct dual graph and from 100 to 92 for the House dual graph.
Finally, we create the tightest version of the graph by using the current House map as a guide, keeping the fewest water adjacencies that would allow the current districts to be considered valid. This gives us a tight dual graph with 1105 precinct edges and 89 House edges. As we will see below, these small changes to the underlying dual graph can have large consequences for the number of possible matchings. Figure 7 shows the resulting graphs, which we use in the remainder of the analysis.  impose hard constraints in the form of requirements for plans, or can choose a weighted random walk that preferentially selects plans with properties deemed to better comport with the districting principles. The tree method itself promotes the selection of compact districts, so the plans generated in this way tend to have comparable compactness statistics to human-approved plans and to comfortably pass the "eyeball test" for district shape.
We ran our Markov chains on Alaska's 441 precincts as basic units, seeking new legally valid plans for forming them into 40 House districts. As outlined above in §2.3, the law requires that the districters aim to produce equipopulous, compact, and contiguous districts.
The ideal population of a House district is 710,231/40, or between 17,755 and 17,756 12 The scientific advantage of using Markov chains to sample districting plans is that they have a theoretical guarantee of producing representative samples (with respect to their stationary disributions) if run for long enough. In our case, we run the chains until we obtain strong heuristic evidence of mixing, which is a common and effective standard in scientific computing. See [13].
people. By federal law and common practice, legislative districts can deviate by up to 5% from ideal size without a special reason, so we have imposed that limit on population balance, allowing 16,868-18,643 people per district. The same level of population balance was imposed on the Senate ensembles.
We generated ensembles of 100,000 distinct House and Senate districting plans, varying the definitions of contiguity (tight/restricted/permissive). A district-level dual graph of the sampled plan was pulled every step. Using FKT, we counted the number of matchings for each districting plan and edges between House districts, and we stored plans with extreme matching statistics. The goal was to learn whether the new plans could have markedly different partisan outcomes, either on their own or when matched to form a Senate plan, from the current districts.
Replication code for producing and analyzing these ensembles is available on GitHub [29].

Alternative matchings in current House plan
In this section, we evaluate the currently enacted House plan by generating all of the potential matchings and computing their partisan behavior under our chosen election data.
We start by computing the number of matchings for each of our notions of adjacency, reported in Table 2, using the FKT algorithm described in Appendix B. This already highlights the fact that toggling a small number of edges in the Alaska House dual graph (due only to reasonable interpretations of water adjacency) can change the number of perfect matchings very substantially; in this case, the number of matchings jumps by nearly a factor of eight. 13 We then use the prune-and-choose algorithm described in Appendix C to generate each of the possible pairings. For each matching, we evaluate its performance under each of the four election treatments, comparing the number of Senate districts with a Democratic majority in the actual plan to the average number over the Senate plans formed by all possible matchings. It bears emphasizing that the Democratic seats reported across the 13 It is worth emphasizing that the number of matchings is sensitively dependent on the precise edge structure as well as simply the number of edges. This fact is explored below in §5.3.

Alaska Tight
Restricted  Table 3: Partisan outcome and competitiveness in the current (Enacted) Senate plan compared to the average over alternative matchings. A competitive district is defined here as one with a D share between 40 and 60 percent. Here, every partisan outcome is more favorable to Republicans than the neutral expectation. Compare Table 4, which varies the underlying House plan and shows the opposite partisan tendency.
Comparing the enacted plan against all possible pairings does indeed find a small Republican tilt, falling approximately one seat to the Republican side of the typical matching but certainly does not appear to be a significant outlier. 14 (At the same time, we can observe the substantial effect of discarding absentee ballots: it shifts outcomes towards Republicans by about 1 seat.) The histograms in Figure 8 add detail by showing the full distribution of Democratic seats with respect to each race.
14 The actual Senate composition also has six or seven Democrats, depending on how you count: seven state Senators were elected as Democrats, but Sen. Lyman Hoffman caucuses with the Republican majority. For even more granular detail, at the level of individual districts, we can study box-andwhisker plots (Figure 9). In these images, the districts are ordered from lowest to highest Democratic vote share in order to make them comparable over the ensembles. The boxes show the 25th-75th percentile range and the whiskers show every result achieved over the full set of (permissive) matchings. Similar histograms and boxplots for the remainder of the elections and dual graphs are available in our supplemental material [29].

Cong18-A Dem share by Senate district
Gov18-A Dem share by Senate district Figure 9: Democratic vote share in current Senate districts (red dots), compared to range in comparable districts over the full set of matchings (box and whiskers). With district-bydistrict detail, the differences between the two elections' voting patterns are more visible. For instance, the 13th-indexed districts in the state have a Galvin (Congressional) share and a Begich (Governor) share just under the median of the respective ensembles, while nearly 75% of the ensemble in each case had a Democratic majority in the corresponding district. Where boxes have degenerated to a single value, it is because some matchings are forced, thinning the number of possibilities.

Partisan outcomes
Using the Markov chain ensembles of 100,000 plans each as a neutral counterfactual for drawing districts, we first report the number of House districts out of 40 with more Democratic than Republican votes.
Beyond the averages, we can view the full histograms to gauge the extent to which the   Table 3.
current plan is an outlier. a small number that achieve a 5-seat outcome against the Governor returns. This means that mere control over the matchings gives essentially just as much partisan latitude as the right to draw plans from scratch with the most permissive notion of precinct adjacency.

Native population
We also find that the number of districts with an Alaska Native population majority is typically 3-4 in our randomly produced House plans, compared to three in the current House plan. Furthermore, the ability to form districts more permissively across water makes a very noticeable difference, boosting the likelihood of forming a fourth majority-Native district by random selection. more edges means more matchings, but the scatterplots in Figure 12 show that there is also substantial dependence on the specific placement of the edges. 15 This accounts for a doubling in the number of overall matchings, assuming a comparable number of ways to match the remaining 36 vertices. Forced pairings play an important role 15 One notable feature of Fig 12 is the prevalence of plans with low numbers of matchings. It is easy to construct graphs with any number of edges and zero matchings, simply by having any two leaves (vertices of degree one) connected to a single common neighbor-and this can easily occur by chance. There were no matchings at all in 2319, 4274, and 3504 of the dual graphs found by the ensembles, respectively. It is similarly easy to randomly construct graphs with very few matchings simply by having many leaves and thus many forced edges. On the other hand, there are graphs with 2n vertices, roughly n 2 /2 edges, and only a single matching: start with a complete graph on n vertices (i.e., with all edges present) and add a single leaf connected to each of those. Each leaf vertex is forced to match to its unique neighbor, leaving no more vertices to pair.
in plans with few matchings. The rightmost graph shows an example with 101 edges but only 852 matchings, the lowest nonzero number ever observed. This is due to the many forced pairs-[ (11,13), (12,34), (2,3), (1,36), (4,33), (8,24), (7,26), (17,25)]-which limits the flexibility in pairing the remaining vertices.  Figure 13: A selection of three House plans from our ensembles whose dual graphs have various extremal properties. The violin plot shows the number of Democratic districts with respect to Gov18-A vote data, and the colored regions show the relative sizes of the matching sets.
The analysis demonstrates that the matchability of the underlying House plan can have a significant downstream partisan impact on the Senate plans that can be formed. Figure   13 shows examples of this behavior by comparing the distributions over the possible perfect matchings for three plans from the permissive ensemble. For each of the three House plans, a typical perfect matching has 5-8 Democratic districts out of 20. However, by choosing a House plan with more district adjacencies or more matchings, it is possible to get as few as 3 or as many as 12. Investigating the full flexibility allowed to a mapmaker who controls the House district drawing process is an interesting question for further research.

Conclusions
Numerous studies have sought to quantify the partisan advantage secured by the selection of a particular districting plan. In that vein, we find that the current Alaska House plan favors Democrats by an estimated 1-2 seats out of 40 when compared to other (contiguous, compact, population-balanced) ways of forming districts from precincts. The core of the paper, however, is a novel application of rigorous mathematics to redistricting in the case of a nesting rule for state legislatures. For that, we can apply the theory of perfect matchings of graphs, learning that the Alaska Senate plan secures a Republican advantage of 1 seat out of 20 when compared to other ways to match the House districts. Other findings: • The choice of matching of a fixed House plan gives as much latitude to control partisan outcomes as drawing a Senate plan from scratch: approximately a five-seat swing out of 20.
• The significant number of absentee/early/provisional ballots in Alaska skew markedly Democratic. Different choices of how to assign them to precincts will impact findings about the consequences of moving district boundaries, and should be further studied.
However, this has no effect on our analysis of matchings.
• Well-chosen statewide races, in this case the 2018 Governor and Congressional elections, gave partisan measurements that are closely compatible with each other and qualitatively concordant with the Legislative outcomes.
• Contiguity rules are not completely straightforward, and can have a major role in shaping the space of districting possibilities. For instance, permissive water adjacency makes nearly half of neutrally generated House plans have a fourth majority-Native district, while less than 2% of plans do with more restricted adjacency ( §5.2).

Supplement to Mathematics of Nested Districts: The Case of Alaska
This supplement contains additional plots and technical descriptions of the algorithms used in the paper for enumerating and sampling perfect matchings. Appendix A shows reference figures of the state House dual graphs for the non-Alaska states with strict nesting rules. Further information about the FKT algorithm is given in Appendix B while Appendix C introduces the new Prune-and-Choose algorithm and provides a proof of correctness. In Appendix D, these algorithms are applied to all states with a nesting rule to compare the relative scales of the enumeration problem. Finally, in Appendix E we implement and validate a uniform sampling procedure for matchings that can be applied even in the states where generating all of the matchings would be computationally infeasible.

A Dual Graphs of States with Nesting Rules
In this appendix we show the dual graphs for the other states that require two-to-one nesting. Corresponding plots for Alaska are shown in Figure 7 of the main text. The lefthand column shows the House districts, with the dual graph overlaid, and the right-hand column shows a nearly-planar embedding with accurate district labels. Given these House districts, valid Senate plans in these states correspond to perfect matchings of these graphs.

Illinois
Iowa Minnesota B FKT algorithm for enumerating perfect matchings This algorithm runs in fractions of a second on each graph, which is fast enough to incorporate at each step of a Markov chain. Our implementation is freely available at [29], and timing details are provided in §D.

C Prune-and-choose algorithm for constructing perfect matchings
In order to evaluate the partisan properties of the pairings of House districts, it is not sufficient to count matchings; we also need to generate and examine the full list of matchings.
In this section, we describe a simple method to create a list of all possible perfect matchings of a graph. This is a recursive method that simplifies the search by looking for forced pairs.
The first step is to prune the graph. This means finding all leaves of the graph (nodes of degree one, i.e., House districts that are only connected to one other district) and matching each with its only neighbor. We call these matches forced pairs. One round of pruning may create new nodes of degree one in the resulting graph, and so we iteratively prune forced pairs until there are no nodes of degree one left.
The second step is a simple check to rule out a parity obstruction to the existence of a matching. If any connected component has an odd number of nodes, then it cannot be perfectly matched, so the whole graph also fails to have a perfect matching. If all connected 16 The Pfaffian is a general matrix operation that agrees with √ det A for skew-symmetric matrices. See [23] for more mathematical details.
components have even numbers of nodes, then we proceed.
Next is a choice step. From the remaining graph, we choose a node of minimum degree, then consider pairing it with each of its neighbors. For each of those pairings, we remove both nodes from the graph and apply our algorithm to what remains. We prune, check, choose, and iterate, in sequence, until the process terminates at a connected graph of two nodes, producing a perfect matching of the original graph. We provide a proof of correctness in Appendix C.2 and an example run of the algorithm on a small graph below.

C.1 Prune-and-Choose Example
A run of our algorithm on a sample graph with ten nodes proceeds as follows.  In the end, we find the two perfect matchings AB/CF/IJ/ED/GH and AB/CF/IJ/EH/GD.

C.2 Prune-and-choose algorithm validity
In this section we formally describe the prune-and-choose method and provide a proof of correctness. Pseudo-code for the algorithm is given here and our implementation in Python is available at [29]. We introduce some additional notation to describe the method.
The subgraph of G induced by deleting nodes u and v will be denoted G \ {u, v}. We will represent a matching as a set of edges M = {(u 1 , v 1 ), (u 2 , v 2 ), . . . , (u , v )}. We assume that the vertices of G are ordered in order to provide a deterministic algorithm. To generate the full set of matchings for a graph G, we would call FindMatchings(G, ∅). if G is connected and has exactly two vertices u, v then 3: else if G has any vertex with exactly one neighbor then 5: prune: let u be the first degree-one vertex; let v be its neighbor 6: return Pair forced vertices and recurse.
Recurse to find all perfect matchings with each pair We next show that the algorithm returns the correct set of perfect matchings on any graph. They key idea of the algorithm and the proof is that for any edge of the graph, the set of perfect matchings that contain edge (u, v) can be computed by finding all perfect matchings in the subgraph G \ {u, v}. This is an example of the self-reducible nature of the perfect matching problem which is discussed in more detail below.
Theorem 1. The prune-and-choose algorithm correctly finds all perfect matchings in the input graph.
Proof. We consider any graph G with n = 2k vertices and proceed by induction on k.
When k = 1, G is either connected (in which case the algorithm correctly finds the unique perfect matching at lines 2-3) or has two isolated vertices and no perfect matchings (which the algorithm correctly reports in lines 7-8).
For k > 1 the algorithm proceeds according to exactly one of the following three cases: 1. If G contains a leaf u with neighbor v, then u must be matched to v in any perfect matching. Line 6 then calls FindMatchings on G \ {u, v} which returns the correct set of matchings of G \ {u, v}, by our inductive hypothesis. Adding (u, v) to each matching returned by this function gives the full set of matchings for G. Thus for any graph G, the first pass through the algorithm either returns ∅, which only occurs if G has no perfect matchings, or it calls the algorithm recursively on a graph of size 2(k − 1). These recursive calls satisfy our inductive hypothesis and hence we obtain the complete set of matchings for G.
We note that well-known classes of planar graphs have exponentially many perfect matchings. For example, this is true of the n × n grids [8,18,34]. This trivially implies that there is no polynomial-time algorithm to list them all as output. As we discuss in Appendix D, the dual graphs of real-world districting plans often have more perfect matchings than a grid graph of comparable size. In that section we also provide timing results for our algorithm that demonstrate that it is adequately fast for several problems at realistic scale, but not all. In Appendix E below we show how a sampling approach can be employed to those settings in which listing all perfect matchings is computationally infeasible.

D Enumerating matchings
Here we apply FKT and Prune-and-Choose to compute the number of potential matchings for each of the eight states that require Senate districts to be formed from adjacent pairs of House districts. We use the standard Census shapefiles to generate dual graphs for each state, making them parallel to the permissive graph for Alaska. Visualizations of these dual graphs are shown in Appendix A.  Extrapolating the prune-and-choose timing from Nevada (299 seconds) and Wyoming (851 seconds) suggests that generating all of the matchings for some of the other states would take prohibitively long-even with linear scaling, the Wyoming timing suggests that the Minnesota computation would take some 180 million years. However, it is possible to sample matchings from planar graphs uniformly, allowing for good estimates of relevant statistics. We have implemented the technique suggested in [17] for this purpose [29] and in Appendix E we validate this approach on Alaska.

E Sampling and extremization over matchings
For Minnesota's 6.1 quintillion matchings, it would be prohibitively inefficient to list them all, no matter the algorithmic design. On the other hand, we can construct uniform samples of the full set of matchings by making use of the self-reducible structure in the perfect matching problem [17] as follows. We can compute the likelihood that a given edge appears in a perfect matching by deleting the edge from the graph and enumerating the matchings on the remaining nodes with FKT. The ratio of matchings on the leftover to total matchings is the probability that the edge is used. With this, we can iterate, starting with the original graph and adding a single edge to the matching at each step with appropriate probability. Since FKT runs in polynomial time, so does our sampling procedure, since a perfect matching requires n 2 edges and finding the probabilities used to select each edge requires at most n 2 FKT evaluations. We next demonstrate that the uniform sampling method can attain good accuracy with a reasonably small number of samples, using the case of Alaska where we can compare to the ground truth from the full matching set. For each of our three dual graphs, we sample 100 matchings uniformly and compare the resulting statistics to those of the full set of matchings. Figure 14 shows these comparisons. Although the distributions are not identical, they are quite similar and the sample means vary only by small fractions of a seat from the actual values. This example shows that even a sample of modest size produces a good estimate of the full distribution. This provides support for our assertion that this procedure can be carried out successfully on states like Minnesota, where it would be computationally infeasible to generate all matchings. We note that all materials are available in our code repositories for others to perform this sampling for the other matching states, but there will be a non-trivial data setup cost in choosing appropriate election data and cleaning it for the analysis.
Though the histograms above are quite similar, the sample fails to capture the full range of seat outcomes in the Governor's race: a small number of possible matchings result in five D seats, but that is never observed in the sample. A second algorithm may be employed to provably find the correct range of seats outcomes possible, again without fully listing the matchings. Finding perfect matchings of extremal weight, given an edgeweighted graph, is a classic problem in combinatorics, solved for instance with the Blossom algorithm developed by Edmonds in the 1960s [14,15]. To apply that in this setting, we use any given pattern of votes to assign a weight to each edge of our dual graph: an edge {u, v} linking two House districts u and v is given weight 1 if there are more D than R votes in the hypothetical Senate district that combines u and v. Otherwise, assign weight 0. The weight of the perfect matching is defined as the sum of the weights of its edges.
By construction, this is the number of D seats in that matching. For more background on extremal perfect matchings, see for instance Chapters 25-26 of [31].
As a final note, knowing these extremes also informs the size of a uniform sample necessary to estimate the true distribution to a desired precision. A detailed discussion of the precise number of samples needed for various estimates is presented in [37]. In particular, Theorem 5.3 shows that with failure rate δ, taking max 4 ε 2 , 4 ln( 1 δ ) ε 2 samples suffices to estimate the probability of each individual outcome to within ε (i.e., an L ∞ bound) whereas max 4n ε 2 , samples suffice to bound the sum of the absolute differences between the individual estimates and the true probabilities (an L 1 bound).