coding for divide a graph into two partitions