开发者

Floyd Warshall reconstruct path

开发者 https://www.devze.com 2023-03-02 01:36 出处:网络
I want to reconstruct the path from source to destination vertex in this graph problem. How can I store the path, and how can I retrieve it after I have found the minimal cost from s to d?

I want to reconstruct the path from source to destination vertex in this graph problem.

How can I store the path, and how can I retrieve it after I have found the minimal cost from s to d?

Please help开发者_如何学运维 me to find a simple answer?

For example at the point,

adjmat[i][j] = Math.min(adjMat[i][j],adjMat[i][k]+adjMat[k][j]);

I need to add a path and I need to retrieve it.


The Wikipedia article about the Floyd-Warshall algorithm provides an explanation and pseudocode for your problem.


Use optimal matrix with Floyd-Warshall Algorithm to reconstruct path. It construct path simulatneously. Refer to Introduction to graph theory- by Narsingh Deo for actual algorithm

0

精彩评论

暂无评论...
验证码 换一张
取 消