fix bug where a self-edge (A -> A) was possible