/** An edge of a graph */ class Edge implements Comparable{ int fst; int snd; Edge(int fst, int snd) { this.fst = fst; this.snd = snd; } public boolean lessThan(Comparable c) { Edge e = (Edge) c; return (fst < e.fst || fst == e.fst && ((snd > e.snd) ^ (fst < snd) ^ (fst < e.snd))); /* the funky second line with the XORs tests for the cyclic ordering snd < fst == e.fst < e.snd */ } }