diam(g) --- return the diameter of g: the length of a longest shortest path in g, or Inf if g is not connected.
0001 function d = diam(g) 0002 % diam(g) --- return the diameter of g: the length of a longest shortest 0003 % path in g, or Inf if g is not connected. 0004 0005 d = max(max(dist(g)));