add O(n^3) extreme edges algorithm