1 | initial version |
You can use the as_data_frame()
function from igraph and then remove the first column which contains the node identifiers. Here is an example:
library(igraph)
# create a sample graph with constraints
g <- graph.formula(1-2-3-4-5, 2-4-5)
set.vertex.attribute(g, "c1", c(1, 0, 0, 0, 1))
set.vertex.attribute(g, "c2", c(1, 0, 0, 1, 1))
# export constraints to data frame without node identifiers
df <- as_data_frame(g, what = "vertices", attrs = c("c1", "c2"))
df <- df[, -1]
The resulting data frame df
will have the constraints in columns, without the node identifiers.