cpp_simplify function

Reduce the number of edges by removing non-intersection nodes, duplicated edges and isolated loops in the graph.