I am trying to calculate the shortest distances of a graph after applying a
filter. I have a code that looks like this:
g=gt.load_graph("myGraph.xml",format="xml")
#for later use
distances = gt.shortest_distance(g)
#extract the components of the graph
comp = g.label_components(g) #This splits the graph in several components #I want to calculate the shortest distances #for the component 2 for example
filtering = g.new_vertex_property("boolean")
for v in g.vertices():
if comp[v]==2:
filtering[v]=True
else:
filtering[v]=False
#set the vertex filter
g.set_vertex_filter(filtering)
distances_comp=gt.shortest_distance(g)
The last line of code rises a segmentation fault. I have plotted the graph
with the filtered graph and its correct, also I can calculate the
local_clustering_coefficient without problems. Am I doing something wrong?
Is there any other way to filter the graph and calculate the shortest
distances? Is this a bug?
I am using the code from the ubuntu package, so I'm not using the latest
2.2.6 version. I will try to install and make a test with the latest
version, as I see it is not available via apt-get.
I have just made a small test. Instead of passing the filtered graph to the
shortest_distance function, I have generated a copy of the filtered graph
and it works fine.
It seems that exist a problem with the shortest_distance function.
Yes, indeed. There was a problem with the property map initialization
in this case. The version in git now contains a fix. Please tell me
if you find any other problems.
Yes, indeed. There was a problem with the property map initialization
in this case. The version in git now contains a fix. Please tell me
if you find any other problems.
I seem to have a similar problem as Juan had a few years back. Using
shortest_distance leads to a segmentation fault. The code below works fine
if I build random networks with less than 100 nodes, but if I increase the
number of nodes to 150 the segmentation fault occurs almost always.
#!/usr/bin/env python
from graph_tool.all import *
show_config()
g = random_graph(150, lambda: (poisson(3), poisson(3)))
print 'try shortest distance'
s = shortest_distance(g) #seg fault occurs here
print 'success!'
This returns:
/system/software/linux-x86_64/lib/python2.7/site-packages/graph_tool/draw/cairo_draw.py:1464:
RuntimeWarning: Error importing Gtk module: No module named gi; GTK+
drawing will not work.
warnings.warn(msg, RuntimeWarning)
version: 2.12 (commit 1d6bf978, Fri Nov 6 15:54:18 2015 +0100)
gcc version: 4.9.2
compilation flags:
-I/system/software/linux-x86_64/lib/boost/python2.7/1_55_0/include -I/system
/software/linux-x86_64/lib/cgal/4.3/include
-I/system/software/linux-x86_64/lib/mpfr/3.1.2/include
-I/system/software/linux-x86_64/lib/gmp/5.1.3/include
-I/system/software/linux-x86_64
/lib/sparsehash/gcc-4.8.2/2.0.2/include
-I/system/software/linux-x86_64/python/2.7.8__gcc-
4.8.2/include/python2.7
-I/system/software/linux-x86_64/lib/boost/python2.7/1_55_0/include
I am wondering if this is a bug or has something to do with how graph-tool
was installed on the computing facilities that I use. The admin told me that
there were some compiler compatibility issues with installing graph-tool.
I've included his notes on the installation process below.
Best,
Alice
# Notes:
# a) the installation was successful (on arcus to be usable across
all systems)
# b) a couple of trickes were needed, both brought on by the fact
that the source
# has to be compiled with a compiler compliant with the 2014 c++
standard
# (this is gcc ver 4.9.2); the tricks are marked clearly in the
recipe below
# c) the python cairo bindings have to be installed (so that "import
cairo" works)
# this is from the library py2cairo (for python 2.7)
from
/system/software/linux-x86_64/lib/python2.7/site-packages/graph_tool/topology/libgraph_tool_topology.so #3 0x00007fffe17e0d16 in gomp_thread_start () at
../../../libgomp/team.c:117 #4 0x0000003d9e6079d1 in start_thread () from /lib64/libpthread.so.0 #5 0x0000003d9e2e89dd in clone () from /lib64/libc.so.6
I will ask the admin team at my university if they can install the newest
version of graph-tool on the system.
from
/system/software/linux-x86_64/lib/python2.7/site-packages/graph_tool/topology/libgraph_tool_topology.so #3 0x00007fffe17e0d16 in gomp_thread_start () at
../../../libgomp/team.c:117 #4 0x0000003d9e6079d1 in start_thread () from /lib64/libpthread.so.0 #5 0x0000003d9e2e89dd in clone () from /lib64/libc.so.6
I will ask the admin team at my university if they can install the newest
version of graph-tool on the system and try 2.13 out then.