jagenjo / litegraph.js

A graph node engine and editor written in Javascript similar to PD or UDK Blueprints, comes with its own editor in HTML5 Canvas2D. The engine can run client side or server side using Node. It allows to export graphs as JSONs to be included in applications independently.
MIT License
5.33k stars 602 forks source link

Multiple connections to/from ports #447

Open ERnsTL opened 3 months ago

ERnsTL commented 3 months ago

From what I have gathered, litegraph.js currently does not support connecting multiple connections to or from a single port (array ports / index ports). A situation like that (generic example graphic):

grafik

Is this a known issue, or any plans regarding priority / roadmap?

If I oversaw this in the Demo, please forgive me.

How would one go about adding these features? Pointers on where to start appreciated.

CHollman82 commented 3 months ago

Multiple outputs work fine... the problem with multiple inputs is the graph is parsed in reverse, from the final node back... and when it reaches a split it has to make a decision. I guess one way to handle it would be to instantiate a new "job" every time it encounters a branch (again, headed in reverse, so a branch would be a multiple-input) but that could very quickly become unreasonable, to attempt to instantiate each possible combination. Some of the graphs I've used could have thousands, easily.

Look at your example... imagine parsing it in reverse... do you see the ambiguity there?

Edit: Just wanted to note that I make use of Litegraph as it is implemented in ComfyUI (listed on the main page) and it definitely does allow for multiple output connections. I'm not sure if that is something they added themselves or not though, I've never used litegraph by itself/"pure"

atlasan commented 1 week ago

Multi output works just fine. Multi input should be allowed by the node itself. A multi input event type would work fine if correctly coded, a multi input "object" reference could execute multiple times for each element, a multi input that would accept a single value or an array could consider the single inputs as part of the array. Anyway there are many places in the library to be recoded, that's a big challange. A solution is using helpers nodes in the middle: for events using a sequencer event node, for other types a node that allows dynamic inputs and merge em into an array and that use that as input (alternatively one could directly code the dyn multi input in the final node itself)