choose_format function

Choose most efficient format heuristically

Choose most efficient format heuristically

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, ...)

Arguments

  • object: Igraph/network object or list thereof
  • ...: other arguments, currently ignored

Returns

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.

Details

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.

Examples

# 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) }
  • Maintainer: Michal Bojanowski
  • License: GPL (>= 3)
  • Last published: 2024-02-01