FormationControlSimulation/SOURCE/networks-toolbox/diameter.m

15 lines
330 B
Mathematica
Raw Normal View History

2019-06-17 14:31:50 +07:00
% The longest shortest path between any two nodes nodes in the network.
%
% INPUTS: adjacency matrix, nxn
% OUTPUTS: network diameter
%
% Other routines used: simpleDijkstra.m
% GB: last updated, Oct 8 2012
function diam = diameter(adj)
diam=0;
for i=1:size(adj,1)
d=simpleDijkstra(adj,i);
diam = max([max(d),diam]);
end