# Finding a shortest path in graph

If each edge of a graph $$G$$ is unweighted or has equal weights, then the shortest path between two nodes in that graph is the path that contains the fewest number of edges. Such a path can be obtained by BFS.

Here, I consider that each weight of the edge is the minimum of the end vertices and the weight of the path is the sum of the edges divided by the number of edges on the path.

I am unable to use BFS for such algorithm. Please suggest me a suitable known algorithm to solve such problem. The following problem is solved manually, but I wish to solve it by using some known algorithm.

• Programming questions are off-topic here. I have removed the programming part. If you want a programming solution, you can delete the post and may re-ask it on StackOverflow (though I'm not sure if it would be treated too broad there). – xskxzr Apr 25 at 13:13
• You can use Dijkstra algorithm to solve the problem with some modification while 'relaxing' edges. – Mr. Sigma. Apr 25 at 15:11
• – ryan Apr 25 at 17:55