Skip to contents

The 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.

Usage

database_to_igraph(db, directed = TRUE)

Arguments

db

A cbe_database (or plain named list with nodes and edges data frames/tibbles), where nodes's first column is the node identifier used by edges's from/to columns.

directed

Logical, whether the graph is directed (default TRUE).

Value

An igraph object.

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