-
大小: 6KB文件类型: .m金币: 1下载: 0 次发布日期: 2023-12-02
- 语言: Matlab
- 标签: matlab shortest paths dijkstraties
资源简介
matlab程序,找出网络中确定两点间的所有最短路径。
注意:输入的矩阵为邻接矩阵。如果两点间没有相邻,请将参数设较大数,例如点i和点j间没有相邻,则将Aij设为999。
代码片段和文件信息
function [sp spcost] = dijkstraties(matriz_costo s d)
%
% This function is built on the dijkstra.m function written by Jorge
% Ignacia Barrera Alviar (April 2008) available at
% http://www.mathworks.com/matlabcentral/fileexchange under file ID 5550.
% Modification records all ties for shortest path.
%
% The inputs are the same is with the original code. Because the original
% documentation is not clear with respect to the array matriz_costo
% matriz_costo is an n x n adjacency matrix where the (ij) element
% represents the cost of traveling along the edge linking node i to node j.
% One should not set any elements to 0 (unless your intention is that there
% is no cost to travel along the corresponding edge). Typically I choose
% some arbitrarily large number for all elements representing non-edges.
%
% I have also been trying unsuccessfully so modify the code so that
% instead of adding the costs of each edge to compute total path costs
% the cost of traveling along edges e1 and 2 is equal to 1 - (1-coste1)(1-coste2).
% This formulation is useful if the costs represent hazard rates and the
% goal is find the path that minimizes the probability of loss from node s
% to node d (or maximizes the probability of survival).
%
% My attempt to modify the code in the latter manner is commented out.
% Code to be removed is commented “Switch # (add)“ and code to substituted
% in its place is labeled “Switch # (mult)“. If one were to output the the
% prev array one would see that it isn‘t
% generated properly which the code switch is performed. However the dist
% vector does appear to be generated correctly.
%
% Any help in getting the code to work properly while computing costs
% as 1 minus the product of survival probabilities would be greatly
% appreciated.
%
% -David Blum
% dmblum@gmail.com
%
%
%
%%%%%%%%%% Original documentation %%%%%%%%%%%%%%%%%%
%
% This is an implementation of the dijkstra磗 algorithm wich finds the
% minimal cost path between two nodes. It磗 supoussed to solve the problem on
% possitive weighted instances.
% the inputs of the algorithm are:
%farthestNode: the farthest node to reach for each node after performing
% the routing;
% n: the number of nodes in the network;
% s: source node index;
% d: destination node index;
%For information about this algorithm visit:
%http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
%This implementatios is inspired by the Xiaodong Wang‘s implememtation of
%the dijkstra‘s algorithm available at
%http://www.mathworks.com/matlabcentral/fileexchange
%file ID 5550
%Author: Jorge Ignacio Barrera Alviar. April/2007
n=size(matriz_costo1);
S(1:n) = 0; %s vector set of visited vectors
dist(1:n) = inf; % it stores the shortest distance between the source node and any other node;
prev = cell(1n);
% prev(1:n) = n+1; % Previous node informs about the best previous node known to reach each network node
prev
- 上一篇:MATLAB 夜间车牌识别
- 下一篇:使用matlab实现ICP点云匹配
相关资源
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
- k近邻算法matlab实现
- matlab识别系统
- 神经网络分类matlab程序
- matlab正弦信号发生器的设计
评论
共有 条评论