day 25 solved in C
This one is a naive O(V^3), using an inefficient implementation of a
modified Stoer-Wagner min-cut algorithm. Using a priority queue
should speed it up to O(V*E + V^2 log V); this graph is sparse enough
(E is approx 2V) that V^2 log V will dominate V*E, and still be better
than V^3. Takes 6.5 seconds with compiled C; which does not bode well
for m4 where I have not yet finished an implementation. But it's at
least worth getting the star without reading anyone else's solution.
And while Karger's algorithm will (likely) perform faster, it is
non-deterministic, but m4 lacks random number generation, making that
one difficult to pick. It would also be possible to do a
Floyd-Warshall to determine the two points furthest apart as the
starting points for a fail-proof Karger's, but then the V^3
Floyd-Warshall will dominate.