restricts adding duplicated edges