我听说过使用以下算法找到未加权图的直径的算法:
Algorithm (start_vertex):
find out the set of vertices S having maximum value of
shortest distance from start_vertex.
ans = 0;
for each vertex v in S
temp = 0;
for each vertex u in graph G:
temp = max(temp, shortest distance between u and v).
ans = temp;
return ans;
该算法在线性时间内工作,用于查找图的直径。任何人都可以证明其正确性或证明它是错误的