from_sparse6 function

Parsing 'sparse6' symbols

Parsing 'sparse6' symbols

These functions take a character vector of 'sparse6' symbols and return a list of other types of objects:

  • edgelist_from_sparse6() creates edgelist matrices

  • igraph_from_sparse6() creates 'igraph' objects. Requires package igraph to be installed.

  • network_from_sparse6() creates 'network' objects. Requires package network to be installed.

edgelist_from_sparse6(s6) igraph_from_sparse6(s6) network_from_sparse6(s6)

Arguments

  • s6: character vector of 'sparse6' symbols

Returns

The returned object is:

  • for edgelist_from_sparse6(), a list of the same length as its input of two-column edgelist matrices. The matrix has a gorder attribute storing the number of vertices in the graph.

  • for igraph_from_sparse6(), a list of 'igraph' objects

  • for network_from_sparse6(), a list of 'network' objects

Examples

elm <- structure(c(1, 1, 2, 2, 4, 4, 5, 6, 9, 10, 7, 8, 4, 8, 6, 8, 8, 5, 4, 6), .Dim = c(10L, 2L)) s6 <- as_sparse6(elm, n = 10) # To edgelist matrix ------------------------------------------------------- edgelist_from_sparse6(s6) # To igraph object --------------------------------------------------------- if(requireNamespace("igraph", quietly=TRUE)) { igraph_from_sparse6(s6) } # To network object -------------------------------------------------------- if(requireNamespace("network", quietly=TRUE)) { network_from_sparse6(s6) }

See Also

as_sparse6() for encoding network data objects as 'sparse6' symbols.

  • Maintainer: Michal Bojanowski
  • License: GPL (>= 3)
  • Last published: 2024-02-01