generate subgraph