【发布时间】:2018-02-18 14:31:06
【问题描述】:
我正在使用 igraph 运行 R 3.3.3,当我通过它传递一个图表时,我一直看到 str() 的奇怪返回:
> g<-graph.formula(1-2,2-3,3-1)
> str(g)
List of 10
$ :List of 1
..$ 1:Class 'igraph.vs' atomic [1:2] 2 3
.. .. ..- attr(*, "env")=<weakref>
.. .. ..- attr(*, "graph")= chr "9ed96421-95d9-11e7-8000-010000000000"
$ :List of 1
..$ 2:Class 'igraph.vs' atomic [1:2] 1 3
.. .. ..- attr(*, "env")=<weakref>
.. .. ..- attr(*, "graph")= chr "9ed96421-95d9-11e7-8000-010000000000"
$ :List of 1
..$ 3:Class 'igraph.vs' atomic [1:2] 1 2
.. .. ..- attr(*, "env")=<weakref>
.. .. ..- attr(*, "graph")= chr "9ed96421-95d9-11e7-8000-010000000000"
$ :Error in adjacent_vertices(x, i, mode = if (directed) "out" else "all") :
At iterators.c:759 : Cannot create iterator, invalid vertex id, Invalid vertex id
我正在使用网络数据的统计分析 (Kolaczyk),他们似乎从 str() 获得了不同的回报:
> g <- graph.formula(1-2, 1-3, 2-3, 2-4, 3-5, 4-5, 4-6,4-7, 5-6, 6-7)
> str(g)
IGRAPH UN-- 7 10 --
+ attr: name (v/c)
+ edges (vertex names):
1 -- 2, 3
2 -- 1, 3, 4
3 -- 1, 2, 5
4 -- 2, 5, 6, 7
5 -- 3, 4, 6
6 -- 4, 5, 7
7 -- 4, 6
以上代码sn-p取自:https://github.com/kolaczyk/sand/blob/master/sand/inst/code/chapter2.R。我想知道为什么我的返回格式不一样,如果有什么我可以做的让我的输出看起来像第二个。我已经尝试了几个版本的 R(3.4.1、3.3.2、3.3.3),但仍然看到相同的东西。我的猜测是这来自 igraph 而不是 R,但我不确定 - 任何帮助都会非常感激。谢谢。
【问题讨论】:
-
我可以在 igraph v1.1.2 上重现这个,但之前安装的版本有其他结果。
-
啊,看着
?str.igraph,它说“从igraph 1.1.1开始,str.igraph函数已失效,请使用print_all()。”所以使用print_all(g)