In the problem Challenge 8: Find Length of Shortest Path between Two Vertices

Test Case is given as:

(1–2,1–3,2–4,4–5,2–5).findShortestPathLength(1, 5)

The solution provided,

Solution Review: Find the Shortest Path between Two Vertices

does not work with this test case. The expected value of test case is 2. This solution returns -1.

Please try the solution with following main method:

public static void main(String args[]) {

Graph g = new Graph(5);

g.addEdge(1, 2);

g.addEdge(1, 3);

g.addEdge(2, 4);

g.addEdge(4, 5);

g.addEdge(2, 5);

System.out.println(findMin(g, 1, 5));

}

Type your question above this line.

Course: https://www.educative.io/collection/5642554087309312/5724822843686912

Lesson: https://www.educative.io/collection/page/5642554087309312/5724822843686912/4711577859129344