Skip to contents

Encode a graph as 'graph6', 'sparse6' or 'digraph6' choosing the format automatically.

Usage

graph_as_text(object, ...)

# S3 method for default
graph_as_text(object, ...)

# S3 method for list
graph_as_text(object, ...)

Arguments

object

igraph/network object or a list thereof

...

other arguments, currently ignored

Value

A character vector of encoded graphs.

Details

If object is a list it may be a mixture of 'network' and 'igraph' objects.

Methods (by class)

  • graph_as_text(default): The default method chooses the encoding format automatically using choose_format().

  • graph_as_text(list): The list method applies the default method to each element.

See also

Examples

# From igraph ------------------------------------------------------
if(requireNamespace("igraph")) {
   g <- igraph::graph.famous("Zachary")
   graph_as_text(g)
   
   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))
      
   graph_as_text(glist)
}
#> [[1]]
#> [1] ":NiMEcpPX\\hHV"
#> 
#> [[2]]
#> [1] "NOGSOO`OA_SA?a?OCE?"
#> 
#> [[3]]
#> [1] "NA^?aGRb?cvThACFLwg"
#> 

# From network -----------------------------------------------------
if(requireNamespace("network")) {
   m <- matrix(rbinom(25,1,.4),5,5)
   diag(m) <- 0
   g <- network::network(m, directed=FALSE)
   graph_as_text(g)
}
#> [1] "Dzs"