Add n-hop partitioning code