算法实验三最短路径(10)

2020-12-24 22:54

}

public static int Min(int a,int b){ if(a>b)return b; else return a; }

public static void main(String[] args)throws Exception {

int[][] W1 = { { 0, 20, 15, 1000, 1000, 1000 }, { 2, 0, 1000, 1000, 10,

30 },

{ 1000, 4, 0, 1000, 1000, 10 }, { 1000, 1000, 2, 0, 1000,

1000 },

{ 1000, 1000, 1000, 15, 0, 1000 }, { 1000, 1000, 1000, 4, 10, 0 } };//

建立一个权值矩阵

int[][]distance=new int[W1[0].length][W1[0].length];

distance=Floyd(W1);

for (int i = 0; i < distance.length; i++) {

File file = new File("E:\\Workspace\\Floyd\\floydoutput1.txt"); //

for (int j = 0; j < distance[i].length; j++) {

System.out.print(distance[i][j] + " "); } System.out.println(); }

存放数组数据的文件

FileWriter out = new FileWriter(file); //文件写入流

//将数组中的数据写入到文件中。每行各数据之间TAB间隔 for(int i=0;i<distance[0].length;i++){ for(int j=0;j<distance[0].length;j++){ out.write(distance[i][j]+"\t");} out.write("\n");}

out.flush();


算法实验三最短路径(10).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:SVD(奇异值分解)算法及其评估

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: