Start a breadth first search (BFS) from any node <code>start</code>; let the farthest node found be <code>A</code>.
Run BFS from <code>A</code>; a farthest node <code>B</code> is at the other end, and the path <code>A</code>-<code>B</code> is a diameter.
If several nodes tie as farthest from <code>start</code>, collect them into <code>cand_start</code>, each is a possible diameter endpoint.
Running BFS from any node in <code>cand_start</code> yields the opposite-end set <code>cand_other</code>, the other diameter endpoints.