Reputation: 33
I just wrote a python script to do optimal_modularity using the igraph module, this function makes use of the GLPK library, but I'm getting this error even after installing python-glpk and practically all glpk related packages :
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
This is the script :
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())
Upvotes: 0
Views: 1458
Reputation: 1
I am using clustering methods and get membership instead. Hope this may help for MacOS user since I also had trouble with GLPK.
Upvotes: 0
Reputation: 48071
python-igraph
depends on the igraph library, which is written in C. Depending on how you installed python-igraph
, it may or may not be compiled with GLPK support. Since the code that uses GLPK from python-igraph
is in the C layer, it does not matter if you install GLPK after the compilation of python-igraph
or if you install python-glpk
; the only thing that matters is whether GLPK was present on your machine when you compiled python-igraph
for the first time.
So, assuming that you installed python-igraph
using pip
and you did not have the C core of igraph in advance on your machine, you will need to:
python-glpk
(it won't be needed).python-igraph
.python-igraph
.python-igraph
should then detect that GLPK itself is installed (look for a line containing GLPK support -- yes
or something similar in the early stages when python-igraph
downloads the corresponding C core and tries to compile it) and you will be able to use Graph.optimal_modularity()
from then on.
Upvotes: 2