Graphs and bread-first-search and depth-first-search.