Commit 4fb60b70 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix bug when drawing empty graphs.

parent a0f67bbd
......@@ -738,6 +738,8 @@ def get_bb(g, pos, size, pen_width, size_scale=1, text=None, font_family=None,
def fit_to_view(g, pos, geometry, size, pen_width, M=None, text=None,
font_family=None, font_size=None, cr=None):
if g.num_vertices() == 0:
return [0, 0], 1
if M is not None:
pos_x, pos_y = ungroup_vector_property(pos, [0, 1])
P = np.zeros((2, len(pos_x.fa)))
......
......@@ -310,7 +310,7 @@ class GraphWidget(Gtk.DrawingArea):
def layout_callback(self):
"""Perform one step of the layout algorithm."""
if self.layout_callback_id is None:
if self.layout_callback_id is None or self.g.num_vertices() == 0:
return False
pos_temp = ungroup_vector_property(self.pos, [0, 1])
sfdp_layout(self.g, K=self.layout_K,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment