谁能给:详细:翻译一下 这个C语言程序

来源:百度知道 编辑:UC知道 时间:2024/05/22 19:13:46
The following is a C/C++ implementation of the Floyd-Warshall algorithm for solving the all-pairs shortest path problem. The code is not guaranteed to run correctly in all cases as I have only tested it on my system, but if it does not, please let me know!
// Floyd-Warshall algorithm
//
// solves the all-pairs shortest path problem using Floyd-Warshall algorithm
// inputs: nn, number of nodes
// connectivity matrix cmat, where 0 means disconnected
// and distances are all positive. array of doubles of
// length (nn*nn).
// outputs:
// dist_mat - shortest path distances(the answer)
// pred_mat - predicate matrix, useful in reconstructing shortest routes
// Note that the caller should provide empty pointers as this
// function will handle the malloc() calls.
void fwarsh(int nn, double *cmat, double **dist_mat, int **pred_mat)
{
do

以下是炭/炭+执行该弗洛伊德- Warshall算法解决所有对最短路径问题。该守则是不能保证正确运行在所有情况下,正如我刚才只是测试我的系统上,但如果没有,请让我知道了!
/ /弗洛伊德- Warshall算法
/ /
/ /解决了所有对最短路径问题,用弗洛伊德- Warshall算法
/ /投入:神经网络,节点数目
/ /连接矩阵cmat ,其中0手段断开
/ /距离都是积极的。阵列双打的
/ /长度(神经网络*神经网络) 。
/ /输出:
/ / dist_mat -最短路径的距离内(答案)
/ / pred_mat -上游矩阵,有用的重建最短的路线
/ /注意,来电者应提供空指针,因为这
/ /功能将处理malloc ( )的来电。
无效fwarsh (诠释神经网络,双* cmat ,双** dist_mat ,诠释** pred_mat )

双*区;
诠释* pred ;
诠释,我J型, K型; / /回路柜

/ /初始化的数据结构
的dist = (双* ) malloc ( sizeof (双人) * *神经网络的神经网络) ;
pred = (诠释* ) malloc ( sizeof ( int )将神经网络* *神经网络) ;
memset (区, 0 , sizeof (双人) * *神经网络的神经网络) ;
memset ( pred , 0 , sizeof ( int )将神经网络* *神经网络) ;

/ /算法初始化
(一= 0 ;我<神经网络;我+ + ) (
为(十= 0 ; j <神经网络; J + +的) (
如果( cmat [我*神经网络+ j ] ! = 0.0 )
的dist [我*神经网络+ j ] = cmat [我*神经网络+ j ] ;
其他的
的dist [我*神经网络+ j ] = huge_val ; / /断开

如果(我