• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

best way to search!

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic