Microsoft interview question

How to traverse the graph