This creates a nctx-graph as a copy of an igraph-graph.

copy_from_igraph(g_i)

Arguments

g_i

An igraph graph

Value

The copied nctx graph

Details

Internally, this is a call to ends(g_i, E(g_i), names = F) with g_i being an igraph graph.

Note that only structural information will be copied, i.e. attributes like vertex names or edge weights are not copied.

Examples

library(RUnit) library(igraph) library(nctx) file <- system.file("extdata", "bcde.directed.graphml", package="nctx") g_i <- read_graph(file, "graphml") checkTrue(igraph::is_directed(g_i))
#> [1] TRUE
g <- copy_from_igraph(g_i) checkTrue(nctx::is_directed(g))
#> [1] TRUE
checkEquals(vcount(g_i), 10)
#> [1] TRUE
#> [1] TRUE
checkEquals(ecount(g_i), 14)
#> [1] TRUE
#> [1] TRUE
checkEquals(igraph::as_edgelist(g_i, names = FALSE), nctx::as_edgelist(g))
#> [1] TRUE
file <- system.file("extdata", "bcde.undirected.graphml", package="nctx") g_i <- read_graph(file, "graphml") checkTrue(!igraph::is_directed(g_i))
#> [1] TRUE
g <- copy_from_igraph(g_i) checkTrue(!nctx::is_directed(g))
#> [1] TRUE
checkEquals(vcount(g_i), 10)
#> [1] TRUE
#> [1] TRUE
checkEquals(ecount(g_i), 14)
#> [1] TRUE
#> [1] TRUE
checkEquals(igraph::as_edgelist(g_i, names = FALSE), nctx::as_edgelist(g))
#> [1] TRUE