This reminds me of an algo to find the 2 points farthest away in a graph.
Imagine the graph is drawn on an handkerchief.
Pick any vertex of the graph and let the handkerchief "fall" around it.
Now, with your other hand, pick the point which is the lowest (farthest away from the one in your hand). The handkerchief falls again around that new point.
Again, with your other hand pick the point which is the lowest. The two points in your hands are those farthest away.
(didn't find the reference of this algo, so it may be wrong; just correct me if it is)
Your algorithm doesn't really work for graphs - it actually treats the vertices as a set of points (the edges are not taken into account, you're just looking for the largest Euclidean distance between two points).
Unforunately, it is not correct even then. Here is a counterexample:
A
|
B-C-D
You have points laid out like this, and: AC > CD=BC, AD=AB < BD. If you start from point C, you will pick A as the lowest point, then B/D, giving you the pair AB/AD as the result. The correct result is BD.
Imagine the graph is drawn on an handkerchief. Pick any vertex of the graph and let the handkerchief "fall" around it.
Now, with your other hand, pick the point which is the lowest (farthest away from the one in your hand). The handkerchief falls again around that new point.
Again, with your other hand pick the point which is the lowest. The two points in your hands are those farthest away.
(didn't find the reference of this algo, so it may be wrong; just correct me if it is)