views:

102

answers:

2

I have a very, very large graph, and I want to find the shortest path from one vertex to another. The graph is directed and unweighted.

I have considered using some modification of Dijkstra's algorithm, but I usually use that for weighted undirected graphs.

So then my other thought was to use a DFS, since I can treat all the weights as one.

Any suggestions? a

EDIT: Ok, I meant to say BFS, I'm sorry.

+1  A: 

Have you tried using A*?

David
There is absolutely no point using A* here with an unweighted graph… it would do nothing better than a breadth-first search, and possibly take more time (unless you do it properly, in which case it *is* a breadth-first search).
ShreevatsaR
I agree with ShreevatsaR :)
Dimitris Andreou
+5  A: 

Try a BFS instead.

(Note that Dijkstra's algorithm works perfectly fine for unweighted directed graphs — it just happens that in the unweighted case, doing it smartly is essentially equivalent to a breadth-first search.)

Dimitris Andreou
I've merged the comment from my answer into this and deleted mine; feel free to remove the comment if you (don't) like. :-)
ShreevatsaR