dijkstra(Graph, Source, Destination, restrict2Nodes)
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 版本兼容性
平台兼容性
Windows macOS Linux类别
- MATLAB > Mathematics > Graph and Network Algorithms > Modify Nodes and Edges > Dijkstra algorithm >
- Sciences > Mathematics > Combinatorics > Graph Theory > Dijkstra Algorithm >
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!版本 | 已发布 | 发行说明 | |
---|---|---|---|
1.0.0.0 | Check
|