
Build an igraph From an R Database's Nodes/Edges Tables
Source:R/database_setops.R
database_to_igraph.RdThe other direction from as_database: takes a
cbe_database (or plain list(nodes = ..., edges = ...))
– such as one produced by as_database or the
database_setops verbs – and builds an igraph from it.
Details
Deliberately not a new as_igraph() method: as_igraph.default()
(see as_igraph) already dispatches on plain list
objects for its own, unrelated purpose (a list of FilePath/
FileUses/FileOutputs pipeline objects); adding
as_igraph.list() here would silently intercept every one of those
calls instead of falling through to .default.
Examples
db <- as_database(list(
nodes = data.frame(name = c("a", "b", "c")),
edges = data.frame(from = c("a", "b"), to = c("b", "c"))
))
database_to_igraph(db)
#> IGRAPH de3d8f4 DN-- 3 2 --
#> + attr: name (v/c)
#> + edges from de3d8f4 (vertex names):
#> [1] a->b b->c