Finding all links between two given nodes

Hello folks,

I’ve been working with a workflow built on GoJS for a while, and i’ve now run into an issue that I possibly need some developer help with.

Our application is built in Extjs, and our workflows need to visualize a sequence of tasks, each with a swimlane group attached.

I have the basic groups working, and I will post another question about some explanations on how to properly implement swimlanes, but this one is about finding node depths.

So far I’ve been experimenting with the Node class and it appeared at first glance to have the very method I need: findLinksTo().

However, to my disappointment, it does not seem to find all links between two nodes, but only returns a non-zero value if the two nodes are actual neighbours. Our nodes will only ever have one link between them, but a node may be at 1 link from the origin, or it may be 10 links away.

I need to know this depth number so that I can position them correctly in the gridlayout.

I also tried to create a recursive function that would be able to get the links between nodes, but this fails as the function itself needs a loop to get an iterable object. (quite possibly my skills are at fault here, but nonetheless…)

We are currently using version 1.3.7 of the library.

My question is: How can we find the amount of nodes or links between two given nodes on a diagram, regardless of whether they are directly connected?

Here’s one way to find the distances between nodes: http://gojs.net/latest/samples/distances.html

But it isn’t clear to me if you need to find all shortest paths from one node to another, if any.

What I need is the following:

When I have a set of nodes, I want the shortest route from the input to that node. The route can consist of just one link, 2 links and one node, 3 links and 2 nodes etc…

I want to be able to count the number of links (shortest route indeed) between the input connector and the node I specify, and there does not seem to be a method for doing that that I could find.

Additionally, the search only has to work one way (from the input to a node) it is not necessary to use this between arbitrary nodes or in all directions, and don’t care about ALL links, just the shortest one.

OK, I have extended that sample to show a shortest path (if any exists) between the first selected node and a second selected node.

http://gojs.net/latest/samples/distances.html

This uses the new in version 1.4 Part.isHighlighted property and related Diagram methods to do the highlighting.