Closed dlaertius closed 6 years ago
Hi @dlaertius . Sorry for the big, big, big, big delay in taking a look to this issue. You're right.
It seems that the problem is in HashBasedHipsterDirectedGraph
, which returns the cities not in lexicographical order, so DFS explores them not in the order you expect. For most problems this don't really matter, but for the Romania search problem it has to be done this way to get a comprehensive solution.
I'll take a look into this when I have some time. Thanks for your feedback.
Hi guys, forgive me if I'm wrong, but I tried a thousand time and cannot found the correct solution for dept-first-search problem related to Romain problem, from Arad to Bucharest.
This is my code:
SearchProblem problem = GraphSearchProblem.startingFrom(RomanianProblem.City.Arad).in(RomanianProblem.graph()).takeCostsFromEdges().build(); System.out.println(Hipster.createDepthFirstSearch(problem).search(RomanianProblem.City.Bucharest));
My output is: [Arad, Zerind, Oradea, Sibiu, Fagaras, Bucharest] but I'm my opinion the correct must be [Arad, Sibiu, Fagaras, Bucharest] cause DFS explore each node before the backtracking preserving lexicographic order, am I right?