Segmentation fault using shortest_distance

Hi Tiago,

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?

Thanks so much,

Juan

attachment.html (1.1 KB)

Hi Juan,

Here it is the output from the show_config()

gt.show_config()
version: 2.2.5 (commit 3ba24072, Sun Feb 21 00:46:41 2010 +0100)
gcc version: 4.4.1
compilation flags: -I/usr/include/python2.6 -I/usr/include
-I/usr/lib/python2.6/dist-packages/numpy/core/include/numpy
-I/usr/lib/python2.6/dist-packages/scipy -O3 -Wall -ftemplate-depth-150
-Wno-deprecated -O99 -fvisibility=default -fvisibility-inlines-hidden
-fopenmp -Wl,-Bsymbolic-functions -L/usr/lib/python2.6 -lpython2.6
install prefix: /usr
python dir: /usr/lib/python2.6/dist-packages
graph filtering: True
openmp: True
uname: Linux 2.6.32-23-generic #37-Ubuntu SMP Fri Jun 11 08:03:28 UTC 2010
x86_64

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.

attachment.html (2.34 KB)

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.

attachment.html (2.96 KB)

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.

Cheers,
Tiago

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.

Thanks so much.

attachment.html (444 Bytes)

Hi Tiago,

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/system/software/linux-x86_64/lib/python2.7/site-packages/numpy/core/include
       
-DSPARSEHASH_PREFIX=/system/software/linux-x86_64/lib/sparsehash/gcc-4.8.2/2.0.2/include
        /sparsehash -Wall -Wextra -ftemplate-backtrace-limit=0 -O3 -mavx
-std=gnu++14 -DNDEBUG
        -ftemplate-depth-250 -Wno-deprecated -Wno-unknown-pragmas -O3
-fvisibility=default -fvisibility-
        inlines-hidden -fopenmp
-DSPARSEHASH_PREFIX=/system/software/linux-x86_64/lib/sparsehash
        /gcc-4.8.2/2.0.2/include/sparsehash
-L/system/software/linux-x86_64/lib/boost/python2.7
        /1_55_0/lib -lboost_python -lboost_iostreams -lboost_regex
-lboost_graph -L/system/software/linux-
        x86_64/python/2.7.8/lib -lpython2.7
-L/system/software/linux-x86_64/lib/cgal/4.3/lib -L/system
        /software/linux-x86_64/python/2.7.8__gcc-4.8.2/lib -lpython2.7
        install prefix: /system/software/linux-x86_64/graph-tool/2.12
        python dir:
/system/software/linux-x86_64/python/2.7.8__gcc-4.8.2/lib/python2.7/site-packages
        graph filtering: True
        openmp: True
        uname: Linux login11 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15
04:27:16 UTC 2014 x86_64
        try shortest distance
        Segmentation fault (core dumped)

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)

# ===== Common =====

I cannot reproduce this. Could you run this under GDB and provide a
backtrace of the segfault?

Also, do you also observe it with the newest version, 2.13?

Best,
Tiago

This is the gdb backtrace:

#0 0x00007fffe29c9bc3 in std::vector<int, std::allocator<int>

::_M_fill_insert(__gnu_cxx::__normal_iterator<int*, std::vector<int,

std::allocator<int> > >, unsigned long, int const&) ()
   from
/system/software/linux-x86_64/lib/python2.7/site-packages/graph_tool/libgraph_tool_core.so
#1 0x00007fffdeaec57d in std::vector<int, std::allocator<int> >::resize ()
   from
/system/software/linux-x86_64/lib/python2.7/site-packages/graph_tool/topology/libgraph_tool_topology.so
#2 0x00007fffdeaeebcb in
do_all_pairs_search::operator()<boost::adj_list<unsigned long>,
boost::typed_identity_property_map<unsigned long>,
boost::unchecked_vector_property_map<std::vector<int, std::allocator<int>

, boost::typed_identity_property_map<unsigned long> >,

graph_tool::ConstantPropertyMap<unsigned long, boost::adj_list<unsigned

::edge_descriptor> > ()

   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.

Thanks and best wishes,
Alice

attachment.html (1.52 KB)

This is the gdb backtrace:

#0 0x00007fffe29c9bc3 in std::vector<int, std::allocator&lt;int>

::_M_fill_insert(__gnu_cxx::__normal_iterator<int*, std::vector&lt;int,

std::allocator&lt;int> > >, unsigned long, int const&) ()
   from
/system/software/linux-x86_64/lib/python2.7/site-packages/graph_tool/libgraph_tool_core.so
#1 0x00007fffdeaec57d in std::vector<int, std::allocator&lt;int> >::resize
()
   from
/system/software/linux-x86_64/lib/python2.7/site-packages/graph_tool/topology/libgraph_tool_topology.so
#2 0x00007fffdeaeebcb in
do_all_pairs_search::operator()<boost::adj_list&lt;unsigned long>,
boost::typed_identity_property_map<unsigned long>,
boost::unchecked_vector_property_map<std::vector&lt;int,
std::allocator&lt;int> >, boost::typed_identity_property_map<unsigned long>

, graph_tool::ConstantPropertyMap<unsigned long, boost::adj_list<unsigned
::edge_descriptor> > ()

   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.

Thanks and best wishes,
Alice