igraph python总结不按预期工作
问题描述:
我想在igraph-python中使用summary()
函数,因为它似乎对理解网络的初始结构非常有帮助,但看起来并不正确。igraph python总结不按预期工作
import igraph
g = igraph.Nexus.get("karate")
igraph.summary(g)
IGRAPH UN-- 34 78 -- Zachary's karate club network
+ attr: Author (g), Citation (g), name (g), Faction (v), id (v), name (v)
从我所看到的所有例子中,我看到人们又回到了从summary()
以下信息,所以我不知道我在做什么错在这里。
>>> g = Graph.Tree(127, 2)
>>> summary(g)
127 vertices, 126 edges, undirected
Number of components: 1
Diameter: 12
Density: 0.0157
Average path length: 8.3510
也许我错过了最新版本的igraph?
答
如果你想得到这样的部件,直径,密度和 平均路径长度的数量信息,你应该做的事情如下所示:
from igraph import *
g=Graph.Tree(127,2)
print(g.diameter())
print(g.average_path_length())
print(g.density())
print(g.components())
结果是:
>>> 12
>>> 8.3509
>>> 0.015
>>> Clustering with 127 elements and 1 clusters
我不知道第二个输出来自哪里,但它肯定不是来自igraph。 – 2014-09-04 01:02:43
@GaborCsardi - 我在这里遇到了igraph总结第二个输出示例:http://www.cs.rhul.ac.uk/home/tamas/development/igraph/tutorial/tutorial.html – 2014-09-04 01:07:38
这已经过时了,这里是新的版本:http://igraph.org/python/doc/tutorial/tutorial.html – 2014-09-04 02:05:32