implementing graph structure, and Breadth-First Search