Sometimes it is useful to work with a standard representation of a graph, like an edge list.
See also
graph_from_adjacency_matrix()
, read_graph()
Other conversion:
as.matrix.igraph()
,
as_adj_list()
,
as_adjacency_matrix()
,
as_biadjacency_matrix()
,
as_data_frame()
,
as_directed()
,
as_graphnel()
,
as_long_data_frame()
,
graph_from_adj_list()
,
graph_from_graphnel()
Examples
g <- sample_gnp(10, 2 / 10)
as_edgelist(g)
#> [,1] [,2]
#> [1,] 1 3
#> [2,] 4 6
#> [3,] 4 7
#> [4,] 2 8
#> [5,] 5 8
#> [6,] 4 9
#> [7,] 6 9
#> [8,] 2 10
#> [9,] 9 10
V(g)$name <- LETTERS[seq_len(gorder(g))]
as_edgelist(g)
#> [,1] [,2]
#> [1,] "A" "C"
#> [2,] "D" "F"
#> [3,] "D" "G"
#> [4,] "B" "H"
#> [5,] "E" "H"
#> [6,] "D" "I"
#> [7,] "F" "I"
#> [8,] "B" "J"
#> [9,] "I" "J"