Voters should choose their candidates, not the other way around, but in gerrymandered districts that's exactly what happens. Gerrymandering has a long and storied history. Originally invented as a way to draw districts to help voters of color earn representation, it didn't take long at all for the political machine to realize they could gerrymander districts to do the exact opposite.
In the USA, racial gerrymandering was outlawed in 1965 as part of the Voting Rights Act, but partisan gerrymandering, drawing districts which virtually ensure that one party will be overrepresented and the other party will be underrepresented on councils or in legislatures is still widespread -- and both parties do it.
The term gerrymandering generally refers to the way district lines are drawn within a city or a state, but the same concept applies for the subdividing of any election into local areas. The drawing of states or provincial borders is just as vulnerable to gerrymandering as the drawing of districts for the house of representatives or for city council.
Any time you break a larger area into smaller areas and elect a winner in each area, the election needs to be protected against gerrymandering.
Proving that an existing district has been gerrymandered, either intentionally or unintentionally, is absolutely doable thanks to the fact that gerrymandering can be measured explicitly. In any election with two identifiable sides you simply measure the number of votes on each side which made a difference and helped win a seat, and those which did not make a difference and were wasted.
In the example above this is clear. In the middle diagram the red faction wastes 100% of their votes every time, while the blue faction is only using the minimum number of voters in each district to ensure a majority. This is a perfect blue gerrymander. In the example on the right blue uses up way more votes then they needed in the two seats the won, so they don't have enough voters left to win a 3rd seat. This is a red gerrymander.
The term "Wasted Votes'' in gerrymandering has a very specific mathematical definition. It includes all the votes for candidates who didn't win, plus any extra votes for the candidate who did win. If one side wastes more votes than the other consistently, across a number of elections, and if there was a better way these districts could have been drawn, then the jurisdiction is gerrymandered.
In a gerrymandered district, voters on one side are able to use their votes very efficiently while votes on the other side are much more likely to be wasted. This difference is known as the election's "Efficiency Gap." The larger the election's Efficiency Gap, the worse the gerrymander. The smaller the efficiency gap, the more fair future elections are likely to be. Ideally, the number of wasted votes on both sides should average out to being roughly equal over time, or the margin of wasted votes should be as small as possible given the number of seats available and the size of the factions.
Drawing perfectly fair, not-gerrymandered districts is impossible in practice because populations shift and because people aren't actually neatly sorted into two opposing factions. This is why the Supreme Court ruling cited above which enshrined the right to an equally weighted vote included the disclaimer "as nearly as is practicable." That said, the Efficiency Gap between parties on the right and on the left, and between voters of color and white voters can and should be measured after each election, and if a stark disparity across the last four or so elections is found then an independent redistricting commission should be convened to redraw the districts more efficiently if possible.
For a given jurisdiction, it's possible to establish what a kind of efficiency gap is practicable, and then encode that efficiency gap in the jurisdictions redistricting protocols, effectively banning racial and partisan gerrymanders.
Equitable Redistricting Commissions
The Equal Vote Coalition advocates for a multi-pronged objective approach to combating gerrymandering, rooted in the science and informed and held accountable by the communities on the ground who are the most impacted.
We call for each and every jurisdiction to pass legislation banning gerrymandering and convening equitable redistricting commissions. These commissions would employ a two-step and two-team process. First, a small "Cartography Committee" of technical experts (skilled in cartography, math, statistics, districting, and programming,) would be convened after each election to measure the efficiency gap and test for both partisan and racial gerrymanders. If the election's efficiency gap over a set number of elections (four for example) was found to be over the set limits, then the second team, an "Impacted Communities Committee" would be convened. This second committee would include a representative from each political party large enough that they could hypothetically win a seat if their members were all clustered in one area. The committee would also include one citizen from each district in the current jurisdiction. These citizens would be chosen to ensure that the "Impacted Communities Committee" reflects the self-identified racial diversity of the jurisdiction as closely as possible. Individuals could invited to serve on the committee by a lottery system, much like jury duty, and members could be selected to ensure diversity on a number of spectrums, such income, and whether the people are renters or homeowners as well.
A number of considerations should go into the drawing of legislative districts, so at this stage, the commission can convene to share and discuss their ideas regarding representational goals, district compactness, and any geographical or historical considerations that should also be factored into the districting map as well. The Cartography Commission can then get to work on a first draft of a new map with highly efficient boundaries. This draft map would then go back to the Impacted Communities Committee, which would either pass the redistricting proposal by a 2/3 vote, or provide feedback for the next iteration. This process would repeat until an acceptable map was produced.
A Bi-Partisan Approach
Solving gerrymandering is more of a political problem than a technical one and stopping gerrymandering is somewhat of a game of chicken. If one party was to suddenly pass a bill that eliminated gerrymandering in all jurisdictions they controlled, the result would be an even worse gerrymander that would likely put them at a massive disadvantage overnight.
For this reason, ending gerrymandering at the national level requires a bipartisan approach where states controlled by both parties pass the same legislation, but where the legislation doesn't take effect in either state until the number of extra seats gained by gerrymandering on both sides is equal. This would require a type of bill called an interstate compact, much like the National Popular Vote Interstate Compact.
Mitigating the impacts of Gerrymandering
The impacts of gerrymandering are at their worst when voters are highly polarized, affiliating strongly with one side or the other. This is the exact political climate that is created when we use voting methods that suffer from extreme vote-splitting, such as Choose-One plurality voting, and to a lesser extent, Ranked Choice Voting.
For this reason, adopting a better voting method like STAR Voting, Condorcet, or Approval Voting that eliminates vote-splitting and ensures an equally weighted vote is a key piece of the puzzle and a great way to combat the impacts of gerrymandering, even in places where the political climate makes it impossible to ban it directly - for now.