zoukankan      html  css  js  c++  java
  • matlab 单元最短路 Dijkstra算法 无向图

    W = [2 8 1 1 6 5 1 2 3 6 4 9 3 7 9];
    S = [0 0 0 1 1 3 3 3 5 5 6 4 6 2 2];S=S+1;
    T = [1 3 2 4 3 4 5 6 4 7 5 7 7 3 6];T=T+1;
    IDS={'u0','u1','u2','u3','u4','u5','u6','u7'};
    DG = sparse(S,T,W,8,8)%求稀疏矩阵
    UG =tril(DG+DG')%取矩阵和转置矩阵和的下三角矩阵。
    bg=biograph(UG,IDS,'ShowArrows','off','ShowWeights','on');%构建biograph对象,设置参数
    set(bg.nodes,'shape','circle','color',[1,1,0],'linecolor',[0,0,1]);
    set(bg.nodes,'textColor',[0,0,0],'lineWidth',2,'fontsize',9);
    set(bg,'EdgeType','straight');%设置连线为直线 
    get(bg.nodes,'position');%获取节点位置
    dolayout(bg);
    bg.nodes(1).position=[9,100];
    bg.nodes(2).position=[101,182];
    bg.nodes(3).position=[101,10];
    bg.nodes(4).position=[101,100];
    bg.nodes(5).position=[214,182];
    bg.nodes(6).position=[214,100];
    bg.nodes(7).position=[214,10];
    bg.nodes(8).position=[303,100];
    dolayout(bg,'pathsonly',true);
    t = view(bg)
    [dist,path,pred] = graphshortestpath(UG,1,8,'directed',false)%Dijkstra求最短路
  • 相关阅读:
    CSS3媒体查询总结
    关于前端学习规划
    开发技术版本
    Visual Studio 问题汇总
    asp.net web core 开发问题汇总(1)
    asp.net web core 部署问题汇总
    报表平台需求文档(V0.0.0.1)
    Git使用说明
    派生类
    cin、cout的重载
  • 原文地址:https://www.cnblogs.com/zxhyxiao/p/9315917.html
Copyright © 2011-2022 走看看