Message Boards Message Boards

0
|
1036 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How do I update a graph's vertex with the highest node degree?

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.
POSTED BY: Dennis Yeboah
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract