as_edgelist: Convert a graph to an edge list

View source: R/conversion.R

as_edgelistR Documentation

Convert a graph to an edge list

Description

Sometimes it is useful to work with a standard representation of a graph, like an edge list.

Usage

as_edgelist(graph, names = TRUE)

Arguments

graph

The graph to convert.

names

Whether to return a character matrix containing vertex names (i.e. the name vertex attribute) if they exist or numeric vertex ids.

Details

as_edgelist() returns the list of edges in a graph.

Value

A ecount(graph) by 2 numeric matrix.

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)

V(g)$name <- LETTERS[seq_len(gorder(g))]
as_edgelist(g)


igraph documentation built on Oct. 20, 2024, 1:06 a.m.