Search code examples
rigraph

Change the layout of ring igraph graph to a series of horizontal nodes


I create the ring graph below with igraph. I would like to know if I can change its default layout (ring) to a series of horizontal nodes, with a large curvy arrow going from the last one back to the front, like this below. The first will be the 1 and the last the 4:

enter image description here

nodes <- data.frame(id = 1:4,label=1:4)
edges <- data.frame(from = c(1,2,3,4), to = c(2,3,4,1))
edges$smooth<-c(F,F,F,T)
edges$label<-c("","","","")

    library(igraph)
net <- graph_from_data_frame(d=edges, vertices=nodes, directed=T) 
plot(net, edge.arrow.size=.4)

Solution

  • Using your sample graph, you can get an approximation of your picture with

    LO = matrix(c(1:4, rep(1,4)), ncol=2)
    plot(net, edge.arrow.size=.4, layout = LO, 
        edge.curved = c(0,0,0,-1.1))
    

    Ring Graph