title: Am I correct in why insertVertex would take O(1) and deleteVertex would take O(m) here?
body: <p>For a homework problem I was asked the question of given a set of n nodes and m edges where the graph was represented by an adjacency list, why insertVertex would take O(1) and deleteVertex would take O(m). </p>
  
  <p>I'm not entirely sure of my answer, but I put that insertVertex is O(1) because when you first insert, all you add to the array is one node and a set of adjacent vertices (meaning vertices that your new node points to). Thus this time complexity is constant. However, when you remove a node, not only do you have to remove the node and the adjacent edges that come with the node, you also have to go through the rest of the m edges to make sure that you remove the ones that point to the node that you are trying to remove (since you can't have an edge that points to nothing. </p>
  
  <p>I'm new to graph theory so I don't know if my way of thinking is correct.</p>