View source: R/choose_format.R
choose_format | R Documentation |
Given a graph suggest the most efficient format out of 'graph6', 'sparse6' or 'digraph6'.
choose_format(object, ...)
## Default S3 method:
choose_format(object, ...)
## S3 method for class 'list'
choose_format(object, ...)
object |
Igraph/network object or list thereof |
... |
other arguments, currently ignored |
If object
is directed, the suggested format is 'digraph6'. If
object
is undirected the function suggests 'sparse6' if density is less
than 0.15 and 'graph6' otherwise. This rule is approximate.
Character value out of 'graph6', 'sparse6' or 'digraph6'. If object
is a list, a vector of such values of the length equal to the length of
object
.
# From igraph ------------------------------------------------------
if(requireNamespace("igraph")) {
g <- igraph::graph.famous("Zachary")
choose_format(g)
set.seed(123)
glist <- list(
igraph::sample_gnp(n = 15, p = 0.1),
igraph::sample_gnp(n = 15, p = 0.2),
igraph::sample_gnp(n = 15, p = 0.3),
igraph::sample_gnp(n = 15, p = 0.15, directed = TRUE))
choose_format(glist)
}
# From network -----------------------------------------------------
if(requireNamespace("network")) {
m <- matrix(rbinom(25,1,.4),15,15)
diag(m) <- 0
g <- network::network(m, directed=FALSE)
choose_format(g)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.