jsPlumb.getConnections Order of connections

1,057 views
Skip to first unread message

jol...@fastmail.fm

unread,
Apr 11, 2013, 10:45:15 AM4/11/13
to jsp...@googlegroups.com
Hi.
 
I'm trying to read a chain of nodes(sources and targets) that are connected. From left to right preferably.
Order is important because the nodes each should represent a function to be used later on in code.
 
I'm using jsPlumb.getConnections('*');
 
and with that I get all connections and can extract all the data I need from connections, and so forth.
 
Problem is, the connections-array have the connections ordered in when they
got created. (Which is probably supposed to be happening if they get pushed
into an array at creationtime.)
 
So before I start writing some sort alogaritm I'm wondering if there is
any inbuilt function for this that I have overlooked ?
 
Best regards.
 
 
Message has been deleted

jol...@fastmail.fm

unread,
Apr 11, 2013, 2:24:47 PM4/11/13
to jsp...@googlegroups.com
I realized after some thinking it might be difficicult for Jsplumb
to know what is considered an input VS output for Node endpoints.
Maybe if outputs endpoints where restricted to only 1 endpoint it could be calculated.
 
like so: ---conn---'input'[node]'output'-----conn----'input'[node]'output'-------etc..
 
perhaps with classes or something..

Simon Porritt

unread,
Apr 11, 2013, 6:03:23 PM4/11/13
to jsp...@googlegroups.com
The layout of the nodes is implicit in your data model and varies per application.  jsPlumb doesn't have anything in it that can help you with this.

jol...@fastmail.fm

unread,
Apr 12, 2013, 2:57:51 AM4/12/13
to jsp...@googlegroups.com

Den fredagen den 12:e april 2013 kl. 00:03:23 UTC+2 skrev simon....@gmail.com:
The layout of the nodes is implicit in your data model and varies per application.  jsPlumb doesn't have anything in it that can help you with this.
 
 
I understand. There more I think of this I could see why this wasent included in the 'API', since it's
such a specific case. It's absolutely vital for my project, though. Most unfortunately..
 
I'll see if I can make up some type of sorting function. 
 
BTW,  I'm very happy with Jsplumb so far. SUPER plugin.
Lot's of options.. 
 
Thank you
 
 
 
 

Simon Porritt

unread,
Apr 12, 2013, 3:03:05 AM4/12/13
to jsp...@googlegroups.com
great!  i am actually about to release 1.4.0, which has a bunch more useful things in it.

i read again your initial post; i thought it was about a layout at first but you actually mean you want to derive a path from a set of connected nodes, right?  given N nodes and M connections, find the path. will there only ever be a single path, or is it possible for one node to have been connected to more than one other?  

jol...@fastmail.fm

unread,
Apr 12, 2013, 5:10:03 AM4/12/13
to jsp...@googlegroups.com
Hi.
 
I'm gathering info about how to solve this dilemma. It's proving quite a showstopper :-)
 
The main interest is actually to grab node information in the correct order.
The path is off course one way of doing it, as you describe. Although there can be more
than 1 path leading to 1 node. As visually described in the picture.
That makes things quite harder.
Hope the picture explains it better than I do.
 
Thanks! 1.4.0. Yes!!!
 
.
Den fredagen den 12:e april 2013 kl. 09:03:05 UTC+2 skrev simon....@gmail.com:
node_schematics.jpg

Simon Porritt

unread,
Apr 12, 2013, 5:56:46 AM4/12/13
to jsp...@googlegroups.com
When you say you "node information in the correct order", I guess you mean for all possible paths then?

What i would suggest you do is that you bind to the "jsPlumbConnection" and "jsPlumbConnectionDetached" events on jsPlumb, and maintain the model separately yourself. For each node you can have a list of nodes that connect to it, as well as a list of nodes it connects to, and you update these lists when you receive an event from jsPlumb.

Then whenever you want to go through and retrieve node information, you'd basically loop through your model ,and for each node that has no previous nodes, recurse down through that node's "children" and their "children" etc.  In that way you could easily put together a list of unique paths.  just make sure you don't get stuck in an infinite loop, ie. check each time you add a new child that it does not already exist in the path.




jol...@fastmail.fm

unread,
Apr 12, 2013, 6:26:06 AM4/12/13
to jsp...@googlegroups.com
"node information in correct order" , further explained:
That means each node is representing a method/function and the inputs are arguments.
Chaining methods-nodes in the correct order is vital, then off course.
So this is basically visual programming, I suppose. 
 
I will be sending this information to another program that executes these methods.
Can't reveal any details regarding that program yet, though. Not officially anyway..
 
Thank you for the pseudo-code. It will be useful.
 
I'm using ver 1.3.9 currently (did not manage go through compiling 1.4).
And looking through the 1.4 doc I see some additions that would
be helpful in retreiving endpoint information. So I look forward to that!!
 
Thanks for all the help.
Reply all
Reply to author
Forward
0 new messages