start to handle case where we try to swap before checking all edges