finish buildGraph function
but State class need to change