Consider the following graph:

nodes 1 to 6 are connected with a transition edge that have a direction and a volume property (red numbers). I'm looking for the right algorithm to find paths with a high volume. In the above example the output should be:

- Path: [4,5,6] with a minimal volume of 17
- Path: [1,2,3] with a minimal volume of 15

I've looked at Floyd–Warshall algorithm but I'm not sure it's the right approach.

Any resources, comments or ideas would be appreciated.

# Best How To :

**Finding a beaten graph:**

In the comments, you clarify that you are looking for "beaten" paths. I am assume this means that you are trying to contrast the paths with the average; for instance, looking for paths which can support weight at least e*w, where 0<e and w is the average edge weight. (You could have any number of contrast functions here, but the function you choose does not affect the algorithm.)

Then the algorithm to find all paths that meet this condition is incredibly simple and only takes O(m) time:

- Loop over all edges to find the average weight. (Takes O(m) time.)
- Calculate the threshold based on the average. (Takes O(1) time.)
- Remove all edges which do not support the threshold weight. (Takes O(m) time.)
- Any path in the resulting graph will be a member of the "widest path collection."

**Example:**

Consider that e=1.5. That is, you require that a beaten path support at least 1.5x the average edge weight. Then in graph you provided, you will loop over all the edges to find their average weight, and multiply this by e:

```
((20+4)+15+3+(2+20)+(1+1+17))/9 = 9.2
9.2*1.5 = 13.8
```

Then you loop over all edges, removing any that have weight less than 13.8. Any remaining paths in the graph are "beaten" paths.

**Enumerating all beaten paths:**

If you then want to find the set of beaten paths with maximal length (that is, they are not "parts" of paths), the modified graph is must be a DAG (because a cycle can be repeated infinite times). If it is a DAG, you can find the set of all maximal paths by:

- In your modified graph, select the set of all source nodes (no incoming edges).
- From each of these source nodes, perform a DFS (allowing repeated visits to the same node).
- Every time you get to a sink node (no outgoing edges), write down the path that you took to get here.

This will take up to O(IncompleteGamma[n,1]) time (super exponential), depending on your graph. That is, it is not very feasible.

**Finding the widest paths:**

An actually much simpler task is to find the widest paths between every pair of nodes. To do this:

- Start from the modified graph.
- Run Floyd-Warshall's, using
`pathWeight(i,j,k+1) = max[pathWeight(i,j,k), min[pathWeight(i,k+1,k), pathWeight(k+1,j,k)]]`

(that is, instead of adding the weights of two paths, you take the minimum volume they can support).