Convert graph object to dataframe with source and target columns

graph2df(graph)

Arguments

graph

Network

Value

data frame

Examples

dag <- create_random_DAG(30, 0.2)
graph2df(dag)
#>    source sink
#> 1      n1  n16
#> 2      n1   n7
#> 3      n1  n14
#> 4      n2  n24
#> 5      n2  n28
#> 6      n3   n5
#> 7      n3   n7
#> 8      n3  n15
#> 9      n3  n18
#> 10     n3  n27
#> 11     n4  n24
#> 12     n6   n7
#> 13     n6  n19
#> 14     n6   n9
#> 15     n6  n12
#> 16     n6  n18
#> 17     n6  n30
#> 18    n10  n12
#> 19     n5  n11
#> 20     n5  n13
#> 21     n5  n17
#> 22     n5  n22
#> 23     n5  n28
#> 24     n7   n8
#> 25     n7  n24
#> 26    n19  n22
#> 27    n11  n22
#> 28    n11  n29
#> 29    n13  n20
#> 30    n13  n14
#> 31    n13  n21
#> 32    n17  n20
#> 33    n17  n29
#> 34    n17  n21
#> 35    n17  n26
#> 36     n8   n9
#> 37     n8  n12
#> 38     n8  n29
#> 39    n24  n27
#> 40    n22  n25
#> 41    n22  n26
#> 42     n9  n14
#> 43     n9  n21
#> 44     n9  n25
#> 45     n9  n23
#> 46    n12  n15
#> 47    n12  n25
#> 48    n12  n26
#> 49    n14  n23
#> 50    n21  n23
#> 51    n21  n30
#> 52    n15  n18
#> 53    n26  n28
#> 54    n18  n27
#> 55    n18  n30