start to implement graph to solve this problem