-
-
Notifications
You must be signed in to change notification settings - Fork 206
Description
I've been plotting multiple subgraphs while attempting to retain layout values, and came across an interesting bug. If g$layout is a matrix, vertex deletion doesn't modify it, which produces odd results. For example:
g <- make_ring(10)
g$layout <- layout_in_circle(g)
plot(induced.subgraph(g,c(1:9)))
The "ghost" node 10 is still plotted, picking up the label of the first vertex to boot!
Workaround is to manually remove the node from layout:
g2 <- induced.subgraph(g,1:9)
g2$layout <- g2$layout[1:9,]
plot(g2)
Similar but slightly more complex manual removal needs to occur when subgraph.edges is used:
g3 <- subgraph.edges(g,1:8)
g3$layout <- g3$layout[V(g)[inc(1:8)],]
plot(g3)
Expected behavior would be for plot() to ignore any "extra" vertices in layout. But depending on internal representation, there may be no way of doing so. In that case, subgraph.edges and induced.subgraph should probably modify any g$layout if g$layout is a matrix.
I'd offer a patch, but my C is very shaky.
Thanks!