Solving edge creation and reversing for graph