-
大小: 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实现ICP点云匹配
- MATLAB 夜间车牌识别
- matlab使用有限元方法求解偏微分方程
- matlab纹理特征提取源代码
- 中央大学 EMD HHT Matlab 源代码
- 方崇智《过程辨识》一书中各种辨识
- 求取图像的平均梯度---matlab ---M文件
- matlab潮流程序牛顿拉夫逊+PQ分解法有
- MATLAB 4f光学系统仿真
- 基于肤色模型的人脸检测MATLAB代码
- 自动寻峰算法matlab源文件
- matlab时间序列分析工具程序
- 灰色预测模型及Matlab实现附参考论文
- MSE+ 一对一多类技术的matlab实现
- MIMO-OFDM无线通信技术及MATLAB实现
- MEEM视觉跟踪matlab代码
- MATLAB神经网络43个案例分析源代码
- 数字滤波器的MATLAB与FPGA实现——杜勇
- MATLAB图像与视频处理实用案例详解代
- 轴承故障诊断matlab代码四种方法
- EM算法(MATLAB实现)289407
- MATLAB应用程序接口用户指南pdf文档
- matlab图像压缩感知
- 基于MATLAB的永磁风力发电机动态仿真
- 精通MATLAB
- MATLAB 图像处理识别程序
- RANSAC算法用MATLAB写的代码
- Optometrika 透镜成像模拟
- MATLAB发票动车票识别.zip
- MATLAB交通标志识别[GUI界面,论文].z
评论
共有 条评论