Skip to contents

split a tidy graph (each line is graph with at least 2 nodes) into two dataframes within a list: one with de nodes and its indexes, a second dataframe with de edges.

Usage

split_graph(DF_graph)

Examples

DF <- data.frame(from = c("Amanda", "Bruno", "Carlos", "Daniel"), to = c("Bruno", "Carlos", "Daniel", "Amanda"))

split_graph(DF)
#> $node_index
#> # A tibble: 4 × 2
#>      id label 
#>   <int> <chr> 
#> 1     1 Amanda
#> 2     2 Bruno 
#> 3     3 Carlos
#> 4     4 Daniel
#> 
#> $edges
#> # A tibble: 4 × 2
#>   from  to   
#>   <chr> <chr>
#> 1 1     2    
#> 2 2     3    
#> 3 3     4    
#> 4 4     1    
#>