score:6

You do not give any example data for the graph or the specific layout that you are trying to achieve, so I will take a random graph and a simple configuration as the target. The idea is that you can let any algorithm lay out all of the points and then adjust the position of the ones that you want to specify.

## basic graph for illustration
library(igraph)
set.seed(1)
g = erdos.renyi.game(10, 0.3)
LO = layout_with_fr(g)
plot(g, layout=LO)

Initial Position

OK, now suppose that we want to take the nodes 2,5,7 and 9 and lay them out in a box without any edges crossing. What I want to do is take a basic box layout and shift it so that these four nodes and their edges are away from the rest of the graph. I will just shift these four nodes so that they are a little above all of the others.

UB = max(LO[,2])
DesiredLO = matrix(c(0,0,0,1,1,0,1,1), nrow=4, ncol=2, byrow=TRUE)
LO[c(2,7,9,5), ]  = DesiredLO + matrix(rep(LO[2,], 4), ncol=2, byrow=TRUE)
LO[c(2,7,9,5), 2] = LO[c(2,7,9,5), 2] + UB - LO[2,2] + 1
plot(g, layout=LO)

Selected nodes placed specifically

Maybe you can adapt this to what you want. If not, please use this example or something like it to specify more clearly what you do want.


Related Query