Implemented the Breadth First Search to check if graph is connected