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 6
#> [2,] 3 7
#> [3,] 3 8
#> [4,] 1 9
#> [5,] 8 9
#> [6,] 3 10
#> [7,] 6 10
#> [8,] 8 10
V(g)$name <- LETTERS[seq_len(gorder(g))]
as_edgelist(g)
#> [,1] [,2]
#> [1,] "A" "F"
#> [2,] "C" "G"
#> [3,] "C" "H"
#> [4,] "A" "I"
#> [5,] "H" "I"
#> [6,] "C" "J"
#> [7,] "F" "J"
#> [8,] "H" "J"