graph_draw fails for larger graphs when called with vertex_* parameter
Bug reports:
Please follow the general troubleshooting steps first:
-
Are you running the latest graph-tool
version? -
Do you observe the problem with the current git version? -
Are you using Macports or Homebrew? If yes, please submit an issue there instead: https://github.com/Homebrew/brew/issues and https://trac.macports.org/newticket -
Did you compile graph-tool
manually? -
If you answered yes above, did you use the exact same compiler to build graph-tool
,boost-python
andPython
?
Invocation of graph_draw(g, vertex_size=g.degree_property_map('total')) fails with the following error:
ValueError: Received property map for graph <Graph object, directed, with 2044 vertices and 897 edges at 0x7fe73b730c50> (base: <Graph object, directed, with 2044 vertices and 897 edges at 0x7fe73b730c50>), expected: <Graph object, directed, with 6137 vertices and 12952 edges at 0x7fe71fa17198> (base: <Graph object, directed, with 6137 vertices and 12952 edges at 0x7fe71fa17198>)
. This happens only for graphs larger than ~ 1000 vertices. The testgraph.gt
file is available at: https://drive.google.com/open?id=1Akiumz3C-h69GKiuCDczQPyNtczqqMcP
import sys; print('Python %s on %s' % (sys.version, sys.platform))
from graph_tool.all import *
show_config()
g = load_graph('./testgraph.gt')
print('Full graph: ', g)
deg = g.degree_property_map('total')
print('Degree property map shape: ', deg.a.shape)
graph_draw(g, vertex_size=prop_to_size(deg)) # Fails
The output of the script is:
Python 3.7.3 (default, Jun 24 2019, 04:54:02)
[GCC 9.1.0] on linux
version: 2.29dev (commit 07196449, Thu Jun 27 12:58:11 2019 +0200)
gcc version: 9.1.0
compilation flags: -DNDEBUG -fopenmp -O3 -fvisibility=default -fvisibility-inlines-hidden -Wno-deprecated -Wall -Wextra -ftemplate-backtrace-limit=0 -Wno-register
install prefix: /home/michal/.local/bin
python dir: /home/michal/SIP/src/lang/pl/graph/lib/python3.7/site-packages
graph filtering: True
openmp: True
uname: Linux ant 5.1.15-arch1-1-ARCH #1 SMP PREEMPT Tue Jun 25 04:49:39 UTC 2019 x86_64
Full graph: <Graph object, directed, with 6137 vertices and 12952 edges at 0x7fd77e9530b8>
Degree property map shape: (6137,)
However, this works:
pos= sfdp_layout(g)
graph_draw(g, pos=pos, vertex_size=prop_to_size(deg)) # Works
Drawing smaller graphs also works:
gv = GraphView(g, vfilt= lambda v: v.out_degree() > 4)
print('Graph View: ', gv)
deg = gv.degree_property_map('total')
graph_draw(gv, vertex_size=prop_to_size(deg)) # Works
giving output:
Graph View: <GraphView object, directed, with 861 vertices and 1178 edges, edges filtered by (<EdgePropertyMap object with value type 'bool', for Graph 0x7f06405bb7f0, at 0x7f06405c9d30>, False), vertices filtered by (<VertexPropertyMap object with value type 'bool', for Graph 0x7f06405bb7f0, at 0x7f06405c99e8>, False) at 0x7f06405bb7f0>
It seems that there is something wrong with the hierarchical graph layout in graph_draw() - somehow the property map passed as a parameter is modified by the layout algorithm.