Convert igraph graphs to graphNEL objects from the graph package
Source:R/conversion.R
as_graphnel.Rd
The graphNEL class is defined in the graph
package, it is another
way to represent graphs. These functions are provided to convert between
the igraph and the graphNEL objects.
Details
as_graphnel()
converts an igraph graph to a graphNEL graph. It
converts all graph/vertex/edge attributes. If the igraph graph has a
vertex attribute ‘name
’, then it will be used to assign
vertex names in the graphNEL graph. Otherwise numeric igraph vertex ids
will be used for this purpose.
See also
graph_from_graphnel()
for the other direction,
as_adjacency_matrix()
, graph_from_adjacency_matrix()
,
as_adj_list()
and graph_from_adj_list()
for
other graph representations.
Other conversion:
as.matrix.igraph()
,
as_adj_list()
,
as_adjacency_matrix()
,
as_biadjacency_matrix()
,
as_data_frame()
,
as_directed()
,
as_edgelist()
,
as_long_data_frame()
,
graph_from_adj_list()
,
graph_from_graphnel()
Examples
## Undirected
g <- make_ring(10)
V(g)$name <- letters[1:10]
GNEL <- as_graphnel(g)
g2 <- graph_from_graphnel(GNEL)
g2
#> IGRAPH e6feb64 UNW- 10 10 -- Ring graph
#> + attr: name (g/c), mutual (g/l), circular (g/l), name (v/c), weight
#> | (e/n)
#> + edges from e6feb64 (vertex names):
#> [1] a--b a--j b--c c--d d--e e--f f--g g--h h--i i--j
## Directed
g3 <- make_star(10, mode = "in")
V(g3)$name <- letters[1:10]
GNEL2 <- as_graphnel(g3)
g4 <- graph_from_graphnel(GNEL2)
g4
#> IGRAPH 344cdaa DNW- 10 9 -- In-star
#> + attr: name (g/c), mode (g/c), center (g/n), name (v/c), weight (e/n)
#> + edges from 344cdaa (vertex names):
#> [1] b->a c->a d->a e->a f->a g->a h->a i->a j->a