I have read the R igraph - save layout?, but in my case it is requared to save positions of begin's and end's edges into a file with the edge list together.
I have a tree
igraph object and predefined mylayout
layout on the plane.
tree <- make_tree(5, 2, mode = "undirected")
mylayout <- matrix(c(1, 2, 0, 3, 2,
1, 2, 0, 2, 3), ncol=2)
I have add a new attribute name
tree <- make_tree(5, 2, mode = "undirected") %>%
set_vertex_attr("name", value = seq(1:vcount(tree)))
and I get the edge list of graph via the get.edgelist()
function, and I am going to use name
attribute:
df1 <- data.frame(V1 = get.edgelist(tree)[,1],
V2 = get.edgelist(tree)[,2],
# V1_x = mylayout[as.integer(names(V(tree))), 1],
# V1_y = mylayout[as.integer(names(V(tree))), 2],
# V2_x = mylayout[, 1],
# V2_y = mylayout[, 2],
stringsAsFactors = FALSE)
Question. How to match the nodes positions with the begin's and end's positions of edges?