Open tomasonjo opened 5 years ago
I inspected the code a bit and it is a simple difference in the comparing operator:
DFS:
exitFunction = (s, t, w) -> w > maxDepth ? Traverse.ExitPredicate.Result.CONTINUE : Traverse.ExitPredicate.Result.FOLLOW;
BFS:
exitFunction = (s, t, w) -> w >= maxDepth ? Traverse.ExitPredicate.Result.CONTINUE : Traverse.ExitPredicate.Result.FOLLOW;
It looks like the DFS algorithm has the maxDepth parameter that includes the max value while the BFS algorithm does not include it. This can be confusing to an end user.
Create graph:
BFS
results:
user -----------| "Bridget"| "Alice"| "Michael"|
DFS
results:
user -----------| "Bridget"| "Michael"| "Alice"| "Charles"|