Optim on connected edges