Amazon Interview Question

how to traverse a network