I\'m writing a code to simplify a graph. In this case i\'ve needed to remove a node of degree 2 and connect its two neighbors each other. Here is the simplified code