A ComfyUI extension to apply better nodes layout algorithm to ComfyUI workflow (mostly for visualization purpose)
a ComfyUI extension to apply better nodes layout algorithm to ComfyUI workflow (mostly for visualization purpose)
this repo is a working prototype of my proof-of-concept in comfyanonymous/ComfyUI#1547
there’s already an 1-click auto-arrange graph but it relies on default arrange()
of LiteGraph.js
(backbone of ComfyUI) which positions the nodes according to level of dependencies, it’s neat but imo the wires are very disorientated (for visualization purpose)
my ideal is to have all wires visible, in term of direction, flow and connection to nodes
from my very limited understanding, most if not all ComfyUI workflows can be qualified as directed acyclic graph, so we can apply better graph drawing algorithms, in particular here i focus on hierarchical graph drawing the most suitable for directed acyclic graph
credit: inspiration from this comment
disclaimer: personal preference, graph very much larger, not always guarantee a better layout for all use-cases
the principle is use an external library to calculate all nodes position, then retrieve back to LiteGraph.js
recommend to remove reroute nodes:
requirements:
bc76b38
implemented algorithms:
undo/redo possible with https://github.com/bmad4ever/ComfyUI-Bmad-DirtyUndoRedo
2 options to control layout density:
TODO:
using noisy latent composition example
(the empty black rectangle box is browser viewport)
original workflow: remove groups coz 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 for DAG):