我对R包有问题 "rgexf".特别是,我有一个问题 边缘 我导入到Gephi的网络。在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的gexf(版本0.8.2beta)。在图像1中:enter image description here

您可以在Gephi中看到导入报告:顶点和边的数量是正确的;我手动将图形类型更改为无向,并将所有数据导入数据实验室窗口。

  1. 问题1. 为什么我应该在导入报告窗口中指定"无向",如果我已经在写入中做到了。gexf函数?

在图像2中

enter image description here

您可以看到,导入后,图形的类型自动切换为"有向"和 实际上没有导入边缘。

在图像3

enter image description here

我们有顶点列表:一切都很好。标签和Id正确导入。在图像4

enter image description here

你可以看到边缘的数据实验室窗口:没有导入边缘,如图2所示。我真的不明白为什么没有边缘导入。

  1. 问题2。如何纠正示例的导入。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代码都是正确的。节点和边缘id、标签、源和目标.

问题在哪里?在3边缘情况下,gephi中的导入报告是正确的,而数据实验室边缘窗口不显示边缘

<edge id="1" source="1" target="1" weight="1.0"/>

在4个边缘的情况下,边缘

 <edge id="0" source="5" target="2" weight="1.0"/>

而是失踪了。

我开始相信Gephi0.8.2中有一个错误,而不是在我的代码中。

任何建议/意见?

有帮助吗?

解决方案

问题1:即使您已经在gexf文件中将图形指定为无向,directed是默认值,尽管单击它有点烦人,至少它不是那么大。从安全角度来看,允许用户仔细检查他们正在导入的图表类型比可能错误地选择更容易。这需要两秒钟,没什么大不了的。

问题2:我复制了你的例子

require(rgexf)
vertices <- as.data.frame(cbind(seq(1,10),seq(1,10)))
colnames(vertices) <- c('Id','Label')
edges <- as.data.frame(cbind(5,9))
colnames(edges) <- c('Source','Target')
write.gexf(output='testgex.gexf',nodes=vertices,edges=edges,
          defaultedgetype = "undirected")

但我对边缘没有任何问题。enter image description here enter image description here enter image description here

也许你可以包括失败的确切代码?也许你的边缘不在数据中。框架形式?只是猜测,因为我无法复制你的错误。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top