generate hierarchical graph