r/adventofcode • • Dec 24 '24

Visualization [2024 Day 24 Part 2] Using a graph visualization tool (Mermaid) to identify suspicious wires.

144 Upvotes

18 comments sorted by

View all comments

Show parent comment

1

u/luke2006 Dec 24 '24

i also struggled with mermaid, unable to have more than 500 edges. and when i did it locally, the svg wasn't easily pannable, zoomable. switched over to graphviz spitting out a png, which was slightly better, but the layout wasnt super consistent either (maybe just need to pick a different layout algo). did you face any of these issues?

5

u/burnt_heatshield Dec 24 '24

I just connected the input and output bits too (e.g. x00->x01->x02->..., and same for the y's and z's), that way Graphwiz created a clean chain: https://dreampuf.github.io/GraphvizOnline/...

2

u/E3FxGaming Dec 24 '24

unable to have more than 500 edges. and when i did it locally, the svg wasn't easily pannable, zoomable

Using mermaid-cli, I created a .stats.mermaid.json file in the same directory as the mermaid diagram file, with the following content

{
  "maxEdges": 1000000
}

Then the command to generate a png was

mmdc -i output_corrected.mmd -o output_corrected.png -c .stats.mermaid.json -w 24000 -H 24000

I picked png since it has a white background, wich was much easier to visually comprehend. Also SVG somehow did not show the text on the nodes? I'm sure you can set the background color of the svg somehow and fix the text, but for png it just works.

Gimp had no problems opening the png, I added a second layer and got to work figuring out what had to be changed. The png had a resolution of approx. 11765x21464 (~2.4 MiB), which none of my programs on Linux had a problem with.

1

u/lyon Dec 24 '24

The Neato output in graphviz was pretty good (if you can zoom out to the entire file):
http://offshore.hkolk.nl/~hkolk/graphviz-2.svg

1

u/jlhawn Dec 24 '24

I used pdf output to fix that 😆