Skip to contents

Generates two data frames (nodes and edges) from a list of edges

Usage

edge.list(x)

Arguments

x

A matrix or data frame structured as a list of edges

Value

A list containing two data frames.

Details

edge.list transforms the input into a two-elements list containing a dataframe of nodes (with columns “id” and “label”) and a dataframe of edges. The last one is numeric (with columns “source” and “target”) and based on auto-generated nodes' ids.

Author

George Vega Yon

Jorge Fabrega Lacoa

Examples


  edgelist <- matrix(
    c("matthew","john",
      "max","stephen",
      "matthew","stephen"),
    byrow=TRUE, ncol=2)
  
  edge.list(edgelist)
#> $nodes
#>   id   label
#> 1  1    john
#> 2  2 matthew
#> 3  3     max
#> 4  4 stephen
#> 
#> $edges
#>      source target
#> [1,]      2      1
#> [2,]      3      4
#> [3,]      2      4
#>