Amazon interview question

how to traverse a network