Partitioning the nodes of a graph