【问题标题】:igraph using two layouts for different nodesigraph 对不同节点使用两种布局
【发布时间】:2017-08-03 08:16:18
【问题描述】:

有没有办法使用两种不同的布局来绘制图形,一种用于一组节点,另一种用于所有其他节点?

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

【问题讨论】:

    标签: r igraph


    【解决方案1】:

    是的,你可以。您只需将两种不同的布局组合在一起即可。

    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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-10
      • 1970-01-01
      • 2015-08-05
      • 2020-05-05
      相关资源
      最近更新 更多