I want to create a visualization of a graph at 4 steps, i.e. different points in time. The positions of my vertices (nodes) should always stay the same (use the positions of the full graph). All I want is to remove some vertices from the R igraph graph. What seems to be an issue is that the vertices names change.
# Erdos
par(mfrow=c(1,3))
g <- erdos.renyi.game(20, 1/20)
locs <- layout.fruchterman.reingold(g)
V(g)$name <- V(g)
# In the original file, vector names look like this (not "1,2,3,4...):
V(g)$name <- as.vector(c(8,9,3,5,13,6,7,1,2,18,11,12,16,14,15,4,17,10,20,19))
V(g)$name
plot(g,
layout=locs,
main="Original")
# Remove a few vertices
removals1 <- c("12","2","9","11","4")
g2 <- delete.vertices(g,removals1)
plot(g2,
layout=locs[-as.numeric(removals1),],
main="Removals")
# Remove some more
removals2 <- c("15","14","7","8","5","19","10")
g3 <- delete.vertices(g2,removals2)
plot(g3,
layout=locs[-as.numeric(c(removals1,removals2)),],
main="More Removals")
I would be really happy to find a solution here. Maybe, there are also far more elegant solution as the one above. Thanks!