Functions is_graph6()
, is_sparse6()
), and is_digraph6()
test if elements
of a character vector are valid symbols of particular type.
Function guess_format()
tries to guess the type of the symbols
used in x
.
Value
Logical vector of length equal to length(x)
with TRUE
if an
element is a valid symbol and FALSE
otherwise.
Function guess_format()
returns a character vector of the same
length as x
with values "graph6", "sparse6", or "digraph6" depending on
the type of symbol present, or NA
if the symbol is unknown or matches
more than one type.
Note
At this moment the test is performed using regular expressions. Theoretically it may result in false positives.
Examples
all(is_graph6(g6))
#> [1] TRUE
all(is_sparse6(s6))
#> [1] TRUE
all(is_digraph6(d6))
#> [1] TRUE
# Vector mixing graphs in various formats
x <- g6
x[seq(2, 20, by = 3)] <- s6[seq(2, 20, by = 3)]
x[seq(3, 20, by = 3)] <- d6[seq(3, 20, by = 3)]
guess_format(x)
#> [1] "graph6" "sparse6" "digraph6" "graph6" "sparse6" "digraph6"
#> [7] "graph6" "sparse6" "digraph6" "graph6" "sparse6" "digraph6"
#> [13] "graph6" "sparse6" "digraph6" "graph6" "sparse6" "digraph6"
#> [19] "graph6" "sparse6"