Skip to contents

Read files of 'graph6', 'sparse6' or 'digraph6' symbols

Usage

read_file6(path, type = "adjacency")

Arguments

path

character; path to file name

type

character; one of "adjacency", "edgelist", "igraph", or "network". Type of result returned.

Value

A list of decoded graphs in the form of objects determined by type.

Details

File pointed to by path is a text file with one graph symbol per line. Optional headers of the form >>graph6<< or >>sparse6<< in the first line (and without the newline after the header) are ignored and removed.

Examples

g6_file <- tempfile()
write(sampleg6,g6_file)
read_file6(g6_file, type = "adjacency")
#> [[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
#> 
unlink(g6_file)