How to remove isolates in Graph object in R

I have a R Graph object which has 20 isolate nodes.
I wish to remove all of them. Can you please guide me how I should write my function and arguments.

Thanks in anticipation



See Remove singleton clusters using induced subgraph - #5 by KeesP.

1 Like

A simple solution:

remove_isolates <- function(g) { <- degree(g)
  g.isolates <- V(g)[which( < 1)]
  return(delete_vertices(g, g.isolates))
1 Like

Thank you so much Dan.
It worked.

Cheers & Warm Regards