How to find the longest path from one node to another in a sufficiently large network

Everyone, I have a question. I need to find the longest path from one node to another in the network. As shown in the figure, it is a directed network, and I currently have no idea how to implement it in the “KNIME” tool. The figure is just a simple example. If the quantity is large enough, how should I implement it.
How to implement without using programming tools such as Python or R?

The figure only shows the following results: node 1 to node 4, node 1 to node 3; Node 5 to Node 4

Hi @lichang , I don’t know how well this will work with a large data set, as internally it uses a recursive loop along, but take a look at the following workflow:

The hard work is inside this component:

which internally looks like this:

Feel free to disconnect it/open it up and have a play! :slight_smile:


Given the following network (based on your picture)

the workflow generates the following result:

Finding the shortest route is much simpler (and faster), as there is a node for that, but not for All Paths or Longest Path… Python or R would no doubt run more quickly.

3 Likes

Hi @takbb
I try to contact you directly but find only this way for a question about your component “all routes between nodes”. In the example joined, the directed path 1, 10, 15, 14, 5 is existing :

but the component doesn’t find it :
image

Have you a hint for this difficulty ?
Here is the workflow :
all paths in network.knwf (68,9 Ko)

Thank you for your help.
Joel

1 Like

Hi @JPollet, thanks for letting me know about the problem with the component. This was caused because I’d inadvertently set a low maximum limit on the number of recursions, so it was exiting before finding all the paths in your network. I have updated the component, and added an additional config for maximum recursions. There needs to be a limit, in case of a huge network which might have far too many combinations of paths. I have set the default at 5000.

I also added some additional small efficiency improvements and as a result I think in your case it now requires about 475 recursive iterations. The previous hard-coded limit was about 400.

If you update your component from the hub (you should find version 2 is present)

You can tell if you have the new version, as it now has the following config:

image

On your data it now returns the following paths:

Sorry for the bug, and thanks again for letting me know. Let me know if you find any other issues. thanks :slight_smile:

3 Likes

Thanks a lot @takbb,
I have pushed the limit to 200 in my tests but not up to 475 ! I will apply your update today.

Best,
Joel