fix breadth_first_search graph parsing algorithm