From: Emden R. Gansner Date: Sat, 2 Aug 2014 16:24:15 +0000 (-0400) Subject: Smoothing using triangles needs at least 3 nodes. X-Git-Tag: TRAVIS_CI_BUILD_EXPERIMENTAL~181 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c3ac0b75744dec6a964fc8d3f8afee9db44b5a9b;p=graphviz Smoothing using triangles needs at least 3 nodes. --- diff --git a/lib/sfdpgen/post_process.c b/lib/sfdpgen/post_process.c index 9ad29ea05..4adc2ec5a 100644 --- a/lib/sfdpgen/post_process.c +++ b/lib/sfdpgen/post_process.c @@ -1281,14 +1281,16 @@ void post_process_smoothing(int dim, SparseMatrix A, spring_electrical_control c case SMOOTHING_RNG: case SMOOTHING_TRIANGLE:{ TriangleSmoother sm; - - if (ctrl->smoothing == SMOOTHING_RNG){ - sm = TriangleSmoother_new(A, dim, 0, x, FALSE); - } else { - sm = TriangleSmoother_new(A, dim, 0, x, TRUE); + + if (A->m > 2) { /* triangles need at least 3 nodes */ + if (ctrl->smoothing == SMOOTHING_RNG){ + sm = TriangleSmoother_new(A, dim, 0, x, FALSE); + } else { + sm = TriangleSmoother_new(A, dim, 0, x, TRUE); + } + TriangleSmoother_smooth(sm, dim, x); + TriangleSmoother_delete(sm); } - TriangleSmoother_smooth(sm, dim, x); - TriangleSmoother_delete(sm); break; } case SMOOTHING_STRESS_MAJORIZATION_GRAPH_DIST: