OK, I have actually modified Dijkstra class to do BFS as well and it got me all possible routes. I added this method:
public void breadthFirstBreadthFirst(Edge graph, LinkedList<String> visited) { LinkedList<String> nodes = graph.adjacentNodes(visited.Last()); // examineExamine adjacent nodes foreach (String node in nodes) { if (visited.Contains(node)) { { continue; } } if (node.Equals(endNode)) { { visited.AddLast(node); printPath(visited); visited.RemoveLast(); RouteCounter++; break; } } // inIn breadth-first, recursion needs to come after visiting adjacent nodes foreach (String node in nodes) { if if(visited.Contains(node) || node.Equals(endNode)) { { continue; continue; } visited.AddLast(node); // Recursion breadthFirstBreadthFirst(graph, visited); visited.RemoveLast(); } } usage would be like this: Usage would be like this:
Dijkstra d = new Dijkstra(_edges, _nodes); LinkedList<String> visited = new LinkedList<string>(); //collecting all routes visited.AddFirst(start); d.breadthFirstBreadthFirst(graph, visited);