【发布时间】:2014-02-27 19:39:59
【问题描述】:
我对 R 包 "rgexf" 有疑问。特别是,我导入到 Gephi 的网络的 edges 存在问题。在 R 中,我可以生成一个顶点数据库
>vertices
Id Label
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
9 9 9
10 10 10
还有一个边数据库(准确地说是一条边)
>edges
Source Target
1 5 9
我使用创建一个 .gexf 文件
>write.gexf(output = path_gexf, nodes = vertices, edges = edges, defaultedgetype = "undirected")
其中path_gexf 只是输出文件的路径(称为example.gexf)。
我使用 Gephi(版本 0.8.2 beta)打开 example.gexf。
在图 1 中:
在Gephi中可以看到导入报告:顶点数和边数正确;我手动将图形类型更改为无向,并将所有数据导入数据实验室窗口。
- 问题 1。 如果我已经在 write.gexf 函数中指定了“未定向”,为什么还要在导入报告窗口中指定?
在图像2中
可以看到,导入后,图的类型自动切换为“有向”,实际上没有导入边。
在图 3 中
我们有顶点列表:一切都很好。标签和 ID 已正确导入。在图 4 中
你可以看到边缘的数据实验室窗口:没有导入边缘,如图 2 所示。我真的不明白为什么没有导入边缘。
- 问题2.如何更正example.gexf文件的导入?在 R 代码级别,一切都很顺利,我的代码正确生成了顶点/边。 Gephi 出现问题。
备注:我有很多 .gexf 文件存在边导入问题;在许多情况下,只有少数边被导入不正确的“源”和“目标”。奇怪的是,平行边总是根据其多重性正确计算。
我为这篇长文道歉。
编辑:使用虚拟 R 代码进行的一些测试
我使用@James Tobin 的代码做了一些测试(谢谢!)。它在我的电脑上也可以正常工作。 我对带有 2 条边的图进行了测试:测试一切正常。 然后我转移到 3,4 边缘情况,使用
require(rgexf)
vertices <- as.data.frame(cbind(seq(1,10),seq(1,10)))
colnames(vertices) <- c('Id','Label')
edges <- as.data.frame(cbind(c(5,1,2),c(1,1,3)))
colnames(edges) <- c('Source','Target')
write.gexf(nodes=vertices,edges=edges,
defaultedgetype = "undirected")
和
require(rgexf)
vertices <- as.data.frame(cbind(seq(1,10),seq(1,10)))
colnames(vertices) <- c('Id','Label')
edges <- as.data.frame(cbind(c(5,1,4,2),c(2,3,1,2)))
colnames(edges) <- c('Source','Target')
write.gexf(nodes=vertices,edges=edges,
defaultedgetype = "undirected")
在这两种情况下,XLM 代码都是正确的 w.r.t。节点和边的 ID、标签、源和目标。
问题出在哪里? 3边情况下Gephi中的导入报告是正确的,而数据实验室边窗口不显示边
<edge id="1" source="1" target="1" weight="1.0"/>
在 4 个边缘的情况下,边缘
<edge id="0" source="5" target="2" weight="1.0"/>
反而不见了。
我开始相信 Gephi 0.8.2 中存在错误,而不是我的代码中。
有什么建议/意见吗?
【问题讨论】:
标签: r data-visualization gephi