igraph / rigraph

igraph R package
https://r.igraph.org
549 stars 200 forks source link

Crash in plot(graph, layout=layout_with_gem) when graph is singleton #563

Closed clpippel closed 2 years ago

clpippel commented 2 years ago

Describe the bug Crash in plot(graph, layout=layout_with_gem) when graph is singleton

To reproduce

require(igraph)
g <- make_graph(c(), 1)
lyt <- add_layout_(g);        ; plot(g, layout=lyt) 
lyt <- component_wise(g)      ; plot(g, layout=lyt) 
lyt <- layout_as_star(g)      ; plot(g, layout=lyt) 
lyt <- layout_in_circle(g)    ; plot(g, layout=lyt) 
lyt <- layout_nicely(g)       ; plot(g, layout=lyt) 
lyt <- layout_on_grid(g)      ; plot(g, layout=lyt) 
lyt <- layout_on_sphere(g)    ; plot(g, layout=lyt) 
lyt <- layout_randomly(g)     ; plot(g, layout=lyt) 
lyt <- layout_with_dh(g)      ; plot(g, layout=lyt) 
lyt <- layout_with_fr(g)      ; plot(g, layout=lyt) 
lyt <- layout_with_graphopt(g); plot(g, layout=lyt) 
lyt <- layout_with_kk(g)      ; plot(g, layout=lyt) 
lyt <- layout_with_lgl(g)     ; plot(g, layout=lyt) 
lyt <- layout_with_sugiyama(g); plot(g, layout=lyt)
## no problem until:
lyt <- layout_with_gem(g)     ; plot(g, layout=lyt) # <<< crash

Version information Which version of igraph are you using? [1] igraph_1.3.4

ntamas commented 2 years ago

Seems to be a bug in the C core; the code sometimes crashes for me, sometimes succeeds without issues.

ntamas commented 2 years ago

The C core fixed this in https://github.com/igraph/igraph/commit/25cb85205b862af4078624ed6be5ac1e54848884 . Fix incorporated into the R interface in commit 7f357916