From d2463f41b52feaaa287471f43952696ffb496e61 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Wed, 11 Jun 2025 18:04:21 +0200 Subject: [PATCH] Tidy-tree WIP --- cypress/platform/knsv2.html | 1 + instructions.md | 131 +++++++ .../tidy-tree/cytoscape-setup.test.ts | 281 -------------- .../tidy-tree/cytoscape-setup.ts | 207 ---------- .../layout-algorithms/tidy-tree/index.ts | 38 +- .../tidy-tree/layout.test.ts | 362 +++++++++++------- .../layout-algorithms/tidy-tree/layout.ts | 352 +++++++++++++++-- .../layout-algorithms/tidy-tree/render.ts | 72 ++-- .../layout-algorithms/tidy-tree/types.ts | 25 +- 9 files changed, 769 insertions(+), 700 deletions(-) create mode 100644 instructions.md delete mode 100644 packages/mermaid/src/rendering-util/layout-algorithms/tidy-tree/cytoscape-setup.test.ts delete mode 100644 packages/mermaid/src/rendering-util/layout-algorithms/tidy-tree/cytoscape-setup.ts diff --git a/cypress/platform/knsv2.html b/cypress/platform/knsv2.html index 431e139a5..f51da5039 100644 --- a/cypress/platform/knsv2.html +++ b/cypress/platform/knsv2.html @@ -116,6 +116,7 @@ Tools Pen and paper Mermaid + Third
       ---
diff --git a/instructions.md b/instructions.md
new file mode 100644
index 000000000..d30b7ea8d
--- /dev/null
+++ b/instructions.md
@@ -0,0 +1,131 @@
+Please help me to implement the tidy-tree algorithm.
+* I have added a placeholder with the correct signature in `packages/mermaid/src/rendering-util/layout-algorithms/tidy-tree/`.
+
+Replace the cytoscape layout with one using tidy-tree.
+
+This is the API for tidy-tree:
+```
+# non-layered-tidy-tree-layout
+
+Draw non-layered tidy trees in linear time.
+
+> This a JavaScript port from the project [cwi-swat/non-layered-tidy-trees](https://github.com/cwi-swat/non-layered-tidy-trees), which is written in Java. The algorithm used in that project is from the paper by _A.J. van der Ploeg_, [Drawing Non-layered Tidy Trees in Linear Time](http://oai.cwi.nl/oai/asset/21856/21856B.pdf). There is another JavaScript port from that project [d3-flextree](https://github.com/Klortho/d3-flextree), which depends on _d3-hierarchy_. This project is dependency free.
+
+## Getting started
+
+### Installation
+
+```
+npm install non-layered-tidy-tree-layout
+```
+
+Or
+
+```
+yarn add non-layered-tidy-tree-layout
+```
+
+There's also a built verison: `dist/non-layered-tidy-tree-layout.js` for use with browser `