divide into subgraphs