dijkstra(Graph, Source, Destination, restrict2Nodes)

版本 1.0.0.0 (4.6 KB) 作者: Pramit Biswas
Dijkstra's Algo to find shortest path, with ability to restrict the path through particular nodes
805.0 次下载
更新时间 2015/6/1

查看许可证

As mentioned in summary, This function used to find shortest path, with the ability to restrict the path through particular nodes. This function used popular method, known as Dijkstra's Algorithm. This method can be use in various domains like: Networking problem (optical/Wireless), Currency Exchange Problem, TSP etc.
%---------------------------------------------------
% usage:
% [Path, Cost, Flag] = dijkstra(Graph, Source, Destination)
% or
% [Path, Cost, Flag] = dijkstra(Graph, Source, Destination, restrict2Nodes)
%
% example:
% Inputs:
% G = [0 10 3 0 0;
% 0 0 1 2 0;
% 0 4 0 8 2;
% 0 0 0 0 7;
% 0 0 0 9 0]; % Every element of Graph should be non-negetive
% S = 1; % Starting node of the path
% D = 4; % Ending node of the path
% r2N = [2 4 1]; % If you want to restrict path only to some of your
% distinguished node (other than Source and Destination) in the Graph, you can ignore this if you want to use
% the full Graph
%
% [c, p, f] = dijkstra(G, S, D, r2N); or
% [c, p, f] = dijkstra(G, S, D)
%
% Outputs:
% Path: Shortest path found by the algorithm, =[], if not found any path
% Cost: Total cost for the shortest path, =Inf, if not found any path
% Flag: 'Found' or 'Not Found' string depending upon path found or not found
%---------------------------------------------------

引用格式

Pramit Biswas (2024). dijkstra(Graph, Source, Destination, restrict2Nodes) (https://www.mathworks.com/matlabcentral/fileexchange/51038-dijkstra-graph-source-destination-restrict2nodes), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2006a
兼容任何版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0

Check
help updated
Check