I have an igraph with several disconnected components. For example:
library(igraph)
g <- simplify(
graph.compose(
graph.ring(10),
graph.star(5
You could calculate the connected components of your graph by using:
clusters(g)
# $membership
# [1] 1 1 1 1 1 1 2 2 3 1
#
# $csize
# [1] 7 2 1
#
# $no
# [1] 3
Or you could create a separate graph for each component of your graph by using:
dg <- decompose.graph(g) # returns a list of three graphs
plot(dg[[1]]) # plot e.g. the 1st one