gt.graph_draw throwing error

Hello all,

I am encountering a strange error in the usual gt.graph_draw when I add
vertex_size = degree. It works well every time but this time it is not
working. My code:

G = gt.Graph(directed = False)
G.add_edge_list(edges, hashed = True, string_vals = True)
gt.remove_parallel_edges(G)
lc = gt.Graph(gt.GraphView(G, vfilt = gt.label_largest_component(G)), prune
= True)

deg = lc.new_vertex_property('int')
for v in lc.vertices():
    deg[v] = v.out_degree()

print(lc)
gt.graph_draw(lc, vertex_size = deg)

And I am getting the following error:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/graph_tool/draw/gtk_draw.py", line
503, in draw
    self.fit_to_window(ink=False)
  File "/usr/lib/python3/dist-packages/graph_tool/draw/gtk_draw.py", line
724, in fit_to_window
    cr)
  File "/usr/lib/python3/dist-packages/graph_tool/draw/cairo_draw.py", line
1319, in fit_to_view
    font_size, cr)
  File "/usr/lib/python3/dist-packages/graph_tool/draw/cairo_draw.py", line
1292, in get_bb
    x_delta = [x_range[0] - (pos_x.fa - delta).min(),
ValueError: operands could not be broadcast together with shapes (4,)
(3397,)

I have 3397 vertices in my graph. I would greatly appreciate any help.
Thanks in advance.

Regards
Snehal

attachment.html (1.73 KB)

I can't reproduce this. Please provide a complete, self-contained program
that shows the error. (In the example above the list of edges is missing).

Best,
Tiago

Hello Tiago,

Thanks for the reply. I have attached my full code along with the necessary
data file. Can you please try to run it and see what is the problem?

Thank you
Snehal

attachment.html (3.15 KB)

routes.dat (2.2 MB)

routes.py (885 Bytes)

Hi,

Indeed there is a bug in the interactive drawing for large graphs. I will
fix this soon.

In the meantime, a simple workaround is to get the vertex positions explicitly:

    pos = gt.sfdp_layout(lc)
    gt.graph_draw(lc, pos=pos, vertex_size=deg)

Best,
Tiago

Thanks.. that worked! A small related question: The nodes in my graph are
strings and that's why I am using `hashed = True` and `string_vals = True`.
How can I use these values as labels for my nodes while drawing the graph?
I couldn't find any way to extract these strings to define a new property
map for vertex_text.

Thank you
Snehal

attachment.html (5.98 KB)

The Graph.add_edge_list() method already returns the property map you want.

Best,
Tiago

Thank you very much Tiago.

Best
Snehal

attachment.html (1.59 KB)