Implementation of Gabow's algorithm