igraph: Resolving tight overlapping nodes

前提是你 提交于 2019-12-17 22:52:44

问题


I have a graph with few hundred nodes and edges. The disconnected subgraphs separate out and resolve well but the nodes within subgraphs overlap and do not resolve well. I have tried several layout algorithms and have also tried changing the relevant parameters within the layout algorithm (ex: iter, kkconst, start.temp etc). But, I am still not able to disperse the tightly clustered nodes. See figure below.

I was hoping to find some parameter to control attraction/repulsion/gravity etc but there seems to be none. The answer and figures from bdemarest in this question does seem to fix exactly this issue. Strangely enough, several seemingly useful parameters have been deprecated in the new version of igraph (coolexp, maxdelta, area, repulserad etc).

Does anyone know of a way to keep the sub graphs well separated while spreading out close nodes well enough that they do not overlap?


回答1:


I managed to get it to work using package qgraph.

Here is a working example:

library(igraph)
library(qgraph)

g <- barabasi.game(355, directed=FALSE)

png("plot1.png", height=6, width=12, units="in", res=250)
par(mfrow=c(1, 3))

plot(g,layout=layout_with_fr,vertex.size=4,vertex.label=NA)
mtext("layout_with_fr", side=1)

e <- get.edgelist(g)
l <- qgraph.layout.fruchtermanreingold(e,vcount=vcount(g))
plot(g,layout=l,vertex.size=4,vertex.label=NA)
mtext("qgraph.layout.fruchtermanreingold default", side=1)

l <- qgraph.layout.fruchtermanreingold(e,vcount=vcount(g),
      area=8*(vcount(g)^2),repulse.rad=(vcount(g)^3.1))
plot(g,layout=l,vertex.size=4,vertex.label=NA)
mtext("qgraph.layout.fruchtermanreingold modified", side=1)

dev.off()



来源:https://stackoverflow.com/questions/39290909/igraph-resolving-tight-overlapping-nodes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!