A linear-time heuristic for improving network partitions