Start of graph search algorithm. Still lots of holes.