BFS algorithm and Graph model