A New Redistricting Algorithm: Motivations and Method

Other articles in this series

All current results can be explored on the GitHub data page.

We have a problem with gerrymandering in the United States. Fortunately, the public is taking notice and taking action by taking control away from biased groups of politicians. Voters in this recent election approved state constitutional amendments in Michigan, Colorado, and Utah to form independent commissions to draw new voting district maps.

But now what? How do we create fair voting maps in a transparent way? There are some tough hurdles to overcome. But it’s possible. And we can do it without the bias any group of people will bring to the table.

I’ll cover the problems, some existing methods for drawing voting maps, and a new proposed algorithm to redistrict our states.

The Problems With Current Districts

Dave Wasserman has a more thorough breakdown of the problems to solve.

Not every vote is equal

Using my home state, Michigan, as an example. In the 2012 election (after the last round of redistricting), these were the congressional election results statewide:

Data from Wikipedia: https://en.wikipedia.org/wiki/United_States_House_of_Representatives_elections_in_Michigan,_2012

It certainly doesn’t look correct that Democratic candidates could have been voted for in stronger numbers, but won 4 fewer seats. These voters aren’t being accurately represented in Congress.

Redistricting is biased when done by humans and it’s getting worse

Gerrymandering is a practice that has historically been used to defend the incumbent political party in elections. This practice has been around since the 1800s. Those in control want to stay in control, so they draw voting districts to benefit their party in the next elections.

But recently, it has been used more effectively than ever to lock in control at all levels of government in the US. Modern computing has helped political parties to draw more informed voting maps by using gender, race, age, buying habits, and party affiliation.

Even well-meaning legislation like the Voting Rights Act has been used as an excuse for creating gerrymandered districts.

When more variables are used for redistricting, there is a greater risk of misuse of the data.

Both the Democratic and Republican parties are guilty of gerrymandering

While the current Republican control in most states is currently responsible for most of the gerrymandering around the country, it has been used by both parties in the past. We cannot rely on one party to safeguard our redistricting every 10 years.

Maryland’s 6th is an example of Democratic party gerrymandering:

Source: https://en.wikipedia.org/wiki/Maryland%27s_6th_congressional_district

And North Carolina’s 12th (prior to getting struck down in 2016) is an example of Republican party gerrymandering:

Source: https://en.wikipedia.org/wiki/North_Carolina%27s_12th_congressional_district

Extreme and uncompromising representatives

Gerrymandering creates artificially noncompetitive districts. Which forces any real election competition up to the primaries for each party. And when a politician only needs to compete in the primaries of their party, they compete at the extreme ends of the political spectrum. Any history of working with the other party is potentially a liability, so representatives steer away from it. This leads to further polarization of representation.

Existing Solutions

Independent commissions

I’m very proud that Michigan passed Proposition 2 — Voters Not Politicians in the 2018 election. Michigan’s Prop 2 creates an independent commission with authority to create voting district maps for Michigan. But, while independent commissions can be effective, without the right plan, they are at risk of being lobbied, corrupted, or simply relying on individuals behaving rationally. While people on commissions may have the best interest of the voters at heart, there will ultimately be some bias in their decisions if maps are drawn by hand.

Further, if they are given maps from outside the commission, they could approve maps that appear to be fair currently but won’t be in a few years. There have been advances in data collection and analysis that make it possible to create gerrymandered maps based on predicting population aging and migrations.

Independent commissions are a great start, but can’t solve the problem in its entirety.

Make all districts competitive

When attempting to measure if a state has gerrymandered districts, one approach is to measure how competitive each district is. And to encourage districts that are as competitive as possible.

But what does competitive mean? When most people discuss competitive voting districts, they are referring to districts that have close to the same number of Democrats and Republicans. There are some problems with this approach.

  • It further ingrains just those two parties into our political system.
  • At what cost do we create competitive districts? If people choose to live with like-minded individuals, that’s their choice. The algorithm proposed later is an attempt to remove unnatural non-competitiveness, not combat the so-called Big Sort (a theoretical trend where people tend to move to like-minded communities).

It’s important to measure and report on these metrics after they’ve been drawn. But using previous voting data to help draw voting districts, again, introduces bias. It should be avoided.

Other Redistricting algorithms

A computer algorithm seems like our best solution to eliminate as much bias as possible. Here are some existing algorithms that all eliminate any bias by not using demographic data, which makes them good solutions in their own right. But there are still some issues with each that can be addressed.


Source: https://rangevoting.org

The rules of this algorithm use only the population distribution and geographic shape of the state to create district maps.

But problems arise when finding districts in densely populated urban areas. It tends to break them up indiscriminately. Other examples can be found here.

Shortest Average Distance to the Center of a District

Source: https://bdistricting.com

This algorithm uses US Census blocks to create districts where people have the lowest average distance to the center of their district.

The primary advantage of this method is that it creates fairly round and compact districts.

The goal of this approach is to improve constituents’ access to voting centers by creating districts with the shortest possible travel times to reach the center. I really like this approach, but it still has the same problem of potentially breaking up larger populations indiscriminately. My understanding is that this is mitigated by an element of randomness, which leads to a human choosing from a set of maps for the best maps. This introduces an element of bias into the system.

A great explanation of the process can be found here.

The Proposed Algorithm

Evenly split a state into the required number of districts by using county lines and population borders while keeping districts as compact as possible. Splitting is done by finding the lowest population paths through each county.

Rules the method follows

Keep communities together
By using the 2010 US Census data, this method creates a population density graph using individual census blocks (the smallest census unit). The state is initially split using county lines in order to utilize an already familiar border for most constituents.

But we can’t form voting districts just from counties. They are much too large for the accuracy required. Especially because the US government requires each federal voting district to be accurate to a single voter. Using the 2010 census data, Michigan needs 14 federal districts and each of those districts need to contain 705,974 people.

That means we need another way to break up counties into smaller pieces. This algorithm creates those splits using a form of dynamic programming used in image analysis. It finds the lowest population path through a group of census blocks, and by doing so, it avoids breaking apart communities as much as possible.

Finding the lowest population seam through a county. It finds the lowest population path through this county by evaluating its neighbors. The heat map shows population energy as measured from west to east. And then the algorithm works back east to west to find the best seam. Green blocks represent the lowest energy seam, purple blocks are the possible candidates from the current end of the seam, and orange blocks are the lowest energy candidate.

You can see that the Interstate Highway was the lowest energy seam here. (Which may cause issues where communities are split by highways, but that could be solved by computing population energy by spreading it to nearby blocks). Here is the same county, but finding a vertical seam:

Working south to north.

Ideally, by doing this, maps will naturally comply with the Voting Rights Act. As mentioned before, using demographics other than location can lead to bias. So this algorithm does not use any of that demographic information; and will leave evaluations of the maps to third parties after map creation.

Keep districts as round or compact as possible
When attempting to create a district, it needs to be as compact as possible. You don’t want to end up with an extremely misshapen district that spans the whole state. While designing this algorithm, several different methods were tried. The best result came from simply filling from north to south or west to east (depending on the orientation of the geography). In this way, it always creates the most compact districts given the groups of blocks available:

A weighted Forest Fire fill attempting to split the state of Michigan in half by population. Blue groups are part of the proposed fill. Green is the next best candidate based on the compactness value. And orange groups are potentially isolated groups (districts must be contiguous).

If you’d like to learn more about the other methods that were tried, you can read up on them at the GitHub project page.

Technical process

There are two main parts to this algorithm:

  • Creating districts by selecting from groups of census blocks
  • Breaking apart groups of census blocks if the districts don’t meet the population requirements.
    (And the algorithm will repeat until a district of the correct size is found)

There is a more detailed explanation of the technical progress as well as the open source code at the project page on GitHub.


Michigan’s 14 federal congressional districts as computed by this algorithm.

For more details and to explore the maps, check out the other articles in this series:

Open Source Resources

A big part of making something like this work and be trustworthy is transparency. So all code can be found here:

And the exported data can be found here: