Java implementation of the Kernighan-Lin algorithm