matlab 中有这样一个函数:[dist,path,pred] = graphshortestpath(G,S,T),
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/11 12:49:57
matlab 中有这样一个函数:[dist,path,pred] = graphshortestpath(G,S,T),
它表示从S到每个节点的最短路径中,目标节点的先驱,即目标节点的前面一个节点.
例如下面的代码.你看每一组返回值中,path向量的倒数第二个数,跟pred中相应节点的数字是不是相同.即依次抽取path的倒数第二个值,组成了pred数组.
>> W = [.41 .99 .51 .32 .15 .45 .38 .32 .36 .29 .21];
>> DG = sparse([6 1 2 2 3 4 4 5 5 6 1],[2 6 3 5 4 1 6 3 4 3 5],W);
>> [dist,path,pred] = graphshortestpath(DG,1,1)
dist =
0
path =
1
pred =
0 6 5 5 1 4
>> [dist,path,pred] = graphshortestpath(DG,1,2)
dist =
1.3600
path =
1 5 4 6 2
pred =
0 6 5 5 1 4
>> [dist,path,pred] = graphshortestpath(DG,1,3)
dist =
0.5300
path =
1 5 3
pred =
0 6 5 5 1 4
>> [dist,path,pred] = graphshortestpath(DG,1,4)
dist =
0.5700
path =
1 5 4
pred =
0 6 5 5 1 4
>> [dist,path,pred] = graphshortestpath(DG,1,5)
dist =
0.2100
path =
1 5
pred =
0 6 5 5 1 4
>> [dist,path,pred] = graphshortestpath(DG,1,6)
dist =
0.9500
path =
1 5 4 6
pred =
0 6 5 5 1 4
例如下面的代码.你看每一组返回值中,path向量的倒数第二个数,跟pred中相应节点的数字是不是相同.即依次抽取path的倒数第二个值,组成了pred数组.
>> W = [.41 .99 .51 .32 .15 .45 .38 .32 .36 .29 .21];
>> DG = sparse([6 1 2 2 3 4 4 5 5 6 1],[2 6 3 5 4 1 6 3 4 3 5],W);
>> [dist,path,pred] = graphshortestpath(DG,1,1)
dist =
0
path =
1
pred =
0 6 5 5 1 4
>> [dist,path,pred] = graphshortestpath(DG,1,2)
dist =
1.3600
path =
1 5 4 6 2
pred =
0 6 5 5 1 4
>> [dist,path,pred] = graphshortestpath(DG,1,3)
dist =
0.5300
path =
1 5 3
pred =
0 6 5 5 1 4
>> [dist,path,pred] = graphshortestpath(DG,1,4)
dist =
0.5700
path =
1 5 4
pred =
0 6 5 5 1 4
>> [dist,path,pred] = graphshortestpath(DG,1,5)
dist =
0.2100
path =
1 5
pred =
0 6 5 5 1 4
>> [dist,path,pred] = graphshortestpath(DG,1,6)
dist =
0.9500
path =
1 5 4 6
pred =
0 6 5 5 1 4
matlab 中有这样一个函数:[dist,path,pred] = graphshortestpath(G,S,T),
matlab中如何改变矩阵维数 比如:有这样一个4维矩阵,H=[U S N T]
matlab中,t=0:2000,函数值x为一个固定值5,这样的函数如何构造?
matlab中有没有这样的函数?
matlab中 S函数 显示没有定义变量t是怎么回事
跪求解释 Matlab中graphshortestpath的具体用法 需要什么参数,矩阵,得到什么结果?
matlab中subs(g,'s',
【Matlab】Matlab中如何编写S函数
matlab语句提问有这样一个函数:function DTMFlabel = SegmentDTMF(sigIn,thr
高一函数题:证明如果f(t)=t/(1+t),g(t)=t/(1-t),证明:f(t) - g(t) = -2g(t&s
matlab中,我想建立一个如“f(i)=x^i”这样的函数表达式,方便带入i.
如何在Matlab中实现Z变换 例如:G(s)=K/(s(s+a))