
大家帮我看看这段matlab程序哪里出问题了呗 S=[1 1 1 1 1 1 2 2 2 2 2
展开全部
问题不少,但可这样改:
S=[1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 4 4 4 5 5 6];
E=[2 3 4 5 6 7 3 4 5 6 7 4 5 6 7 5 6 7 6 7 7];
W=[702 456 842 2396 1196 864 324 1093 2136 764 845 1137 2180 798 664 1616 1857 1706 2900 2844 396];
G=sparse(S,E,W);
G(7,7)=0;
h = view(biograph(G,[],'ShowWeights','on'));
%P=biograph(G,[],'showweights','on');
[dist,path]=graphshortestpath(G,1,7,'method','dijkstra');
set(h.nodes(path),'color',[1 0.4 0.4]);
edges=getedgesbynodeid(h,get(h.nodes(path),'id'));
set(edges,'linecolor',[1 0 0]);
set(edges,'linewidth',2.0);
%set(edges,'cinewidth',2.0);
S=[1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 4 4 4 5 5 6];
E=[2 3 4 5 6 7 3 4 5 6 7 4 5 6 7 5 6 7 6 7 7];
W=[702 456 842 2396 1196 864 324 1093 2136 764 845 1137 2180 798 664 1616 1857 1706 2900 2844 396];
G=sparse(S,E,W);
G(7,7)=0;
h = view(biograph(G,[],'ShowWeights','on'));
%P=biograph(G,[],'showweights','on');
[dist,path]=graphshortestpath(G,1,7,'method','dijkstra');
set(h.nodes(path),'color',[1 0.4 0.4]);
edges=getedgesbynodeid(h,get(h.nodes(path),'id'));
set(edges,'linecolor',[1 0 0]);
set(edges,'linewidth',2.0);
%set(edges,'cinewidth',2.0);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询