Erasing a vertex from a graph in an edge list structure is more involved compared to insertion. This complexity arises because it not only involves removing the vertex but also requires adjusting the edges.
Steps involved in vertex deletion:
- Locate the vertex to be removed
- Scan through the entire list of edges (m in total) to find and delete edges that are connected to that vertex
- Remove the vertex from the list of vertices
The critical part of this process is scanning through all the edges, which makes the time complexity O(m). This dependence on the number of edges is what makes vertex deletion a more time-consuming operation compared to vertex insertion.
Because every edge must be checked to see if it connects to the vertex being erased, this step ensures that the graph remains accurate and connected properly after the removal.