Thales interview question

A graph traversal problem