最短路径算法之 Floyd

| 发布     | 分类 算法  | 标签 算法 



783. 最小危险值路径

Floyd.ts

namespace ihaiu
{
    export class Floyd
    {
        constructor()
        {

        }

        // 顶点数
        nodeNum: number= 0;

        // 成本矩阵
        arcs: number[][];

        // 路径字典
        pathMap: number[][][];

        /** 获取路径 */
        public getPath(from: number, to: number): number[]
        {
            return this.pathMap[from][to];
        }


        /** 获取路径成本 */
        public getArcs(from: number, to: number): number
        {
            return this.arcs[from][to];
        }

        /** 获取路径中最大成本 */
        public getPathMaxArc(from: number, to: number): number
        {
            return this.getPathMaxArcByPath(this.getPath(from, to));
        }

        public getPathMaxArcByPath(ponts: number[]): number
        {
            let max = -1;
            for(let i = 0; i < ponts.length - 1; i ++)
            {
                let u = ponts[i];
                let v = ponts[i + 1];
                let d = this.arcs[u][v];
                if(d > max)
                {
                    max = d;
                }
            }
            return max;
        }

        /** 计算寻路 */
        public calculation(nodeNum: number, edegeNum: number, x: number[], y: number[], w: number[])
        {
            // 成本矩阵
            let arcs: number[][] = [];
            // 路径矩阵
            let path: number[][] = [];

            // 矫正顶点数量
            let num = 0;
            for(let i = 0; i < x.length; i ++)
            {  
                num = Math.max(x[i], num);
                num = Math.max(y[i], num);
            }
            nodeNum = Math.max(num + 1, nodeNum);
            this.nodeNum = nodeNum;
            


            // 初始化矩阵值
            for(let u = 0; u < nodeNum; u ++)
            {
                arcs[u] = [];
                path[u] = [];

                for(let v = 0; v < nodeNum; v ++)
                {
                    if( u != v)
                    {
                        arcs[u][v] = Number.MAX_VALUE;
                    }
                    else
                    {
                        // 同一个点,成本是0
                        arcs[u][v] = 0;
                    }
                    path[u][v] = v;
                }
            }


            this.print(arcs, nodeNum, -1);

            // 输入边
            for(let i = 0; i < x.length; i ++)
            {
                let u = x[i];
                let v = y[i];
                arcs[u][v] = w[i];
                arcs[v][u] = w[i];
            }
            
            // floyd算法
            // if ( arcs[i][k]  + arcs[k][j] < arcs[i][j] )
            //     arcs[i][j] = arcs[i][k] + arcs[k][j]

            for(let k = 0; k < nodeNum; k ++)
            {
                for(let i = 0; i < nodeNum; i ++)
                {
                    for(let j = 0; j < nodeNum; j ++)
                    {
                        if( arcs[i][k] < Number.MAX_VALUE && arcs[k][j] < Number.MAX_VALUE )
                        {
                            let d = arcs[i][k] + arcs[k][j];
                            if(d < arcs[i][j])
                            {
                                arcs[i][j] = d;
                                path[i][j] = path[i][k];
                            }
                        }
                    }
                }

                this.print(arcs, nodeNum, k);
            }
            

            // 路径字典
            let pathMap: number[][][] = this.generatePathMap(arcs, path, nodeNum);

            this.printPathMap(arcs, pathMap, nodeNum);

            this.arcs = arcs;
            this.pathMap = pathMap;
        }


        // 生存路径字典
        generatePathMap(arcs: number[][], path: number[][], nodeNum: number): number[][][]
        {
            // 路径字典
            let pathMap: number[][][] = [];
            let temp = 0;
            for(let u = 0; u < nodeNum; u ++)
            {
                pathMap[u] = [];
                let str = "";
                for(let v = 0; v < nodeNum; v ++)
                {
                    let points = pathMap[u][v]=[];
                    points.push(u);
                    temp = path[u][v];
                    while(temp != v)
                    {
                        points.push(temp);
                        temp = path[temp][v];
                    }
                    points.push(v);
                }

            }

            return pathMap;
        }

        // 打印矩阵
        print(arcs: number[][], nodeNum: number, index: number)
        {
            return;
            console.log("step of %d:", index);
            for(let u = 0; u < nodeNum; u ++)
            {
                let str = "";
                for(let v = 0; v < nodeNum; v ++)
                {
                    if(arcs[u][v] < Number.MAX_VALUE)
                    {
                        str += arcs[u][v] + "  ";
                    }
                    else
                    {
                        str +=  "∞  ";
                    }
                }
                str += "\n";
                console.log(str);
            }
        }

        // 打印路径
        printPath(arcs: number[][], path: number[][], nodeNum: number)
        {
            console.log("path:");
            let temp = 0;
            for(let u = 0; u < nodeNum; u ++)
            {
                let str = "";
                for(let v = 0; v < nodeNum; v ++)
                {
                    str += u + " -> " + v + ", weight:" + arcs[u][v] + ":" + u;

                    temp = path[u][v];
                    while(temp != v)
                    {
                        str += "->" + temp;
                        temp = path[temp][v];
                    }
                    str += "->" + v + "\n";
                }

                console.log(str);

            }
        }

        // 打印路径字典
        printPathMap(arcs: number[][], pathMap: number[][][], nodeNum: number)
        {
            console.log("pathMap:");
            let temp = 0;
            for(let u = 0; u < nodeNum; u ++)
            {
                let str = "";
                for(let v = 0; v < nodeNum; v ++)
                {
                    str += u + " -> " + v + ", weight:" + arcs[u][v] + ":" ;

                    let points = pathMap[u][v];
                    if(points.length < 2)
                        console;

                    str += points[0];
                    for(let i = 1; i < points.length - 1; i ++)
                    {
                        str += "->" + points[i];
                    }

                    str += "->" + points[points.length - 1] + "\n";
                }

                console.log(str);

            }
        }





    }
}

GameMain.ts


namespace ihaiu
{

    // 程序入口
    export class GameMain
    {
        constructor()
        {

            // this.test1();
            // this.test2();
            this.test3();
            // this.test4();
        }

        test1()
        {
            let x: number[];
            let y: number[];
            let w: number[];
            let n: number;
            let m: number;

            n = 2, m = 2, x = [0, 1], y = [1, 2], w = [1, 2]; //返回2。
             
            let floyd = new Floyd();
            floyd.calculation(n, m, x, y, w);
            console.log("The minimum risk value is: %d", floyd.getPathMaxArc(0, floyd.nodeNum - 1));
       

        }

        test2()
        {
            let x: number[];
            let y: number[];
            let w: number[];
            let n: number;
            let m: number;
            n = 3, m = 4, x = [0, 0, 1, 2], y = [1, 2, 3, 3], w = [1, 2, 3, 4]; //返回3

            let floyd = new Floyd();
            floyd.calculation(n, m, x, y, w);
            console.log("The minimum risk value is: %d", floyd.getPathMaxArc(0, floyd.nodeNum - 1));
        }

        
        test3()
        {
            let x: number[];
            let y: number[];
            let w: number[];
            let n: number;
            let m: number;
            
            n = 4, m = 5, x = [0, 1, 1, 2, 3], y = [1, 2, 3, 4, 4], w = [3, 2, 4, 2, 1]; //返回3


            let floyd = new Floyd();
            floyd.calculation(n, m, x, y, w);
            console.log("The minimum risk value is: %d", floyd.getPathMaxArc(0, floyd.nodeNum - 1));
        }

        
        test4()
        {
            let x: number[];
            let y: number[];
            let w: number[];
            let n: number;
            let m: number;
            
            n = 5, m = 7, x = [0, 0, 1, 2, 3, 3, 4], y = [1, 2, 3, 4, 4, 5, 5], w = [2, 5, 3, 4, 3, 4, 1]; //返回4


            let floyd = new Floyd();
            floyd.calculation(n, m, x, y, w);
            console.log("The minimum risk value is: %d", floyd.getPathMaxArc(0, floyd.nodeNum - 1));
        }
    }

}

setTimeout(function() 
{ 
    new ihaiu.GameMain();
}, 100);

日志


pathMap:
0 -> 0, weight:0:0->0
0 -> 1, weight:3:0->1
0 -> 2, weight:5:0->1->2
0 -> 3, weight:7:0->1->3
0 -> 4, weight:7:0->1->2->4

1 -> 0, weight:3:1->0
1 -> 1, weight:0:1->1
1 -> 2, weight:2:1->2
1 -> 3, weight:4:1->3
1 -> 4, weight:4:1->2->4

2 -> 0, weight:5:2->1->0
2 -> 1, weight:2:2->1
2 -> 2, weight:0:2->2
2 -> 3, weight:3:2->4->3
2 -> 4, weight:2:2->4

3 -> 0, weight:7:3->1->0
3 -> 1, weight:4:3->1
3 -> 2, weight:3:3->4->2
3 -> 3, weight:0:3->3
3 -> 4, weight:1:3->4

4 -> 0, weight:7:4->2->1->0
4 -> 1, weight:4:4->2->1
4 -> 2, weight:2:4->2
4 -> 3, weight:1:4->3
4 -> 4, weight:0:4->4

The minimum risk value is: 3

测试数据1


testData_1()
{
    
    let x: number[];
    let y: number[];
    let w: number[];
    let n: number;
    let m: number;

    n = 21;
    m =57;
    x = [0,6,0,2,18,10,8,20,18,10,17,4,13,0,16,11,20,2,11,20,8,4,6,2,14,0,13,20,14,11,4,21,10,6,0,18,8,11,11,1,12,20,10,12,14,0,19,18,21,16,6,2,20,0,2,4,2]
    y = [21,12,16,4,12,16,18,10,2,21,16,8,10,18,18,20,0,0,18,14,10,0,5,5,6,10,21,8,10,10,14,2,12,0,7,4,16,17,21,2,2,6,15,14,18,9,1,20,4,4,18,16,4,15,11,1,20]
    w = [935,34009,59451,45352,14875,83529,89136,67961,37503,6026,27485,218,71477,84628,13389,50306,25117,79418,41787,48302,33630,31638,46513,53891,31721,195,74893,74913,93905,51507,42081,17165,17281,90736,42233,97501,15441,68372,60001,67999,8796,27121,47312,2666,49181,15835,86363,6183,7637,93817,98081,80625,82855,55521,70109,99009,90159]


    let floyd = new Floyd();
    floyd.calculation(n, m, x, y, w);
    console.log("The minimum risk value is: %d", floyd.getPathMaxArc(0, floyd.nodeNum - 1));

}

日志

Floyd.js:151 pathMap:
Floyd.js:166 0 -> 0, weight:0:0->0
0 -> 1, weight:86099:0->21->2->1
0 -> 2, weight:18100:0->21->2
0 -> 3, weight:1.7976931348623157e+308:0->3
0 -> 4, weight:8572:0->21->4
0 -> 5, weight:71991:0->21->2->5
0 -> 6, weight:51485:0->10->12->6
0 -> 7, weight:42233:0->7
0 -> 8, weight:8790:0->21->4->8
0 -> 9, weight:15835:0->9
0 -> 10, weight:195:0->10
0 -> 11, weight:51702:0->10->11
0 -> 12, weight:17476:0->10->12
0 -> 13, weight:71672:0->10->13
0 -> 14, weight:20142:0->10->12->14
0 -> 15, weight:47507:0->10->15
0 -> 16, weight:24231:0->21->4->8->16
0 -> 17, weight:51716:0->21->4->8->16->17
0 -> 18, weight:31300:0->20->18
0 -> 19, weight:172462:0->21->2->1->19
0 -> 20, weight:25117:0->20
0 -> 21, weight:935:0->21

Floyd.js:166 1 -> 0, weight:86099:1->2->21->0
1 -> 1, weight:0:1->1
1 -> 2, weight:67999:1->2
1 -> 3, weight:1.7976931348623157e+308:1->3
1 -> 4, weight:92801:1->2->21->4
1 -> 5, weight:121890:1->2->5
1 -> 6, weight:110804:1->2->12->6
1 -> 7, weight:128332:1->2->21->0->7
1 -> 8, weight:93019:1->2->21->4->8
1 -> 9, weight:101934:1->2->21->0->9
1 -> 10, weight:86294:1->2->21->0->10
1 -> 11, weight:133457:1->2->12->18->11
1 -> 12, weight:76795:1->2->12
1 -> 13, weight:157771:1->2->21->0->10->13
1 -> 14, weight:79461:1->2->12->14
1 -> 15, weight:133606:1->2->21->0->10->15
1 -> 16, weight:105059:1->2->12->18->16
1 -> 17, weight:132544:1->2->12->18->16->17
1 -> 18, weight:91670:1->2->12->18
1 -> 19, weight:86363:1->19
1 -> 20, weight:97853:1->2->12->18->20
1 -> 21, weight:85164:1->2->21

Floyd.js:166 2 -> 0, weight:18100:2->21->0
2 -> 1, weight:67999:2->1
2 -> 2, weight:0:2->2
2 -> 3, weight:1.7976931348623157e+308:2->3
2 -> 4, weight:24802:2->21->4
2 -> 5, weight:53891:2->5
2 -> 6, weight:42805:2->12->6
2 -> 7, weight:60333:2->21->0->7
2 -> 8, weight:25020:2->21->4->8
2 -> 9, weight:33935:2->21->0->9
2 -> 10, weight:18295:2->21->0->10
2 -> 11, weight:65458:2->12->18->11
2 -> 12, weight:8796:2->12
2 -> 13, weight:89772:2->21->0->10->13
2 -> 14, weight:11462:2->12->14
2 -> 15, weight:65607:2->21->0->10->15
2 -> 16, weight:37060:2->12->18->16
2 -> 17, weight:64545:2->12->18->16->17
2 -> 18, weight:23671:2->12->18
2 -> 19, weight:154362:2->1->19
2 -> 20, weight:29854:2->12->18->20
2 -> 21, weight:17165:2->21

Floyd.js:166 3 -> 0, weight:1.7976931348623157e+308:3->0
3 -> 1, weight:1.7976931348623157e+308:3->1
3 -> 2, weight:1.7976931348623157e+308:3->2
3 -> 3, weight:0:3->3
3 -> 4, weight:1.7976931348623157e+308:3->4
3 -> 5, weight:1.7976931348623157e+308:3->5
3 -> 6, weight:1.7976931348623157e+308:3->6
3 -> 7, weight:1.7976931348623157e+308:3->7
3 -> 8, weight:1.7976931348623157e+308:3->8
3 -> 9, weight:1.7976931348623157e+308:3->9
3 -> 10, weight:1.7976931348623157e+308:3->10
3 -> 11, weight:1.7976931348623157e+308:3->11
3 -> 12, weight:1.7976931348623157e+308:3->12
3 -> 13, weight:1.7976931348623157e+308:3->13
3 -> 14, weight:1.7976931348623157e+308:3->14
3 -> 15, weight:1.7976931348623157e+308:3->15
3 -> 16, weight:1.7976931348623157e+308:3->16
3 -> 17, weight:1.7976931348623157e+308:3->17
3 -> 18, weight:1.7976931348623157e+308:3->18
3 -> 19, weight:1.7976931348623157e+308:3->19
3 -> 20, weight:1.7976931348623157e+308:3->20
3 -> 21, weight:1.7976931348623157e+308:3->21

Floyd.js:166 4 -> 0, weight:8572:4->21->0
4 -> 1, weight:92801:4->21->2->1
4 -> 2, weight:24802:4->21->2
4 -> 3, weight:1.7976931348623157e+308:4->3
4 -> 4, weight:0:4->4
4 -> 5, weight:78693:4->21->2->5
4 -> 6, weight:60057:4->21->0->10->12->6
4 -> 7, weight:50805:4->21->0->7
4 -> 8, weight:218:4->8
4 -> 9, weight:24407:4->21->0->9
4 -> 10, weight:8767:4->21->0->10
4 -> 11, weight:60274:4->21->0->10->11
4 -> 12, weight:26048:4->21->0->10->12
4 -> 13, weight:80244:4->21->0->10->13
4 -> 14, weight:28714:4->21->0->10->12->14
4 -> 15, weight:56079:4->21->0->10->15
4 -> 16, weight:15659:4->8->16
4 -> 17, weight:43144:4->8->16->17
4 -> 18, weight:29048:4->8->16->18
4 -> 19, weight:179164:4->21->2->1->19
4 -> 20, weight:33689:4->21->0->20
4 -> 21, weight:7637:4->21

Floyd.js:166 5 -> 0, weight:71991:5->2->21->0
5 -> 1, weight:121890:5->2->1
5 -> 2, weight:53891:5->2
5 -> 3, weight:1.7976931348623157e+308:5->3
5 -> 4, weight:78693:5->2->21->4
5 -> 5, weight:0:5->5
5 -> 6, weight:46513:5->6
5 -> 7, weight:114224:5->2->21->0->7
5 -> 8, weight:78911:5->2->21->4->8
5 -> 9, weight:87826:5->2->21->0->9
5 -> 10, weight:72186:5->2->21->0->10
5 -> 11, weight:119349:5->2->12->18->11
5 -> 12, weight:62687:5->2->12
5 -> 13, weight:143663:5->2->21->0->10->13
5 -> 14, weight:65353:5->2->12->14
5 -> 15, weight:119498:5->2->21->0->10->15
5 -> 16, weight:90951:5->2->12->18->16
5 -> 17, weight:118436:5->2->12->18->16->17
5 -> 18, weight:77562:5->2->12->18
5 -> 19, weight:208253:5->2->1->19
5 -> 20, weight:73634:5->6->20
5 -> 21, weight:71056:5->2->21

Floyd.js:166 6 -> 0, weight:51485:6->12->10->0
6 -> 1, weight:110804:6->12->2->1
6 -> 2, weight:42805:6->12->2
6 -> 3, weight:1.7976931348623157e+308:6->3
6 -> 4, weight:60057:6->12->10->0->21->4
6 -> 5, weight:46513:6->5
6 -> 6, weight:0:6->6
6 -> 7, weight:93718:6->12->10->0->7
6 -> 8, weight:60275:6->12->10->0->21->4->8
6 -> 9, weight:67320:6->12->10->0->9
6 -> 10, weight:51290:6->12->10
6 -> 11, weight:75091:6->20->18->11
6 -> 12, weight:34009:6->12
6 -> 13, weight:122767:6->12->10->13
6 -> 14, weight:31721:6->14
6 -> 15, weight:98602:6->12->10->15
6 -> 16, weight:46693:6->20->18->16
6 -> 17, weight:74178:6->20->18->16->17
6 -> 18, weight:33304:6->20->18
6 -> 19, weight:197167:6->12->2->1->19
6 -> 20, weight:27121:6->20
6 -> 21, weight:52420:6->12->10->0->21

Floyd.js:166 7 -> 0, weight:42233:7->0
7 -> 1, weight:128332:7->0->21->2->1
7 -> 2, weight:60333:7->0->21->2
7 -> 3, weight:1.7976931348623157e+308:7->3
7 -> 4, weight:50805:7->0->21->4
7 -> 5, weight:114224:7->0->21->2->5
7 -> 6, weight:93718:7->0->10->12->6
7 -> 7, weight:0:7->7
7 -> 8, weight:51023:7->0->21->4->8
7 -> 9, weight:58068:7->0->9
7 -> 10, weight:42428:7->0->10
7 -> 11, weight:93935:7->0->10->11
7 -> 12, weight:59709:7->0->10->12
7 -> 13, weight:113905:7->0->10->13
7 -> 14, weight:62375:7->0->10->12->14
7 -> 15, weight:89740:7->0->10->15
7 -> 16, weight:66464:7->0->21->4->8->16
7 -> 17, weight:93949:7->0->21->4->8->16->17
7 -> 18, weight:73533:7->0->20->18
7 -> 19, weight:214695:7->0->21->2->1->19
7 -> 20, weight:67350:7->0->20
7 -> 21, weight:43168:7->0->21

Floyd.js:166 8 -> 0, weight:8790:8->4->21->0
8 -> 1, weight:93019:8->4->21->2->1
8 -> 2, weight:25020:8->4->21->2
8 -> 3, weight:1.7976931348623157e+308:8->3
8 -> 4, weight:218:8->4
8 -> 5, weight:78911:8->4->21->2->5
8 -> 6, weight:60275:8->4->21->0->10->12->6
8 -> 7, weight:51023:8->4->21->0->7
8 -> 8, weight:0:8->8
8 -> 9, weight:24625:8->4->21->0->9
8 -> 10, weight:8985:8->4->21->0->10
8 -> 11, weight:60492:8->4->21->0->10->11
8 -> 12, weight:26266:8->4->21->0->10->12
8 -> 13, weight:80462:8->4->21->0->10->13
8 -> 14, weight:28932:8->4->21->0->10->12->14
8 -> 15, weight:56297:8->4->21->0->10->15
8 -> 16, weight:15441:8->16
8 -> 17, weight:42926:8->16->17
8 -> 18, weight:28830:8->16->18
8 -> 19, weight:179382:8->4->21->2->1->19
8 -> 20, weight:33907:8->4->21->0->20
8 -> 21, weight:7855:8->4->21

Floyd.js:166 9 -> 0, weight:15835:9->0
9 -> 1, weight:101934:9->0->21->2->1
9 -> 2, weight:33935:9->0->21->2
9 -> 3, weight:1.7976931348623157e+308:9->3
9 -> 4, weight:24407:9->0->21->4
9 -> 5, weight:87826:9->0->21->2->5
9 -> 6, weight:67320:9->0->10->12->6
9 -> 7, weight:58068:9->0->7
9 -> 8, weight:24625:9->0->21->4->8
9 -> 9, weight:0:9->9
9 -> 10, weight:16030:9->0->10
9 -> 11, weight:67537:9->0->10->11
9 -> 12, weight:33311:9->0->10->12
9 -> 13, weight:87507:9->0->10->13
9 -> 14, weight:35977:9->0->10->12->14
9 -> 15, weight:63342:9->0->10->15
9 -> 16, weight:40066:9->0->21->4->8->16
9 -> 17, weight:67551:9->0->21->4->8->16->17
9 -> 18, weight:47135:9->0->20->18
9 -> 19, weight:188297:9->0->21->2->1->19
9 -> 20, weight:40952:9->0->20
9 -> 21, weight:16770:9->0->21

Floyd.js:166 10 -> 0, weight:195:10->0
10 -> 1, weight:86294:10->0->21->2->1
10 -> 2, weight:18295:10->0->21->2
10 -> 3, weight:1.7976931348623157e+308:10->3
10 -> 4, weight:8767:10->0->21->4
10 -> 5, weight:72186:10->0->21->2->5
10 -> 6, weight:51290:10->12->6
10 -> 7, weight:42428:10->0->7
10 -> 8, weight:8985:10->0->21->4->8
10 -> 9, weight:16030:10->0->9
10 -> 10, weight:0:10->10
10 -> 11, weight:51507:10->11
10 -> 12, weight:17281:10->12
10 -> 13, weight:71477:10->13
10 -> 14, weight:19947:10->12->14
10 -> 15, weight:47312:10->15
10 -> 16, weight:24426:10->0->21->4->8->16
10 -> 17, weight:51911:10->0->21->4->8->16->17
10 -> 18, weight:31495:10->0->20->18
10 -> 19, weight:172657:10->0->21->2->1->19
10 -> 20, weight:25312:10->0->20
10 -> 21, weight:1130:10->0->21

Floyd.js:166 11 -> 0, weight:51702:11->10->0
11 -> 1, weight:133457:11->18->12->2->1
11 -> 2, weight:65458:11->18->12->2
11 -> 3, weight:1.7976931348623157e+308:11->3
11 -> 4, weight:60274:11->10->0->21->4
11 -> 5, weight:119349:11->18->12->2->5
11 -> 6, weight:75091:11->18->20->6
11 -> 7, weight:93935:11->10->0->7
11 -> 8, weight:60492:11->10->0->21->4->8
11 -> 9, weight:67537:11->10->0->9
11 -> 10, weight:51507:11->10
11 -> 11, weight:0:11->11
11 -> 12, weight:56662:11->18->12
11 -> 13, weight:122984:11->10->13
11 -> 14, weight:59328:11->18->12->14
11 -> 15, weight:98819:11->10->15
11 -> 16, weight:55176:11->18->16
11 -> 17, weight:68372:11->17
11 -> 18, weight:41787:11->18
11 -> 19, weight:219820:11->18->12->2->1->19
11 -> 20, weight:47970:11->18->20
11 -> 21, weight:52637:11->10->0->21

Floyd.js:166 12 -> 0, weight:17476:12->10->0
12 -> 1, weight:76795:12->2->1
12 -> 2, weight:8796:12->2
12 -> 3, weight:1.7976931348623157e+308:12->3
12 -> 4, weight:26048:12->10->0->21->4
12 -> 5, weight:62687:12->2->5
12 -> 6, weight:34009:12->6
12 -> 7, weight:59709:12->10->0->7
12 -> 8, weight:26266:12->10->0->21->4->8
12 -> 9, weight:33311:12->10->0->9
12 -> 10, weight:17281:12->10
12 -> 11, weight:56662:12->18->11
12 -> 12, weight:0:12->12
12 -> 13, weight:88758:12->10->13
12 -> 14, weight:2666:12->14
12 -> 15, weight:64593:12->10->15
12 -> 16, weight:28264:12->18->16
12 -> 17, weight:55749:12->18->16->17
12 -> 18, weight:14875:12->18
12 -> 19, weight:163158:12->2->1->19
12 -> 20, weight:21058:12->18->20
12 -> 21, weight:18411:12->10->0->21

Floyd.js:166 13 -> 0, weight:71672:13->10->0
13 -> 1, weight:157771:13->10->0->21->2->1
13 -> 2, weight:89772:13->10->0->21->2
13 -> 3, weight:1.7976931348623157e+308:13->3
13 -> 4, weight:80244:13->10->0->21->4
13 -> 5, weight:143663:13->10->0->21->2->5
13 -> 6, weight:122767:13->10->12->6
13 -> 7, weight:113905:13->10->0->7
13 -> 8, weight:80462:13->10->0->21->4->8
13 -> 9, weight:87507:13->10->0->9
13 -> 10, weight:71477:13->10
13 -> 11, weight:122984:13->10->11
13 -> 12, weight:88758:13->10->12
13 -> 13, weight:0:13->13
13 -> 14, weight:91424:13->10->12->14
13 -> 15, weight:118789:13->10->15
13 -> 16, weight:95903:13->10->0->21->4->8->16
13 -> 17, weight:123388:13->10->0->21->4->8->16->17
13 -> 18, weight:102972:13->10->0->20->18
13 -> 19, weight:244134:13->10->0->21->2->1->19
13 -> 20, weight:96789:13->10->0->20
13 -> 21, weight:72607:13->10->0->21

Floyd.js:166 14 -> 0, weight:20142:14->12->10->0
14 -> 1, weight:79461:14->12->2->1
14 -> 2, weight:11462:14->12->2
14 -> 3, weight:1.7976931348623157e+308:14->3
14 -> 4, weight:28714:14->12->10->0->21->4
14 -> 5, weight:65353:14->12->2->5
14 -> 6, weight:31721:14->6
14 -> 7, weight:62375:14->12->10->0->7
14 -> 8, weight:28932:14->12->10->0->21->4->8
14 -> 9, weight:35977:14->12->10->0->9
14 -> 10, weight:19947:14->12->10
14 -> 11, weight:59328:14->12->18->11
14 -> 12, weight:2666:14->12
14 -> 13, weight:91424:14->12->10->13
14 -> 14, weight:0:14->14
14 -> 15, weight:67259:14->12->10->15
14 -> 16, weight:30930:14->12->18->16
14 -> 17, weight:58415:14->12->18->16->17
14 -> 18, weight:17541:14->12->18
14 -> 19, weight:165824:14->12->2->1->19
14 -> 20, weight:23724:14->12->18->20
14 -> 21, weight:21077:14->12->10->0->21

Floyd.js:166 15 -> 0, weight:47507:15->10->0
15 -> 1, weight:133606:15->10->0->21->2->1
15 -> 2, weight:65607:15->10->0->21->2
15 -> 3, weight:1.7976931348623157e+308:15->3
15 -> 4, weight:56079:15->10->0->21->4
15 -> 5, weight:119498:15->10->0->21->2->5
15 -> 6, weight:98602:15->10->12->6
15 -> 7, weight:89740:15->10->0->7
15 -> 8, weight:56297:15->10->0->21->4->8
15 -> 9, weight:63342:15->10->0->9
15 -> 10, weight:47312:15->10
15 -> 11, weight:98819:15->10->11
15 -> 12, weight:64593:15->10->12
15 -> 13, weight:118789:15->10->13
15 -> 14, weight:67259:15->10->12->14
15 -> 15, weight:0:15->15
15 -> 16, weight:71738:15->10->0->21->4->8->16
15 -> 17, weight:99223:15->10->0->21->4->8->16->17
15 -> 18, weight:78807:15->10->0->20->18
15 -> 19, weight:219969:15->10->0->21->2->1->19
15 -> 20, weight:72624:15->10->0->20
15 -> 21, weight:48442:15->10->0->21

Floyd.js:166 16 -> 0, weight:24231:16->8->4->21->0
16 -> 1, weight:105059:16->18->12->2->1
16 -> 2, weight:37060:16->18->12->2
16 -> 3, weight:1.7976931348623157e+308:16->3
16 -> 4, weight:15659:16->8->4
16 -> 5, weight:90951:16->18->12->2->5
16 -> 6, weight:46693:16->18->20->6
16 -> 7, weight:66464:16->8->4->21->0->7
16 -> 8, weight:15441:16->8
16 -> 9, weight:40066:16->8->4->21->0->9
16 -> 10, weight:24426:16->8->4->21->0->10
16 -> 11, weight:55176:16->18->11
16 -> 12, weight:28264:16->18->12
16 -> 13, weight:95903:16->8->4->21->0->10->13
16 -> 14, weight:30930:16->18->12->14
16 -> 15, weight:71738:16->8->4->21->0->10->15
16 -> 16, weight:0:16->16
16 -> 17, weight:27485:16->17
16 -> 18, weight:13389:16->18
16 -> 19, weight:191422:16->18->12->2->1->19
16 -> 20, weight:19572:16->18->20
16 -> 21, weight:23296:16->8->4->21

Floyd.js:166 17 -> 0, weight:51716:17->16->8->4->21->0
17 -> 1, weight:132544:17->16->18->12->2->1
17 -> 2, weight:64545:17->16->18->12->2
17 -> 3, weight:1.7976931348623157e+308:17->3
17 -> 4, weight:43144:17->16->8->4
17 -> 5, weight:118436:17->16->18->12->2->5
17 -> 6, weight:74178:17->16->18->20->6
17 -> 7, weight:93949:17->16->8->4->21->0->7
17 -> 8, weight:42926:17->16->8
17 -> 9, weight:67551:17->16->8->4->21->0->9
17 -> 10, weight:51911:17->16->8->4->21->0->10
17 -> 11, weight:68372:17->11
17 -> 12, weight:55749:17->16->18->12
17 -> 13, weight:123388:17->16->8->4->21->0->10->13
17 -> 14, weight:58415:17->16->18->12->14
17 -> 15, weight:99223:17->16->8->4->21->0->10->15
17 -> 16, weight:27485:17->16
17 -> 17, weight:0:17->17
17 -> 18, weight:40874:17->16->18
17 -> 19, weight:218907:17->16->18->12->2->1->19
17 -> 20, weight:47057:17->16->18->20
17 -> 21, weight:50781:17->16->8->4->21

Floyd.js:166 18 -> 0, weight:31300:18->20->0
18 -> 1, weight:91670:18->12->2->1
18 -> 2, weight:23671:18->12->2
18 -> 3, weight:1.7976931348623157e+308:18->3
18 -> 4, weight:29048:18->16->8->4
18 -> 5, weight:77562:18->12->2->5
18 -> 6, weight:33304:18->20->6
18 -> 7, weight:73533:18->20->0->7
18 -> 8, weight:28830:18->16->8
18 -> 9, weight:47135:18->20->0->9
18 -> 10, weight:31495:18->20->0->10
18 -> 11, weight:41787:18->11
18 -> 12, weight:14875:18->12
18 -> 13, weight:102972:18->20->0->10->13
18 -> 14, weight:17541:18->12->14
18 -> 15, weight:78807:18->20->0->10->15
18 -> 16, weight:13389:18->16
18 -> 17, weight:40874:18->16->17
18 -> 18, weight:0:18->18
18 -> 19, weight:178033:18->12->2->1->19
18 -> 20, weight:6183:18->20
18 -> 21, weight:32235:18->20->0->21

Floyd.js:166 19 -> 0, weight:172462:19->1->2->21->0
19 -> 1, weight:86363:19->1
19 -> 2, weight:154362:19->1->2
19 -> 3, weight:1.7976931348623157e+308:19->3
19 -> 4, weight:179164:19->1->2->21->4
19 -> 5, weight:208253:19->1->2->5
19 -> 6, weight:197167:19->1->2->12->6
19 -> 7, weight:214695:19->1->2->21->0->7
19 -> 8, weight:179382:19->1->2->21->4->8
19 -> 9, weight:188297:19->1->2->21->0->9
19 -> 10, weight:172657:19->1->2->21->0->10
19 -> 11, weight:219820:19->1->2->12->18->11
19 -> 12, weight:163158:19->1->2->12
19 -> 13, weight:244134:19->1->2->21->0->10->13
19 -> 14, weight:165824:19->1->2->12->14
19 -> 15, weight:219969:19->1->2->21->0->10->15
19 -> 16, weight:191422:19->1->2->12->18->16
19 -> 17, weight:218907:19->1->2->12->18->16->17
19 -> 18, weight:178033:19->1->2->12->18
19 -> 19, weight:0:19->19
19 -> 20, weight:184216:19->1->2->12->18->20
19 -> 21, weight:171527:19->1->2->21

Floyd.js:166 20 -> 0, weight:25117:20->0
20 -> 1, weight:97853:20->18->12->2->1
20 -> 2, weight:29854:20->18->12->2
20 -> 3, weight:1.7976931348623157e+308:20->3
20 -> 4, weight:33689:20->0->21->4
20 -> 5, weight:73634:20->6->5
20 -> 6, weight:27121:20->6
20 -> 7, weight:67350:20->0->7
20 -> 8, weight:33907:20->0->21->4->8
20 -> 9, weight:40952:20->0->9
20 -> 10, weight:25312:20->0->10
20 -> 11, weight:47970:20->18->11
20 -> 12, weight:21058:20->18->12
20 -> 13, weight:96789:20->0->10->13
20 -> 14, weight:23724:20->18->12->14
20 -> 15, weight:72624:20->0->10->15
20 -> 16, weight:19572:20->18->16
20 -> 17, weight:47057:20->18->16->17
20 -> 18, weight:6183:20->18
20 -> 19, weight:184216:20->18->12->2->1->19
20 -> 20, weight:0:20->20
20 -> 21, weight:26052:20->0->21

Floyd.js:166 21 -> 0, weight:935:21->0
21 -> 1, weight:85164:21->2->1
21 -> 2, weight:17165:21->2
21 -> 3, weight:1.7976931348623157e+308:21->3
21 -> 4, weight:7637:21->4
21 -> 5, weight:71056:21->2->5
21 -> 6, weight:52420:21->0->10->12->6
21 -> 7, weight:43168:21->0->7
21 -> 8, weight:7855:21->4->8
21 -> 9, weight:16770:21->0->9
21 -> 10, weight:1130:21->0->10
21 -> 11, weight:52637:21->0->10->11
21 -> 12, weight:18411:21->0->10->12
21 -> 13, weight:72607:21->0->10->13
21 -> 14, weight:21077:21->0->10->12->14
21 -> 15, weight:48442:21->0->10->15
21 -> 16, weight:23296:21->4->8->16
21 -> 17, weight:50781:21->4->8->16->17
21 -> 18, weight:32235:21->0->20->18
21 -> 19, weight:171527:21->2->1->19
21 -> 20, weight:26052:21->0->20
21 -> 21, weight:0:21->21

GameMain.js:69 The minimum risk value is: 935

测试数据2




testData_2()
{
    
    let x: number[];
    let y: number[];
    let w: number[];
    let n: number;
    let m: number;

    n = 15;
    m = 119;
    x = [0,0,3,0,1,5,5,0,11,0,1,5,12,2,12,3,14,9,4,1,2,10,0,6,10,2,2,8,9,13,4,14,13,7,0,9,8,0,2,0,13,12,11,5,14,14,0,3,10,5,4,12,12,1,14,10,10,12,5,6,15,11,2,1,3,9,11,12,10,14,6,10,12,1,4,1,8,10,3,9,13,4,10,6,4,6,3,13,7,9,13,3,4,7,7,15,2,6,6,1,15,15,2,3,6,14,9,11,2,5,15,2,7,15,3,1,5,1,13]
    y = [15,7,8,11,0,0,4,10,2,9,4,14,4,12,8,1,8,2,8,5,0,4,8,11,13,4,8,10,7,14,6,6,6,8,13,13,5,12,14,14,8,7,14,10,12,15,6,0,2,12,0,11,10,8,7,1,11,15,11,8,5,13,13,14,11,12,7,3,7,10,12,3,13,15,11,11,9,6,5,6,15,9,15,15,14,3,15,7,4,10,5,4,13,1,3,8,3,5,1,12,4,9,15,14,7,9,5,8,6,7,11,1,2,7,9,9,2,13,3]
    w = [98737,25594,93437,6242,4021,85593,49106,80313,86433,7439,63281,66498,11065,55961,40850,36571,53394,48551,75802,45577,50801,16246,99905,12301,95430,46641,15151,66858,26256,61817,26241,53249,36038,17433,15939,39647,3031,71721,71546,40145,16385,42928,74959,29414,38973,10676,72912,82047,22241,87633,99101,23241,42017,79035,23283,37164,57041,66185,47929,88161,55180,63622,52383,94641,81217,83186,58081,57311,55057,68722,84161,29662,96779,86373,71657,65761,78376,52239,6321,11433,27204,74425,99619,71926,91136,90313,26470,64601,61665,62077,75091,33121,69401,49817,47741,90683,8929,78939,52716,52917,96033,40497,65485,75320,1461,19905,37603,4353,39366,70546,30517,72611,71431,86347,57675,86309,71521,73945,67151]

    let floyd = new Floyd();
    floyd.calculation(n, m, x, y, w);
    console.log("The minimum risk value is: %d", floyd.getPathMaxArc(0, floyd.nodeNum - 1));

}

日志

Floyd.js:151 pathMap:
Floyd.js:166 0 -> 0, weight:0:0->0
0 -> 1, weight:4021:0->1
0 -> 2, weight:25746:0->11->8->2
0 -> 3, weight:19947:0->11->8->5->3
0 -> 4, weight:40548:0->11->12->4
0 -> 5, weight:13626:0->11->8->5
0 -> 6, weight:18543:0->11->6
0 -> 7, weight:20004:0->11->6->7
0 -> 8, weight:10595:0->11->8
0 -> 9, weight:7439:0->9
0 -> 10, weight:41185:0->1->10
0 -> 11, weight:6242:0->11
0 -> 12, weight:29483:0->11->12
0 -> 13, weight:15939:0->13
0 -> 14, weight:27344:0->9->14
0 -> 15, weight:36759:0->11->15

Floyd.js:166 1 -> 0, weight:4021:1->0
1 -> 1, weight:0:1->1
1 -> 2, weight:29767:1->0->11->8->2
1 -> 3, weight:23968:1->0->11->8->5->3
1 -> 4, weight:44569:1->0->11->12->4
1 -> 5, weight:17647:1->0->11->8->5
1 -> 6, weight:22564:1->0->11->6
1 -> 7, weight:24025:1->0->11->6->7
1 -> 8, weight:14616:1->0->11->8
1 -> 9, weight:11460:1->0->9
1 -> 10, weight:37164:1->10
1 -> 11, weight:10263:1->0->11
1 -> 12, weight:33504:1->0->11->12
1 -> 13, weight:19960:1->0->13
1 -> 14, weight:31365:1->0->9->14
1 -> 15, weight:40780:1->0->11->15

Floyd.js:166 2 -> 0, weight:25746:2->8->11->0
2 -> 1, weight:29767:2->8->11->0->1
2 -> 2, weight:0:2->2
2 -> 3, weight:8929:2->3
2 -> 4, weight:38487:2->10->4
2 -> 5, weight:15250:2->3->5
2 -> 6, weight:31805:2->8->11->6
2 -> 7, weight:32584:2->8->7
2 -> 8, weight:15151:2->8
2 -> 9, weight:33185:2->8->11->0->9
2 -> 10, weight:22241:2->10
2 -> 11, weight:19504:2->8->11
2 -> 12, weight:42745:2->8->11->12
2 -> 13, weight:31536:2->8->13
2 -> 14, weight:46075:2->3->15->14
2 -> 15, weight:35399:2->3->15

Floyd.js:166 3 -> 0, weight:19947:3->5->8->11->0
3 -> 1, weight:23968:3->5->8->11->0->1
3 -> 2, weight:8929:3->2
3 -> 3, weight:0:3->3
3 -> 4, weight:33121:3->4
3 -> 5, weight:6321:3->5
3 -> 6, weight:26006:3->5->8->11->6
3 -> 7, weight:26785:3->5->8->7
3 -> 8, weight:9352:3->5->8
3 -> 9, weight:27386:3->5->8->11->0->9
3 -> 10, weight:29662:3->10
3 -> 11, weight:13705:3->5->8->11
3 -> 12, weight:36946:3->5->8->11->12
3 -> 13, weight:25737:3->5->8->13
3 -> 14, weight:37146:3->15->14
3 -> 15, weight:26470:3->15

Floyd.js:166 4 -> 0, weight:40548:4->12->11->0
4 -> 1, weight:44569:4->12->11->0->1
4 -> 2, weight:38487:4->10->2
4 -> 3, weight:33121:4->3
4 -> 4, weight:0:4->4
4 -> 5, weight:39442:4->3->5
4 -> 6, weight:26241:4->6
4 -> 7, weight:27702:4->6->7
4 -> 8, weight:38659:4->12->11->8
4 -> 9, weight:37674:4->6->9
4 -> 10, weight:16246:4->10
4 -> 11, weight:34306:4->12->11
4 -> 12, weight:11065:4->12
4 -> 13, weight:55044:4->12->11->8->13
4 -> 14, weight:50038:4->12->14
4 -> 15, weight:59591:4->3->15

Floyd.js:166 5 -> 0, weight:13626:5->8->11->0
5 -> 1, weight:17647:5->8->11->0->1
5 -> 2, weight:15250:5->3->2
5 -> 3, weight:6321:5->3
5 -> 4, weight:39442:5->3->4
5 -> 5, weight:0:5->5
5 -> 6, weight:19685:5->8->11->6
5 -> 7, weight:20464:5->8->7
5 -> 8, weight:3031:5->8
5 -> 9, weight:21065:5->8->11->0->9
5 -> 10, weight:29414:5->10
5 -> 11, weight:7384:5->8->11
5 -> 12, weight:30625:5->8->11->12
5 -> 13, weight:19416:5->8->13
5 -> 14, weight:40970:5->8->11->0->9->14
5 -> 15, weight:32791:5->3->15

Floyd.js:166 6 -> 0, weight:18543:6->11->0
6 -> 1, weight:22564:6->11->0->1
6 -> 2, weight:31805:6->11->8->2
6 -> 3, weight:26006:6->11->8->5->3
6 -> 4, weight:26241:6->4
6 -> 5, weight:19685:6->11->8->5
6 -> 6, weight:0:6->6
6 -> 7, weight:1461:6->7
6 -> 8, weight:16654:6->11->8
6 -> 9, weight:11433:6->9
6 -> 10, weight:42487:6->4->10
6 -> 11, weight:12301:6->11
6 -> 12, weight:35542:6->11->12
6 -> 13, weight:33039:6->11->8->13
6 -> 14, weight:24744:6->7->14
6 -> 15, weight:35420:6->7->14->15

Floyd.js:166 7 -> 0, weight:20004:7->6->11->0
7 -> 1, weight:24025:7->6->11->0->1
7 -> 2, weight:32584:7->8->2
7 -> 3, weight:26785:7->8->5->3
7 -> 4, weight:27702:7->6->4
7 -> 5, weight:20464:7->8->5
7 -> 6, weight:1461:7->6
7 -> 7, weight:0:7->7
7 -> 8, weight:17433:7->8
7 -> 9, weight:12894:7->6->9
7 -> 10, weight:43948:7->6->4->10
7 -> 11, weight:13762:7->6->11
7 -> 12, weight:37003:7->6->11->12
7 -> 13, weight:33818:7->8->13
7 -> 14, weight:23283:7->14
7 -> 15, weight:33959:7->14->15

Floyd.js:166 8 -> 0, weight:10595:8->11->0
8 -> 1, weight:14616:8->11->0->1
8 -> 2, weight:15151:8->2
8 -> 3, weight:9352:8->5->3
8 -> 4, weight:38659:8->11->12->4
8 -> 5, weight:3031:8->5
8 -> 6, weight:16654:8->11->6
8 -> 7, weight:17433:8->7
8 -> 8, weight:0:8->8
8 -> 9, weight:18034:8->11->0->9
8 -> 10, weight:32445:8->5->10
8 -> 11, weight:4353:8->11
8 -> 12, weight:27594:8->11->12
8 -> 13, weight:16385:8->13
8 -> 14, weight:37939:8->11->0->9->14
8 -> 15, weight:34870:8->11->15

Floyd.js:166 9 -> 0, weight:7439:9->0
9 -> 1, weight:11460:9->0->1
9 -> 2, weight:33185:9->0->11->8->2
9 -> 3, weight:27386:9->0->11->8->5->3
9 -> 4, weight:37674:9->6->4
9 -> 5, weight:21065:9->0->11->8->5
9 -> 6, weight:11433:9->6
9 -> 7, weight:12894:9->6->7
9 -> 8, weight:18034:9->0->11->8
9 -> 9, weight:0:9->9
9 -> 10, weight:48624:9->0->1->10
9 -> 11, weight:13681:9->0->11
9 -> 12, weight:36922:9->0->11->12
9 -> 13, weight:23378:9->0->13
9 -> 14, weight:19905:9->14
9 -> 15, weight:30581:9->14->15

Floyd.js:166 10 -> 0, weight:41185:10->1->0
10 -> 1, weight:37164:10->1
10 -> 2, weight:22241:10->2
10 -> 3, weight:29662:10->3
10 -> 4, weight:16246:10->4
10 -> 5, weight:29414:10->5
10 -> 6, weight:42487:10->4->6
10 -> 7, weight:43948:10->4->6->7
10 -> 8, weight:32445:10->5->8
10 -> 9, weight:48624:10->1->0->9
10 -> 10, weight:0:10->10
10 -> 11, weight:36798:10->5->8->11
10 -> 12, weight:27311:10->4->12
10 -> 13, weight:48830:10->5->8->13
10 -> 14, weight:66284:10->4->12->14
10 -> 15, weight:56132:10->3->15

Floyd.js:166 11 -> 0, weight:6242:11->0
11 -> 1, weight:10263:11->0->1
11 -> 2, weight:19504:11->8->2
11 -> 3, weight:13705:11->8->5->3
11 -> 4, weight:34306:11->12->4
11 -> 5, weight:7384:11->8->5
11 -> 6, weight:12301:11->6
11 -> 7, weight:13762:11->6->7
11 -> 8, weight:4353:11->8
11 -> 9, weight:13681:11->0->9
11 -> 10, weight:36798:11->8->5->10
11 -> 11, weight:0:11->11
11 -> 12, weight:23241:11->12
11 -> 13, weight:20738:11->8->13
11 -> 14, weight:33586:11->0->9->14
11 -> 15, weight:30517:11->15

Floyd.js:166 12 -> 0, weight:29483:12->11->0
12 -> 1, weight:33504:12->11->0->1
12 -> 2, weight:42745:12->11->8->2
12 -> 3, weight:36946:12->11->8->5->3
12 -> 4, weight:11065:12->4
12 -> 5, weight:30625:12->11->8->5
12 -> 6, weight:35542:12->11->6
12 -> 7, weight:37003:12->11->6->7
12 -> 8, weight:27594:12->11->8
12 -> 9, weight:36922:12->11->0->9
12 -> 10, weight:27311:12->4->10
12 -> 11, weight:23241:12->11
12 -> 12, weight:0:12->12
12 -> 13, weight:43979:12->11->8->13
12 -> 14, weight:38973:12->14
12 -> 15, weight:49649:12->14->15

Floyd.js:166 13 -> 0, weight:15939:13->0
13 -> 1, weight:19960:13->0->1
13 -> 2, weight:31536:13->8->2
13 -> 3, weight:25737:13->8->5->3
13 -> 4, weight:55044:13->8->11->12->4
13 -> 5, weight:19416:13->8->5
13 -> 6, weight:33039:13->8->11->6
13 -> 7, weight:33818:13->8->7
13 -> 8, weight:16385:13->8
13 -> 9, weight:23378:13->0->9
13 -> 10, weight:48830:13->8->5->10
13 -> 11, weight:20738:13->8->11
13 -> 12, weight:43979:13->8->11->12
13 -> 13, weight:0:13->13
13 -> 14, weight:37880:13->15->14
13 -> 15, weight:27204:13->15

Floyd.js:166 14 -> 0, weight:27344:14->9->0
14 -> 1, weight:31365:14->9->0->1
14 -> 2, weight:46075:14->15->3->2
14 -> 3, weight:37146:14->15->3
14 -> 4, weight:50038:14->12->4
14 -> 5, weight:40970:14->9->0->11->8->5
14 -> 6, weight:24744:14->7->6
14 -> 7, weight:23283:14->7
14 -> 8, weight:37939:14->9->0->11->8
14 -> 9, weight:19905:14->9
14 -> 10, weight:66284:14->12->4->10
14 -> 11, weight:33586:14->9->0->11
14 -> 12, weight:38973:14->12
14 -> 13, weight:37880:14->15->13
14 -> 14, weight:0:14->14
14 -> 15, weight:10676:14->15

Floyd.js:166 15 -> 0, weight:36759:15->11->0
15 -> 1, weight:40780:15->11->0->1
15 -> 2, weight:35399:15->3->2
15 -> 3, weight:26470:15->3
15 -> 4, weight:59591:15->3->4
15 -> 5, weight:32791:15->3->5
15 -> 6, weight:35420:15->14->7->6
15 -> 7, weight:33959:15->14->7
15 -> 8, weight:34870:15->11->8
15 -> 9, weight:30581:15->14->9
15 -> 10, weight:56132:15->3->10
15 -> 11, weight:30517:15->11
15 -> 12, weight:49649:15->14->12
15 -> 13, weight:27204:15->13
15 -> 14, weight:10676:15->14
15 -> 15, weight:0:15->15

GameMain.js:85 The minimum risk value is: 30517


上一篇: Unity Shader 学习笔记(010)RenderSteup渲染设置之固定着色器命令
下一篇: 最小生成树之Prim普里姆算法