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

Regards

DHARMA
INDIA

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

1 Like

A simple solution:

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

Thank you so much Dan.
It worked.

Cheers & Warm Regards

SHRINIVAS