I want to know whether the below algorithm is correct for testing planr graph:
step 1. Remove every degree-1 vertex and the edge that contains it.
step 2. Remove every degree-2 vertex and replace its two edges by an edge connecting its two neighbors.
step 3. Check whether the resulting graph has a K5 or a K3,3 as a subgraph; if not, pro- claim the graph is planar.
If the above algorithm is correct, how can I prove it is correct?
Since $K_5$ contains a 3-cycle and $K_{3,3}$ a 4-cycle, your proposed algorithm fails on any graph that is not planar and has girth at least five, e.g., the Petersen graph.