Jump to content

Recursive depth first search


Recommended Posts

Posted (edited)

I'm writing my school project and the last thing I neef is a depth first search of a graph containing nodes, trying to find the shortest path from A to B.

Is it possible with a depth first search? Or should I use a breadth first?

 

any help appreciated

Edited by IHB
Posted
4 hours ago, Gosre said:

It's easily possible with both; just depends what kind of running time you want out of it.

 

Suggestion: Do both so that you understand the differences between the two.

 

3 hours ago, layman said:

Assuming you are talking about unweighted undirected graphs, DFS cannot be used to find the shortest path in a graph. Only BFS is capable of that.

 

It will be undirected and weighted, should I be using Dijkstra's algorithm? Does Dijkstra's work for directed graphs aswell?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...