



a ComfyUI extension that applies an improved node layout algorithm to ComfyUI workflows, primarily for better visualization
this serves as a working prototype of the proof-of-concept detailed in Comfy-Org/ComfyUI#1547
while ComfyUI includes a 1-click auto-arrange feature based on LiteGraph.js’s default arrange() method, which organizes nodes by dependency levels, i find its wire orientation often leads to visual clutter
for better visualization, my goal is to ensure all connections are clearly visible, indicating their direction, flow, and specific node attachments
given my limited understanding, it appears most (if not all) ComfyUI workflows can be classified as directed acyclic graphs; this suggests that more advanced graph drawing algorithms could be applied; specifically, i’m focusing on hierarchical graph drawing, which seems particularly well-suited for directed acyclic graphs.
credit: this approach was inspired by this comment
disclaimer: this reflects a personal preference, and it often produces larger graphs
[!IMPORTANT]
it’s recommended to remove ‘ReRoute’ nodes from your ComfyUI workflows prior to applying the layout
Here’s why:
It’s worth noting that since ComfyUI workflows are inherently oriented from left to right, the concept of ‘depth’ is more accurately described as a ‘column’ or ‘rank’ within this hierarchical context.
[!WARNING]
As per issue #8 changes to graph not visible until Undo + Redo. I struggle to reproduce this bug with my machine, if u have any additional information please share in #8
Installation: via ComfyUI Manager for ease of use, or clone this repository manually using git if you’re developing (no additional requirements needed)
Using:
the principle is to use an external library to compute all nodes position, then retrieve back to LiteGraph.js
requirements: ComfyUI version ≥ 0.12.3
implemented algorithms:
2 options to control layout density:
TODO
using noisy latent composition example
(the empty black rectangle box is browser viewport)
remove groups because nodes gonna be placed very differently
LiteGraph.js default auto-arrange:Dagre.js layout:ELK.js ‘layered’ layout:other possible graph layout in JS (but unsatisfying to me nor suitable for DAG):