is_graph_connected {DiagrammeR} | R Documentation |
Determines whether a graph is a connected graph.
is_graph_connected(graph)
graph |
a graph object of class
|
a logical value.
## Not run: library(magrittr) # This graph, created using `create_random_graph()` # is almost fully connected but there is an # isolated node with no edges graph_1 <- create_random_graph( 30, 50, set_seed = 1) graph_1 %>% is_graph_connected #> [1] FALSE # The following graph is fully connected graph_2 <- create_random_graph( 36, 50, set_seed = 1) graph_2 %>% is_graph_connected #> [1] TRUE # Modify `graph_2` so that there are two # clusters of nodes (i.e., making the graph # not connected) graph_3 <- graph_2 %>% delete_edge(10, 36) %>% delete_edge(25, 27) %>% delete_edge(28, 29) %>% delete_edge(4, 29) %>% delete_edge(24, 32) graph_3 %>% is_graph_connected #> [1] FALSE ## End(Not run)