What is the feature or improvement you would like to see?
Be able to read and write to strings in read_graph(), write_graph()
For example:
Create graph.
g <- make_ring(10)
write_graph(g) # output graph to the console, e.g. stdout()
write_graph(g, file="") # output graph to the console, e.g. stdout()
write_graph(g, text = s) # output graph to string
And read back.
library(igraph)
g <- make_ring(10)
s1 = r"---(0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 0 9)---"
# g1 <- read_graph(text=s1, format="edgelist", directed=FALSE) # proposed
g1 <- read_graph(rawConnection(charToRaw(s1)), format="edgelist", directed=FALSE) # work around as suggested by ntamas
isomorphic(g, g1)
From the R documentation of write.table:
text | character string: if file is not supplied and this is,
then data are read from the value of text via a text connection.
Notice that a literal string can be used to include (small) data sets within R code.
The current implementation of write/read_graph uses binary connections. Therefore, the above construction fails.
One idea is to add ascii =TRUE as in saveRDS.
Use cases for the feature
- Avoids interaction with the file system.
- Makes it easier to create standalone code samples.
- Allows moving graph objects across platforms using cut and paste and plain text files.
References
See also read.csv, write.csv
What is the feature or improvement you would like to see?
Be able to read and write to strings in read_graph(), write_graph()
For example:
Create graph.
write_graph(g, text = s) # output graph to stringAnd read back.
From the R documentation of write.table:
The current implementation of write/read_graph uses binary connections. Therefore, the above construction fails.
One idea is to add ascii =TRUE as in saveRDS.
Use cases for the feature
References
See also read.csv, write.csv