I've implemented a DFS recursive algorithm to find ALL paths between two nodes on a directed graph. Currently, my algorithm is finding approximately half of the total paths to find (I checked on an online tool how many possible paths there should be). I'm not sure where my algorithm is going awry. I have checked a bunch of different posts and it seems to be what others have implemented but I think I may have overlooked something. This is my first pathfinding algorithm and I seem to be stumbling over my first hurdle. I am not allowed to use inbuilt ADTS and therefore have built my own. Any help is appreciated as I am really pulling my hair out over this one. Please let me know if you need further information/code.
PATH FINDING
private void findPaths(String current, String target, LinkedList<String> currPath)
{
Edge edge;
if(current == target)
{
System.out.println(curPath.toString());
return;
}
for (Vertex vertex: current.getAdjacent()))
{
Edge edge = getEdge(current+vertex);
if(!edge.getVisited())
{
edge.setVisited;
curPath.insertLast(vertex);
findPaths(vertex, target, currPath);
curPath.removeLast()
}
}
edge.clearVisited()
}
edited for readability.