An effective way to get all the possible paths + special details

I ran into the problem of finding a path in which I must find all possible paths from one point to another. It would be very easy if that were the case - I would use a width algorithm like the one explained here .

The problem is that in this case, each edge has a maximum number of times that can be used . Let's look at an example:

Example graph

In this case, I can go 15 times from A to D. The first 10 times the path will be A β†’ B β†’ C β†’ D. The rest 5 times the path will be A β†’ C β†’ D.

So far, I have been able to implement the solution (using python), but it is rather slow for medium sized tasks (about 30 nodes). I have an unweighted graph (since I'm not against the length of the path) with possible connections between different nodes, and separately I have a matrix with a limit on the use of each edge.

So, inside the loop:

  • I find the only possible way.
  • I am updating the custom matrix. Using this path will be minimal for using edges (for example, you can use the path as many times as part of the path with a minimum limit).
  • For each edge whose use reaches 0, this means that it can no longer be used, so I remove it from the graph.
  • Loop until all paths are found.

, , . , node , , .

?

+3
1

. , , A B 10 , , 10 ^ 3/. , 15 ^ 3/ D. , wikipedia.

, . , .

  • A C 6, A D - 15, ( 6 C, 9 B 5 10). ? , A C (, node E), , C D .
  • (, C B), , , , , .
+1

All Articles