0
votes

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?

1
The answer to your question is: No, you would not modify it. You just stop execution once you pull the source node from the queue. - SaiBot

1 Answers

1
votes

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.