简体   繁体   中英

connected weighted directed graph with diameter k< |V|, find the shortest path

You are given a connected weighted directed graph G = (V,E) with diameter k < |V| and I am trying to find a way to give the most efficient (running time) algorithm to find the shortest path from S (source) to any node v in V. I cant figure it out how to use the given diameter to make the algorithm more efficient?

Thanks for you help.

The diameter doesn't help at all, you can ignore it. Take an extreme example, a fully connected graph. It's diameter will be 1 (every node is just one link away).

However you can imagine that all the edges have a very large weight except for a path like 1->2->3->4->5->..->N that have a very low weight, so the path will have to go through the low cost edges and therefore through all the nodes.

If the diameter is expressed in weight you can optimize dijkstra to ignore any update that grows over the diameter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM