1

How do I identify isolates and delete them in R Statnet?

Here is an example code.

g2<-network.initialize(10)
add.edge(g2,1,2)
add.edge(g2,2,3)
add.edge(g2,3,4)
add.edge(g2,4,5)

This will generate a network where vertices 6,7,8,9, 10 are not connected. These are isolates. So my question is how do I identify isolates and remove them from the network in Statnet library.

Kay
  • 567
  • 3
  • 6
  • 15

1 Answers1

1

You could use the sna::isolates function to detect them and delete the isolates through the network::delete.vertices function of the network package (both included in statnet).

In your case:

isolates <- sna::isolates(g2)
network::delete.vertices(g2, isolates)
harald
  • 81
  • 8
  • Thank you for your answer harald. I apologize for not acknowledging your help sooner. – Kay Oct 23 '22 at 18:59