from_sparse6: Parsing 'sparse6' symbols

from_sparse6R Documentation

Parsing 'sparse6' symbols

Description

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.

Usage

edgelist_from_sparse6(s6)

igraph_from_sparse6(s6)

network_from_sparse6(s6)

Arguments

s6

character vector of 'sparse6' symbols

Value

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

See Also

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

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)
}


mbojan/rgraph6 documentation built on Sept. 25, 2024, 2:14 a.m.