First step: graph partitioning