In graph algorithm, sometimes we need to merge a large graph to a small graph based on specific sequence.