Thanks for the very helpful comments.
What I’m trying to achieve is to distribute an object, but in a concise, human-readable form.
With minimal dependencies on system and environment. So that others can experiment with the result. And in such a way that it can be published in limited space.
Building on the received input I arrived at:
library(igraph)
g1 <- make_star(7)
dput(g1) # transfer output to the code example
# code example
library(igraph)
s1 = r"---(
structure(list(7, TRUE,
c(1, 2, 3, 4, 5, 6),
c(0, 0, 0, 0, 0, 0),
c(0, 1, 2, 3, 4, 5),
c(0, 1, 2, 3, 4, 5),
c(0, 0, 1, 2, 3, 4, 5, 6),
c(0, 6, 6, 6, 6, 6, 6, 6),
list(c(1, 0, 1),
list(name = "In-star", mode = "in", center = 1),
list(),
list()) ),
class = "igraph")
)---"
g2 <- dget(rawConnection(charToRaw(s1)), keep.source=FALSE)
g2 <- upgrade_graph(g2)
stopifnot(identical_graphs(g1, g2))
Dget doesn’t like <envionment>
so I got rid of that.