# Do breadth first search from both ends at the same time.
# Keep a set of all nodes that each has reached.
# When the sets have any element in common, there is a path.