DiagrammeR (version 0.9.0)

get_s_connected_cmpts: Get nodes within strongly connected components

Description

Determine which nodes in a graph belong to different strongly connected components.

Usage

get_s_connected_cmpts(graph)

Arguments

graph

a graph object of class dgr_graph.

Value

a data frame with nodes and their membership in different strongly connected components.

Examples

Run this code
# NOT RUN {
set.seed(23)

# Create a graph with a random connection
# between 2 different cycles
graph <-
  create_graph() %>%
  add_cycle(3, "cycle_1") %>%
  add_cycle(4, "cycle_2") %>%
  add_edge(
    from = get_node_ids(., "type == 'cycle_1'") %>%
      sample(1),
    to = get_node_ids(., "type == 'cycle_2'") %>%
      sample(1))

# Get the strongly connected components as a
# data frame of nodes and their groupings
get_s_connected_cmpts(graph)
#>   id sc_component
#> 1  1            1
#> 2  2            1
#> 3  3            1
#> 4  4            2
#> 5  5            2
#> 6  6            2
#> 7  7            2
# }

Run the code above in your browser using DataCamp Workspace