finally implement topology generation