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 =====
#
# version
GRAPH_VER=2.12
# prepare source
tar -jxf graph-tool-${GRAPH_VER}.tar.bz2
cd graph-tool-${GRAPH_VER}/
export CFLAGS="-O3 -mavx"
export CXXFLAGS=${CFLAGS}
CGAL_ROOT=/system/software/linux-x86_64/lib/cgal/4.3
MPFR_ROOT=/system/software/linux-x86_64/lib/mpfr/3.1.2
GMP_ROOT=/system/software/linux-x86_64/lib/gmp/5.1.3
SPARSEHASH_ROOT=/system/software/linux-x86_64/lib/sparsehash/gcc-4.8.2/2.0.2
PKG_CONFIG_PATH=/system/software/linux-x86_64/lib/cairomm/1.12.0/lib/pkgconfig
PKG_CONFIG_PATH=/system/software/linux-x86_64/lib/pixman/0.32.8/lib/pkgconfig:$PKG_CONFIG_PATH
PKG_CONFIG_PATH=/system/software/linux-x86_64/lib/cairo/1.14.6/lib/pkgconfig:$PKG_CONFIG_PATH
PKG_CONFIG_PATH=/system/software/linux-x86_64/lib/sigc++/2.6.2/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH
#
# ===== Python 2.* =====
#
# python / compiler combo
module load python/2.7__gcc-4.8
module swap gcc/4.8.2 gcc/4.9.2 ### TRICK 1
# python / boost combo
PYTHON_ROOT=/system/software/linux-x86_64/python/2.7.6__gcc-4.8.2
BOOST_ROOT=/system/software/linux-x86_64/lib/boost/python2.7/1_55_0
# includes and libraries
export CPPFLAGS="-I${BOOST_ROOT}/include -I${CGAL_ROOT}/include
-I${MPFR_ROOT}/include -I${GMP_ROOT}/include -I${SPARSEHASH_ROOT}/include"
export LDFLAGS="-L${BOOST_ROOT}/lib -lboost_python -lboost_iostreams
-lboost_regex -lboost_graph -L${PYTHON_ROOT}/lib -lpython2.7
-L${CGAL_ROOT}/lib"
export CGAL_LIBADD="-L${CGAL_ROOT}/lib"
export LD_LIBRARY_PATH=${BOOST_ROOT}/lib:${LD_LIBRARY_PATH}
make install
#
# ===== Python 3.* =====
#
# python / compiler combo
module load python/3.3__gcc-4.8
# python / boost combo
PYTHON_ROOT=/system/software/linux-x86_64/python/3.3.2__gcc-4.8.2
BOOST_ROOT=/system/software/linux-x86_64/lib/boost/python3.3/1_55_0
# includes and libraries
export CPPFLAGS="-I${BOOST_ROOT}/include -I${CGAL_ROOT}/include
-I${MPFR_ROOT}/include -I${GMP_ROOT}/include -I${SPARSEHASH_ROOT}/include"
export LDFLAGS="-L${BOOST_ROOT}/lib -lboost_python -lboost_iostreams
-lboost_regex -lboost_graph -L${PYTHON_ROOT}/lib -lpython3.3m
-L${CGAL_ROOT}/lib"
export CGAL_LIBADD="-L${CGAL_ROOT}/lib"
export LD_LIBRARY_PATH=${BOOST_ROOT}/lib:${LD_LIBRARY_PATH}
#
# ===== Common =====
#
# configure
./configure \
--prefix=/system/software/linux-x86_64/graph-tool/${GRAPH_VER} \
--enable-openmp \
--with-boost=${BOOST_ROOT} \
--with-sparsehash-prefix=${SPARSEHASH_ROOT}/include/sparsehash
NOTE: The prefix furnished to configure is for installing documentation.
Deleted after installation.
# build and install
make -j 8
make install
### TRICK 2
mv
/system/software/linux-x86_64/python/2.7.8__gcc-4.8.2/lib/python2.7/site-packages/graph_tool
\
/system/software/linux-x86_64/lib/python2.7/site-packages
Juan Manuel Tirado wrote
> 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
--
View this message in context:
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/Segmentation-fault-using-shortest-distance-tp2144146p4026495.html
Sent from the Main discussion list for the graph-tool project mailing list
archive at Nabble.com.
_______________________________________________
graph-tool mailing list
[email protected]
http://lists.skewed.de/mailman/listinfo/graph-tool