Over the last few years, mathematicians have been studying how various algorithms can be used to draw up fair legislative districts. Here are two recent articles about different approaches:

Can Math Solve the Congressional Redistricting Problem?

Will Geometric Group Theory Solve the Redistricting Problem?