我刚刚编写了一个 python 脚本来使用 igraph 模块执行优化模块,这个函数使用了 GLPK 库,但是即使在安装了 python-glpk 和几乎所有与 glpk 相关的包之后我也会收到这个错误:
root@ubuntu:/home/abdou/Desktop/graphs# python graph.py
Traceback (most recent call last):
File "graph.py", line 49, in <module>
print g.community_optimal_modularity()
File "/usr/lib/python2.7/dist-packages/igraph/__init__.py", line 1076, in community_optimal_modularity
GraphBase.community_optimal_modularity(self, *args, **kwds)
NotImplementedError: Error at optimal_modularity.c:81: GLPK is not available, Unimplemented function call
这是脚本:
from igraph import *
g = Graph()
g.add_vertex(1)
.
.
.
g.add_vertex(20)
g.add_edge(1,2)
g.add_edge(12,0)
plot(g)
print g.community_optimal_modularity()
verClus = VertexClustering(g)
plot(verClus.cluster_graph())