I have the graph below in which I always display node a
on top. What I would like to change is to change the direction of the circle network to be always right (clockwise) with igraph
. Here is an example based on Set the position of certain node always on top of ring graph
library('igraph')
nodes <- c('a','b','c','d')
x <- c(0,1,2,3)
y <- c(0,1,2,3)
from <- c('a','b','c','d')
to <- c('b','c','d','a')
NodeList <- data.frame(nodes, x ,y)
EdgeList <- data.frame(from, to)
a<- graph_from_data_frame(vertices = NodeList, d= EdgeList, directed = TRUE)
# rotate rows of matrix mat so that row number mx is at top
# where mx defaults to row having largest value in 2nd column
rot <- function(mat, mx = which.max(mat[, 2])) {
if (mx == 1) mat else mat[c(mx:nrow(mat), 1:(mx-1)), ]
}
plot(a, layout = rot(layout_in_circle(a)))