zakarumych / egui-snarl

Customizable egui node-graph library
https://crates.io/crates/egui-snarl
MIT License
287 stars 28 forks source link

Count number of connected outputs #32

Closed dignifiedquire closed 2 months ago

dignifiedquire commented 2 months ago

Hey thanks for the cool library! I am trying to count the number of currently connected outputs on a single node, could only come up with this so far

let num_connections = snarl.wires().filter(|(output, input)| {
    output.node == pin.id.node
}).count();

but this is quite expensive as I have to iterate over all wires. Is there a way to do this I am not seeing?

dignifiedquire commented 2 months ago

nevermind this is given by pin.remotes, I was confused

dignifiedquire commented 2 months ago

actually it isn't, as that only gives me that info on per output basis

zakarumych commented 2 months ago

Searching through all wires is intended way to do it right now.

I can add dedicated methods, but they will do it same way. However they might be optimized someday.