## Not run:
# library(magrittr)
#
# # Create a random graph
# graph <-
# create_random_graph(36, 50, set_seed = 1)
#
# # Check if the graph is connected
# is_graph_connected(graph)
# #> [1] TRUE
#
# # Modify the graph so that it becomes disconnected
# # (with two clusters of nodes)
# graph <-
# graph %>%
# delete_edge(10, 36) %>%
# delete_edge(25, 27) %>%
# delete_edge(28, 29) %>%
# delete_edge(4, 29) %>%
# delete_edge(24, 32)
#
# # Verify that the graph is disconnected
# is_graph_connected(graph)
# #> [1] FALSE
#
# # Get the graph's connected components
# get_connected_components(graph)
# #> component node
# #> 1 1 1
# #> 2 1 3
# #> 3 1 4
# #> 4 1 5
# #> 5 1 6
# #> 6 1 7
# #> 7 1 8
# #> 8 1 9
# #> 9 1 11
# #> 10 1 14
# #> .. .. ..
# ## End(Not run)
Run the code above in your browser using DataLab