3 ms·
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 fo
by krajzeg 7y ago
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.
Was fun to think about, though!
- rjmunro 7y agoAre you supposed to keep going until you go back to the same pair? So you would go C, A, B, D, B?