Modified functions to take the graph as a const parameter as the graph itself isn't altered by the search.