%% Shortest Path Distances from Specified Sources
% Create and plot a graph.

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

%
% Find the shortest path distances from node 1, node 2, and node 3 to all other nodes in the graph.

d = distances(G,[1 2 3])

%
% Use d to find the shortest path distance from node 1 to node 7.

d(1,7)

% Copyright 2015 The MathWorks, Inc.