is_graph_connected: Is the graph a connected graph?

Description Usage Arguments Value Examples

View source: R/is_graph_connected.R

Description

Determines whether a graph is a connected graph.

Usage

1

Arguments

graph

a graph object of class dgr_graph.

Value

a logical value.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## Not run: 
# 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(
    n = 30, m = 40,
    set_seed = 23)

graph_1 %>%
  is_graph_connected()
#> [1] FALSE

# The following graph is fully connected
graph_2 <-
  create_random_graph(
    n = 30, m = 50,
    set_seed = 23)

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); this is easily done by
# removing one of the nodes that is an
# articulation point
graph_2 %>%
  delete_node(
    node = get_articulation_points(.)[1]) %>%
  is_graph_connected()
#> [1] FALSE

## End(Not run)

DiagrammeR documentation built on Sept. 7, 2017, 1:06 a.m.