I am trying to update a graph to find the new vertex with the highest degree after removing vertex with the highest degree. However after doing that the first time, I get the same vertex after I had calculated the new vertex with the highest node degree.
rg = RandomGraph[{100, 367}]
s0 = VertexCount[rg]
targ = Flatten[
Position[VertexDegree[rg], _?(# == Max[VertexDegree[rg]] &)]][[1]]
rgtem = VertexDelete[rg, targ]
srg = Max[VertexCount /@ ConnectedGraphComponents[rgtem]] (**size of largest component**)
rg = rgtem
the code above works alright when i do it over and over again. However, this is a test code. When I implement this step on my orginal graph, after the first round, I get the error:
VertexDelete::inv: The argument 2554 in VertexDelete[Graph[<4940>, <6584>], 2554] is not a valid vertex.