%% Shortest Path Between Specified Nodes
% Create and plot a directed graph.

s = [1 1 2 3 3 4 4 6 6 7 8 7 5];
t = [2 3 4 4 5 5 6 1 8 1 3 2 8];
G = digraph(s,t);
plot(G)

%
% Calculate the shortest path between nodes 7 and 8.

P = shortestpath(G,7,8)

% Copyright 2015 The MathWorks, Inc.