Graph and BfsIterator classes