如何传播或整理网络? [英] How to spread or unclutter a network?

查看:84
本文介绍了如何传播或整理网络?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试扩展网络或更好地可视化网络.问题是我似乎分散了一些隔离株,并迫使簇进入紧凑的空间,使得很难看到图案.

I am trying to spread out or better visualize the network. The issue is the number of isolates I have seems to spread out the isolates and force the clusters into compact spaces that makes it hard to see patterns.

任何人都没有任何指南来分发群集或更好地可视化数据.如果需要,我可以在代码中进行编辑.

Does anyone have any guides to spread the clusters or better visualize the data. If you need, I can edit in the code.

谢谢

推荐答案

以下是获得更好布局的两种方法.两种解决方案都只需要做一点试验就可以找到好的设置.首先,由于您不提供任何数据,因此我将举一个与您类似的示例.

Here are two ways to get a better layout. Both solutions require just a little experimentation to find good settings. First, since you do not provide any data, I will make an example that is vaguely like yours.

library(igraph)
set.seed(1234)
g1 = erdos.renyi.game(100,0.35)
g2= erdos.renyi.game(10,0.35)
G = add_vertices(g1+g2, 50)
LO = layout_with_fr(G)
plot(G, layout=LO, vertex.size=5, vertex.label="")

解决方案1 ​​:调整边缘权重
如果您不需要将边缘权重用于其他任何事情,则可以将权重设置为较低的值,这样在连接的点之间就不会产生如此强烈的吸引力.您可能需要尝试找到适合权重的值.

Solution #1 Adjust edge weights
If you don't need to use the edge weights for anything else, you can just set the weights to something low so that there will not be such a strong attraction between connected points. You may need to experiment to find a good value to use for the weights.

E(G)$weight = 0.01
LO = layout_with_fr(G)
plot(G, layout=LO, vertex.size=5, vertex.label="")

解决方案#2 直接调整布局
您也可以直接调整布局.

Solution #2 Directly adjust the layout
You could also directly adjust the layout.

首先,我确定哪些集群过于紧密.

First, I identify which are the nodes that are too tightly clustered.

CM = components(G)$membership
table(CM)

对于我的图形,组件1是我要扩展的组件.接下来,我只是移动布局,使其位于第一个组件的质心的中心.这不会更改图形;它使我可以轻松调整布局.

For my graph, component 1 is the one that I want to expand. Next, I just shift the layout so that it is centered on the centroid of the first component. This does not change the graph; it just makes it easy for me to adjust the layout.

LO = layout_with_fr(G)
LO[,1] = LO[,1] - mean(LO[CM == 1,1])
LO[,2] = LO[,2] - mean(LO[CM == 1,2])

但是现在我可以通过任何给定的扩展因子来增长(或收缩)第一个组件.我选择一个(5.5)来占用大部分空白空间.

But now I can grow (or shrink) the first component by any given expansion factor. I choose one (5.5) to take up most of the empty space.

LO[components(G)$membership == 1,] = LO[components(G)$membership == 1,] * 5.5
plot(G, layout=LO, vertex.size=5, vertex.label="")

当然,如果您想返回并调整其他组件,也可以这样做.

Of course if you wanted to go back and adjust other components, you could do that too.

这篇关于如何传播或整理网络?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆