Bethel's algorithm.