I am trying to use purge_vertices() with a vertex filter to efficiently
remove vertices from a graph. I am seeing different behavior in version
2.2.18 and 2.2.25, both as prebuilt packages for Ubuntu precise (current
"graph-tool" and "python-graph-tool" packages, respectively)
I have a simple example script attached which shows the behavior. If I
run with graph-tool 2.2.18, it works without complaint, e.g.:
$ python graph-tool-play2.py
graph_tool version 2.2.18 (commit 83bb8a49, Tue Nov 13 00:57:29 2012 +0100)
pruning 11
pruning 13
pruning 14
pruning 19
pruning 23
pruning 26
pruning 46
pruning 47
pruning 48
pruning 52
pruning 63
pruning 81
pruning 93
pruning 97
complete
If I run with python-graph-tool 2.2.25, I get a TypeError, e.g.:
$ python graph-tool-play2.py
graph_tool version 2.2.25 (commit feec13d9, Mon Sep 2 00:01:39 2013 +0200)
pruning 10
pruning 12
pruning 13
pruning 18
pruning 22
pruning 25
pruning 45
pruning 46
pruning 47
pruning 51
pruning 62
pruning 80
pruning 92
pruning 96
Traceback (most recent call last):
File "graph-tool-play2.py", line 59, in <module>
g.purge_vertices() # MJH this will die in graph-tool 2.2.25 with a
TypeError. Works in 2.2.18.
File "/usr/lib/python2.7/dist-packages/graph_tool/__init__.py", line
1838, in purge_vertices
new_g = Graph(self, prune=(True, False, False))
File "/usr/lib/python2.7/dist-packages/graph_tool/__init__.py", line
1109, in __init__
vorder.fa = numpy.arange(gv.num_vertices())
File "/usr/lib/python2.7/dist-packages/graph_tool/__init__.py", line
561, in <lambda>
lambda self, v: self.__get_set_f_array(v, False),
File "/usr/lib/python2.7/dist-packages/graph_tool/__init__.py", line
556, in __get_set_f_array
a[m] = v
TypeError: array cannot be safely cast to required type
Why would this fail in 2.2.25? It's entirely possible that I am missing
something basic about how to fly graph-tool.
Any clues appreciated!
Cheers,
Mark.