用matlab软件求最短路实例2

上传人:wt****50 文档编号:37277051 上传时间:2018-04-13 格式:DOC 页数:6 大小:70KB
返回 下载 相关 举报
用matlab软件求最短路实例2_第1页
第1页 / 共6页
用matlab软件求最短路实例2_第2页
第2页 / 共6页
用matlab软件求最短路实例2_第3页
第3页 / 共6页
用matlab软件求最短路实例2_第4页
第4页 / 共6页
用matlab软件求最短路实例2_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《用matlab软件求最短路实例2》由会员分享,可在线阅读,更多相关《用matlab软件求最短路实例2(6页珍藏版)》请在金锄头文库上搜索。

1、用用 MATLAB 软软件求最短路件求最短路实实例例 2试用 MATLAB 软件计算有向图中 v1 到 v9 的最短路。v9v1v2v3v4v5v6v7v8333331 1222445运筹学课程设计实验报告 06 信息管理与信息系统(中美合作) 顾真皓 06130801322解:解:w=ones(9);w=inf*w; for i=1:9w(i,i)=0;end w(1,2)=3;w(1,4)=4; w(2,3)=3;w(2,5)=2;w(2,6)=3; w(3,9)=5; w(4,7)=3; w(5,6)=3; w(6,9)=1;w(6,7)=1; w(7,8)=2;w(7,9)=2; w(

2、8,9)=4; p=log(8)/log(2) %向上(大的方向)取整向上(大的方向)取整p =3 w1=w运筹学课程设计实验报告 06 信息管理与信息系统(中美合作) 顾真皓 06130801323w1 =0 3 Inf 4 Inf Inf Inf Inf InfInf 0 3 Inf 2 3 Inf Inf InfInf Inf 0 Inf Inf Inf Inf Inf 5Inf Inf Inf 0 Inf Inf 3 Inf InfInf Inf Inf Inf 0 3 Inf Inf InfInf Inf Inf Inf Inf 0 1 Inf 1Inf Inf Inf Inf In

3、f Inf 0 2 2Inf Inf Inf Inf Inf Inf Inf 0 4Inf Inf Inf Inf Inf Inf Inf Inf 0 w2=fld(9,w)w2 =0 3 6 4 5 6 7 Inf InfInf 0 3 Inf 2 3 4 Inf 4Inf Inf 0 Inf Inf Inf Inf Inf 5Inf Inf Inf 0 Inf Inf 3 5 5Inf Inf Inf Inf 0 3 4 Inf 4Inf Inf Inf Inf Inf 0 1 3 1运筹学课程设计实验报告 06 信息管理与信息系统(中美合作) 顾真皓 06130801324Inf Inf

4、 Inf Inf Inf Inf 0 2 2Inf Inf Inf Inf Inf Inf Inf 0 4Inf Inf Inf Inf Inf Inf Inf Inf 0 w3=fld(9,w2)w3 =0 3 6 4 5 6 7 9 7Inf 0 3 Inf 2 3 4 6 4Inf Inf 0 Inf Inf Inf Inf Inf 5Inf Inf Inf 0 Inf Inf 3 5 5Inf Inf Inf Inf 0 3 4 6 4Inf Inf Inf Inf Inf 0 1 3 1Inf Inf Inf Inf Inf Inf 0 2 2Inf Inf Inf Inf Inf

5、Inf Inf 0 4Inf Inf Inf Inf Inf Inf Inf Inf 0functionci,cj,dij=stlin(n,i,j,d) %求最短路的路径求最短路的路径 ci=d(i,j)-d(i,:);cj=d(:,j);dij=d(i,j);function y=fld(n,x) %求最短路求最短路 for r=1:n运筹学课程设计实验报告 06 信息管理与信息系统(中美合作) 顾真皓 06130801325for i=1:nfor j=1:np(j)=x(i,j)+x(j,r);endy(r,i)=min(p);endend c1,c9,d19=stlin(9,1,9,w3)c1 =7 4 1 3 2 1 0 -2 0运筹学课程设计实验报告 06 信息管理与信息系统(中美合作) 顾真皓 06130801326c9 =745541240d19 =7

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 生活休闲 > 社会民生

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号