Skip to contents

Create adjacency matrices from 'graph6', 'sparse6', or 'digraph6' symbols

Usage

adjacency_from_text(object, ...)

Arguments

object

character vector of 'graph6', 'sparse6', or 'digraph6' symbols

...

other arguments, currently ignored

Value

A list of adjacency matrices.

Details

If object contains 'sparse6' symbols, which are in fact encoded edgelists, the function will return corresponding adjacency matrices creating temporary igraph objects internally.

Examples

# Graph6 symbols
sampleg6
#> [1] "CR"       "CJ"       "CN"       "F_?xo"    "F@h^_"    "F@Miw"    "Hr\\~~~~"
#> [8] "H}u|z|~"  "Ht\\~~z~"
adjacency_from_text(sampleg6)
#> [[1]]
#>      [,1] [,2] [,3] [,4]
#> [1,]    0    0    1    0
#> [2,]    0    0    0    1
#> [3,]    1    0    0    1
#> [4,]    0    1    1    0
#> 
#> [[2]]
#>      [,1] [,2] [,3] [,4]
#> [1,]    0    0    0    0
#> [2,]    0    0    1    1
#> [3,]    0    1    0    1
#> [4,]    0    1    1    0
#> 
#> [[3]]
#>      [,1] [,2] [,3] [,4]
#> [1,]    0    0    0    1
#> [2,]    0    0    1    1
#> [3,]    0    1    0    1
#> [4,]    1    1    1    0
#> 
#> [[4]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7]
#> [1,]    0    1    0    0    0    0    0
#> [2,]    1    0    0    0    0    0    0
#> [3,]    0    0    0    0    0    1    1
#> [4,]    0    0    0    0    0    1    1
#> [5,]    0    0    0    0    0    1    1
#> [6,]    0    0    1    1    1    0    0
#> [7,]    0    0    1    1    1    0    0
#> 
#> [[5]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7]
#> [1,]    0    0    0    0    1    0    1
#> [2,]    0    0    0    0    0    1    1
#> [3,]    0    0    0    1    1    0    1
#> [4,]    0    0    1    0    0    1    1
#> [5,]    1    0    1    0    0    1    0
#> [6,]    0    1    0    1    1    0    0
#> [7,]    1    1    1    1    0    0    0
#> 
#> [[6]]
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7]
#> [1,]    0    0    0    0    0    1    0
#> [2,]    0    0    0    0    0    0    1
#> [3,]    0    0    0    1    1    1    0
#> [4,]    0    0    1    0    1    0    1
#> [5,]    0    0    1    1    0    1    1
#> [6,]    1    0    1    0    1    0    1
#> [7,]    0    1    0    1    1    1    0
#> 
#> [[7]]
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
#>  [1,]    0    1    1    0    0    0    1    1    1
#>  [2,]    1    0    0    1    1    1    1    1    1
#>  [3,]    1    0    0    1    1    1    1    1    1
#>  [4,]    0    1    1    0    1    1    1    1    1
#>  [5,]    0    1    1    1    0    1    1    1    1
#>  [6,]    0    1    1    1    1    0    1    1    1
#>  [7,]    1    1    1    1    1    1    0    1    1
#>  [8,]    1    1    1    1    1    1    1    0    1
#>  [9,]    1    1    1    1    1    1    1    1    0
#> 
#> [[8]]
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
#>  [1,]    0    1    1    1    1    1    1    0    0
#>  [2,]    1    0    1    1    1    0    0    1    1
#>  [3,]    1    1    0    0    0    1    1    1    1
#>  [4,]    1    1    0    0    1    1    1    1    1
#>  [5,]    1    1    0    1    0    1    1    1    1
#>  [6,]    1    0    1    1    1    0    1    1    1
#>  [7,]    1    0    1    1    1    1    0    1    1
#>  [8,]    0    1    1    1    1    1    1    0    1
#>  [9,]    0    1    1    1    1    1    1    1    0
#> 
#> [[9]]
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
#>  [1,]    0    1    1    1    0    0    1    1    1
#>  [2,]    1    0    0    0    1    1    1    1    1
#>  [3,]    1    0    0    1    1    1    1    1    1
#>  [4,]    1    0    1    0    1    1    1    1    1
#>  [5,]    0    1    1    1    0    1    1    1    1
#>  [6,]    0    1    1    1    1    0    1    1    1
#>  [7,]    1    1    1    1    1    1    0    0    1
#>  [8,]    1    1    1    1    1    1    0    0    1
#>  [9,]    1    1    1    1    1    1    1    1    0
#> 

# Sparse6 symbols
s6 <- c(":DgXI@G~", ":DgWCgCb")
adjacency_from_text(s6)
#> [[1]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    0    0    0    0    1
#> [2,]    0    0    1    1    1
#> [3,]    0    1    0    1    1
#> [4,]    0    1    1    0    1
#> [5,]    1    1    1    1    0
#> 
#> [[2]]
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    0    0    0    1    1
#> [2,]    0    0    1    1    1
#> [3,]    0    1    0    1    1
#> [4,]    1    1    1    0    1
#> [5,]    1    1    1    1    0
#> 

# Digraph6 symbol
d6 <- "&N????C??D?_G??C?????_?C_??????C??Q@O?G?"
adjacency_from_text(d6)
#> [[1]]
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
#>  [1,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#>  [2,]    0    0    0    0    0    0    0    0    0     0     0     0     1
#>  [3,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#>  [4,]    1    0    1    0    0    0    0    0    0     1     0     0     0
#>  [5,]    0    0    1    0    0    0    0    0    0     0     0     0     0
#>  [6,]    0    0    0    0    0    0    1    0    0     0     0     0     0
#>  [7,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#>  [8,]    0    0    0    0    0    0    0    0    0     1     0     0     0
#>  [9,]    0    0    0    0    0    0    0    0    0     1     0     0     1
#> [10,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [11,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [12,]    0    0    0    0    0    0    0    0    0     0     0     0     1
#> [13,]    0    0    0    0    0    0    0    0    0     0     0     0     0
#> [14,]    0    1    0    0    0    0    0    0    1     0     1     0     0
#> [15,]    0    0    0    0    0    0    0    0    1     0     0     0     0
#>       [,14] [,15]
#>  [1,]     0     0
#>  [2,]     0     0
#>  [3,]     0     0
#>  [4,]     0     0
#>  [5,]     0     0
#>  [6,]     0     0
#>  [7,]     0     0
#>  [8,]     0     0
#>  [9,]     0     0
#> [10,]     0     0
#> [11,]     0     0
#> [12,]     0     0
#> [13,]     1     0
#> [14,]     0     0
#> [15,]     0     0
#>