# Create an adjacency matrix representing an unconnected graph:
adjacency_matrix <- matrix(
data = c(
0, 0, 0, 1, 1, 0,
0, 0, 1, 0, 0, 1,
0, 1, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
0, 1, 1, 0, 0, 0
),
ncol = 6,
byrow = TRUE,
dimnames = list(LETTERS[1:6], LETTERS[1:6])
)
# Check graph is connected:
split_out_subgraphs(adjacency_matrix = adjacency_matrix)
Run the code above in your browser using DataLab