%% Subset of Shortest Paths with Specified Source Node
% Find the shortest paths and path lengths from a single source node to several target nodes.
% Create and plot a graph.

G = digraph(bucky);
plot(G)

%
% Find the shortest paths from node 23 to several other nodes. Specify OutputForm as cell to return the shortest paths in a cell array. Specify two outputs to also return the shortest path distances.

target = [1 5 13 32 44];
[TR,D] = shortestpathtree(G,23,target,'OutputForm','cell')

%
% tree{j} is the shortest path from node 23 to node target(j) with length D(j).
% Find the path and path length from node 21 to node 5.

path = TR{2}

%

path_length = D(2)

% Copyright 2015 The MathWorks, Inc.