Question d’entretien chez TIAA

given graph. please write code to iterate graph each node. please dont judge candidate on single interview question. I have wasted my half day here.