• Post Reply Bookmark Topic Watch Topic
  • New Topic

best way to search!

 
Mateen Dar
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am implementing a grapph in java, and i want to know how to serarch all possible routes between nodes A and X. which algo is best to be implmented.
BFS or DFS
 
Jon Bates
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Although search is hardly my forte, I have a couple of points that may help you. Firstly, depth-first search may well be simpler to impment, since the logic is sstraight forward. The downside is that the solution may not be optimal, and may take much longer to complete.

Conversely, Breadth first will find the optimal path and thus be much faster to complete, but is harder to manage and write. I think though it would be easier to multithread since each path can execute in a single thread as they split off.

One algorithm you may like to look into (i only know about this form the prolog language, and as such can't vouch for its Java-compatability is the A* algorithm, but have fun with that one )

Regards,

Jon Bates
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!