不同节点使用两种布局的igraph

不同节点使用两种布局的igraph,r,igraph,R,Igraph,是否有一种方法可以使用两种不同的布局绘制图形,一种用于一组节点,另一种用于所有其他节点 例如,定义节点1-10使用圆形布局绘制,所有其他节点使用力导向布局绘制。可以。您只需要将两种不同的布局组合在一起 library(igraph) gr <- random.graph.game(100, p.or.m = 0.25, type = "gnp") lay1 <- layout_in_circle(induced_subgraph(gr, 1:20)) ##layouts are

是否有一种方法可以使用两种不同的布局绘制图形,一种用于一组节点,另一种用于所有其他节点


例如,定义节点1-10使用圆形布局绘制,所有其他节点使用力导向布局绘制。

可以。您只需要将两种不同的布局组合在一起

library(igraph)

gr <- random.graph.game(100, p.or.m = 0.25, type = "gnp")

lay1 <- layout_in_circle(induced_subgraph(gr, 1:20)) ##layouts are just matrices with x, y coordinates
lay2 <- layout_with_fr(induced_subgraph(gr, 21:100)) #I used Fruchterman-Reingold on the subgraph excluding the nodes in the circle but you could include them and then overwrite their layout coordinates with the coordinates for the circle
lay3 <- rbind(lay1+2, lay2) ## I added a scalar to shift the circlular nodes out of the middle of the force-directed layout to make it more obvious.
plot(gr, layout=lay3, vertex.size=8)