if a graph node is removed or switched off, it is not removed from the vector of nodes (because that would mean changing all the indices of all the nodes that have a higher index. This method takes a node iterator as a parameter and assigns the next valid element to it.