igraph / igraph

Library for the analysis of networks
https://igraph.org
GNU General Public License v2.0
1.75k stars 405 forks source link

igraph_layout_kamada_kawai() gives NaN for P_2 graph #2074

Closed szhorvat closed 2 years ago

szhorvat commented 2 years ago

Describe the bug

igraph_layout_kamada_kawai() gives NaN for the 2-vertex path graph.

To reproduce

> layout_with_kk(make_graph(c(1,2)))
           [,1]         [,2]
[1,]        NaN          NaN
[2,] -0.5091169 6.234884e-17

Version information

Current master, does not happen with 0.9.8.

szhorvat commented 2 years ago

@GroteGnoom If you have time, it would be useful to have a test for layout_kamada_kawai(). Something along the lines of what you added for FR would be perfect, as it will detect NaNs.

As for this issue, I'll fix it.

szhorvat commented 2 years ago

This bug is identical to #1462, now updating the fix used for that issues.