From 5566c6a0bf9465774262863ebf7bf79385180499 Mon Sep 17 00:00:00 2001 From: FeelUs Date: Tue, 30 Sep 2025 16:18:24 +0300 Subject: [PATCH 1/3] add option neato -n3 (like neato -n2 but graphviz do clip_and_install) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This squashes other commits: • man dot for neato -n3 • neato -n3: minor fixes • neato -n3: code style --- CHANGELOG.md | 5 +++++ cmd/dot/dot.1 | 4 ++++ lib/neatogen/neatoinit.c | 2 +- lib/neatogen/neatosplines.c | 13 +++++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d91d0ecb7..e749d3fa57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased (14.0.2)] +### Added + +- Added option `neato -n3` for fit ends of edges to nodes' borders when edge + trajectory is set. + ### Changed - Quartz plugin code paths to support older macOS and iOS versions have been diff --git a/cmd/dot/dot.1 b/cmd/dot/dot.1 index b5ab4fae89..1f66dfda08 100644 --- a/cmd/dot/dot.1 +++ b/cmd/dot/dot.1 @@ -623,6 +623,10 @@ with no adjustment to remove node\(hynode overlaps, and use any edge layouts already specified by the pos attribute. neato computes an edge layout for any edge that does not have a \fBpos\fP attribute. As usual, edge layout is guided by the \fBsplines\fR attribute. +.nf + num = 3 +.fi +Also fit ends of edges to nodes' borders. .PP \fB\-K\fIlayout\fR override the default layout engine implied by the command name. .PP diff --git a/lib/neatogen/neatoinit.c b/lib/neatogen/neatoinit.c index f5847e9336..5068fb6217 100644 --- a/lib/neatogen/neatoinit.c +++ b/lib/neatogen/neatoinit.c @@ -591,7 +591,7 @@ int init_nop(Agraph_t * g, int adjust) freeEdgeInfo (g); posEdges = NoEdges; } - if (posEdges != AllEdges) + if (posEdges != AllEdges || Nop==3) spline_edges0(g, false); /* add edges */ else State = GVSPLINES; diff --git a/lib/neatogen/neatosplines.c b/lib/neatogen/neatosplines.c index 7a23a0f6c5..01befe0720 100644 --- a/lib/neatogen/neatosplines.c +++ b/lib/neatogen/neatosplines.c @@ -658,6 +658,19 @@ static int spline_edges_(graph_t *g, expand_t *pmargin, int edgetype) { node_t *head = aghead(e); if (useEdges && ED_spl(e)) { addEdgeLabels(e); + if (Nop == 3 && ED_spl(e)->size>0) { + // use first bezier, start point and end point will lost + if(ED_spl(e)->size>1) + agwarningf("edge %s -> %s : set more than one spline. First used, other dropped.\n", agnameof(n), agnameof(head)); + bezier *bez = ED_spl(e)->list; + size_t sz = bez->size; + bez->size = 0; + pointf *pb = bez->list; + bez->list = NULL; + gv_free_splines(e); + clip_and_install(e, head, pb, sz, &sinfo); + free(pb); + } } else if (ED_count(e) == 0) continue; /* only do representative */ else if (n == head) { /* self arc */ -- GitLab From 93ddb67c05e2cdf98be7be077995a8edf83dab0e Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 17 Oct 2025 18:19:06 -0700 Subject: [PATCH 2/3] neatogen: style fixes to the previous commit Style in these files is not particularly consistent, but I would like to at least not go backwards. --- lib/neatogen/neatoinit.c | 2 +- lib/neatogen/neatosplines.c | 27 ++++++++++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/neatogen/neatoinit.c b/lib/neatogen/neatoinit.c index 5068fb6217..e6c365339f 100644 --- a/lib/neatogen/neatoinit.c +++ b/lib/neatogen/neatoinit.c @@ -591,7 +591,7 @@ int init_nop(Agraph_t * g, int adjust) freeEdgeInfo (g); posEdges = NoEdges; } - if (posEdges != AllEdges || Nop==3) + if (posEdges != AllEdges || Nop == 3) spline_edges0(g, false); /* add edges */ else State = GVSPLINES; diff --git a/lib/neatogen/neatosplines.c b/lib/neatogen/neatosplines.c index 01befe0720..5d478ae060 100644 --- a/lib/neatogen/neatosplines.c +++ b/lib/neatogen/neatosplines.c @@ -658,19 +658,20 @@ static int spline_edges_(graph_t *g, expand_t *pmargin, int edgetype) { node_t *head = aghead(e); if (useEdges && ED_spl(e)) { addEdgeLabels(e); - if (Nop == 3 && ED_spl(e)->size>0) { - // use first bezier, start point and end point will lost - if(ED_spl(e)->size>1) - agwarningf("edge %s -> %s : set more than one spline. First used, other dropped.\n", agnameof(n), agnameof(head)); - bezier *bez = ED_spl(e)->list; - size_t sz = bez->size; - bez->size = 0; - pointf *pb = bez->list; - bez->list = NULL; - gv_free_splines(e); - clip_and_install(e, head, pb, sz, &sinfo); - free(pb); - } + if (Nop == 3 && ED_spl(e)->size > 0) { + // use first bezier, start point and end point will lost + if (ED_spl(e)->size > 1) { + agwarningf("edge %s -> %s : set more than one spline. First used, other dropped.\n", agnameof(n), agnameof(head)); + } + bezier *bez = ED_spl(e)->list; + size_t sz = bez->size; + bez->size = 0; + pointf *pb = bez->list; + bez->list = NULL; + gv_free_splines(e); + clip_and_install(e, head, pb, sz, &sinfo); + free(pb); + } } else if (ED_count(e) == 0) continue; /* only do representative */ else if (n == head) { /* self arc */ -- GitLab From fb43ce6e0c28c3d65437afb5c2243730a042149a Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 17 Oct 2025 18:20:15 -0700 Subject: [PATCH 3/3] add Gitlab issue reference for 'neato -n3' Gitlab: closes #2736 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e749d3fa57..9de489f6e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added option `neato -n3` for fit ends of edges to nodes' borders when edge - trajectory is set. + trajectory is set. #2736 ### Changed -- GitLab