feat: Add layout options to mermaid renderer#288
Merged
Conversation
Merging this PR will degrade performance by 21.34%
Performance Changes
Comparing |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #288 +/- ##
==========================================
+ Coverage 83.06% 83.12% +0.06%
==========================================
Files 30 31 +1
Lines 7670 7704 +34
Branches 7670 7704 +34
==========================================
+ Hits 6371 6404 +33
- Misses 1199 1200 +1
Partials 100 100 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ss2165
approved these changes
Apr 13, 2026
Merged
github-merge-queue bot
pushed a commit
that referenced
this pull request
Apr 13, 2026
## 🤖 New release * `portgraph`: 0.16.0 -> 0.16.1 (✓ API compatible changes) <details><summary><i><b>Changelog</b></i></summary><p> <blockquote> ## [0.16.1](v0.16.0...v0.16.1) - 2026-04-13 ### New Features - Add layout options to mermaid renderer ([#288](#288)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gives some basic control over mermaid's layout option:
https://mermaid.js.org/intro/syntax-reference.html#selecting-layout-algorithms
Changes the default to use
elk, to work around this bug: mermaid-js/mermaid#7609.This is mostly noticeable on larger graphs, where
elkproduces a tighter node layout:Before:
graph LR subgraph 0 ["(0) Module"] direction LR subgraph 1 ["(1) [**FuncDefn: #quot;__main__.foo#quot;**]"] direction LR style 1 stroke:#832561,stroke-width:3px 2["(2) Input"] 3["(3) Output"] subgraph 4 ["(4) CFG"] direction LR subgraph 5 ["(5) DataflowBlock"] direction LR 6["(6) Input"] 7["(7) Output"] 8["(8) LoadConstant"] 9["(9) const:custom:u64(0)"] 10["(10) Tag"] 6--"0:1<br>bool"-->7 6--"1:2<br>bool"-->7 8--"0:3<br>int(6)"-->7 9--"0:0<br>int(6)"-->8 10--"0:0<br>Unit"-->7 end 11["(11) ExitBlock"] subgraph 12 ["(12) DataflowBlock"] direction LR 13["(13) Input"] 14["(14) Output"] 15["(15) tket.bool.read"] 13--"0:0<br>bool"-->15 13--"1:1<br>bool"-->14 13--"2:2<br>int(6)"-->14 15--"0:0<br>Bool"-->14 end subgraph 16 ["(16) DataflowBlock"] direction LR 17["(17) Input"] 18["(18) Output"] 19["(19) tket.bool.read"] 17--"0:1<br>bool"-->18 17--"0:0<br>bool"-->19 17--"1:2<br>int(6)"-->18 19--"0:0<br>Bool"-->18 end subgraph 20 ["(20) DataflowBlock"] direction LR 21["(21) Input"] 22["(22) Output"] 23["(23) tket.bool.read"] 21--"0:0<br>bool"-->23 21--"1:1<br>int(6)"-->22 23--"0:0<br>Bool"-->22 end subgraph 24 ["(24) DataflowBlock"] direction LR 25["(25) Input"] 26["(26) Output"] 27["(27) LoadConstant"] 28["(28) const:custom:u64(1)"] 29["(29) arithmetic.int.iadd"] 30["(30) Tag"] 25--"0:1<br>bool"-->26 25--"1:0<br>int(6)"-->29 27--"0:1<br>int(6)"-->29 28--"0:0<br>int(6)"-->27 29--"0:2<br>int(6)"-->26 30--"0:0<br>Unit"-->26 end subgraph 31 ["(31) DataflowBlock"] direction LR 32["(32) Input"] 33["(33) Output"] 34["(34) LoadConstant"] 35["(35) const:custom:u64(2)"] 36["(36) arithmetic.int.iadd"] 37["(37) Tag"] 32--"0:1<br>bool"-->33 32--"1:0<br>int(6)"-->36 34--"0:1<br>int(6)"-->36 35--"0:0<br>int(6)"-->34 36--"0:2<br>int(6)"-->33 37--"0:0<br>Unit"-->33 end subgraph 38 ["(38) DataflowBlock"] direction LR 39["(39) Input"] 40["(40) Output"] 41["(41) LoadConstant"] 42["(42) const:custom:u64(5)"] 43["(43) arithmetic.int.ilt_s"] 44["(44) tket.bool.make_opaque"] 45["(45) Tag"] 39--"0:2<br>bool"-->40 39--"1:3<br>int(6)"-->40 39--"1:0<br>int(6)"-->43 41--"0:1<br>int(6)"-->43 42--"0:0<br>int(6)"-->41 43--"0:0<br>Bool"-->44 44--"0:1<br>bool"-->40 45--"0:0<br>Unit"-->40 end subgraph 46 ["(46) DataflowBlock"] direction LR 47["(47) Input"] 48["(48) Output"] 49["(49) LoadConstant"] 50["(50) const:custom:u64(2)"] 51["(51) arithmetic.int.imul"] 52["(52) Tag"] 47--"0:0<br>int(6)"-->51 49--"0:1<br>int(6)"-->51 50--"0:0<br>int(6)"-->49 51--"0:1<br>int(6)"-->48 52--"0:0<br>Unit"-->48 end subgraph 53 ["(53) DataflowBlock"] direction LR 54["(54) Input"] 55["(55) Output"] 56["(56) LoadConstant"] 57["(57) const:custom:u64(3)"] 58["(58) arithmetic.int.imul"] 59["(59) Tag"] 54--"0:0<br>int(6)"-->58 56--"0:1<br>int(6)"-->58 57--"0:0<br>int(6)"-->56 58--"0:1<br>int(6)"-->55 59--"0:0<br>Unit"-->55 end subgraph 60 ["(60) DataflowBlock"] direction LR 61["(61) Input"] 62["(62) Output"] 63["(63) Tag"] 61--"0:1<br>int(6)"-->62 63--"0:0<br>Unit"-->62 end 5-."0:0".->12 12-."0:0".->20 12-."1:0".->16 16-."0:0".->24 16-."1:0".->31 20-."0:0".->46 20-."1:0".->53 24-."0:0".->38 31-."0:0".->38 38-."0:0".->12 46-."0:0".->60 53-."0:0".->60 60-."0:0".->11 end 2--"0:0<br>bool"-->4 2--"1:1<br>bool"-->4 4--"0:0<br>int(6)"-->3 end endAfter:

(github markdown does not support
elk, and falls back to the default kernel instead)