算法导论-单源最短路径

关注
算法导论-单源最短路径www.shan-machinery.compublic class Dijkstra {    static int M=10000;    public static void main(String[] args) {        // TODO Auto-generated method stub        int[][] weight1 = {                {0,3,2000,7,M},                {3,0,4,2,M},                {M,4,0,5,4},                {7,2,5,0,6},                    {M,M,4,6,0}        };        //有向图的矩阵表示,数值表示权重        int[][] weight2 = {                {0,10,M,30,100},                {M,0,50,M,M},                {M,M,0,M,10},                {M,M,20,0,60},                {M,M,M,M,0}        };        int start=0;//起点s        int[] shortPath = Dijsktra(weight2,start);                for(int i = 0;i https://www.shan-machinery.com