Reputation: 847
Is there a way of testing whether a network graph is planar in R? I've looked in igraph but to no avail.
I know I can with MATLAB using BGL toolbox but I want to know if anyone has tried it in R.
Upvotes: 5
Views: 1089
Reputation: 5966
The RBGL package within bioconductor has what you are looking for. RBGL provides an interface to the Boost library for graph analysis (C++)
source("https://bioconductor.org/biocLite.R")
biocLite("RBGL")
library(RBGL)
library(igraph)
set.seed(1234)
g <- erdos.renyi.game(20, 1/5) ##Make an igraph graph
plot(g)
g <- as_graphnel(g) ## Convert igraph object to graphNEL object for planarity testing
boyerMyrvoldPlanarityTest(g)
# [1] FALSE
g <- erdos.renyi.game(20, 1/8)
plot(g)
g <- as_graphnel(g)
boyerMyrvoldPlanarityTest(g)
# [1] TRUE
Upvotes: 6