Reputation: 33
I would like to write an algorithm, which finds the shortest path between two specific vertices - source and destination - in a directed and undirected graph.
I know dijkstra's algorithm, which is used to find all the shortest paths graph. But would you modify this algorithm to find the shortest path between two vertices only?
Upvotes: 0
Views: 1658
Reputation: 2135
Just used the A* algorithm with no heuristic information. That would give you the same shortest path between the source and goal vertices that you would obtain from Dijkstra (Dijkstra is a specific case of A* when h = 0).
Regarding the implementation of the algorithm in C, there are tons of implementations available online: one, two or three.
Upvotes: 1