Elementum interview question

A graph traversal problem.