function dist = spdist(G)
%SPDIST returns shortest path distances of every node in graph G
%   This will take a really long time to run with a large graph.
tic                                                     % start timer
nids = G.Nodes.Name;                                    % get node ids
dist = zeros(length(nids));                             % initialize output
for i = 1:length(nids)                                  % loop over node ids
    for j = 1:length(nids)                              % nested loop
        if i ~= j                                       % skip diagonal els
            [~, d] = shortestpath(G,nids{i},nids{j});   % get shortest path
            dist(i,j) = d;                              % store distance
        end
    end
    fprintf('.')                                        % show progress
    if mod(i,30) == 0                                   % every 30th i
        fprintf('%.2f%% done\n',i*j*100/length(nids)^2) % show percentage
    end
end
disp('Complete.')                                       % show completion
toc                                                     % time spent
end

