Graph throughput algorithm

My task is to calculate the maximum throughput in a graph.

The easiest way to describe a graph is int[][]. The internal array is the nodes in the graph, and the external array is the distance connecting each node in the graph, for example:

new int[][] {
    {0, 5, 0, 0}, // node 0 (the "source")
    {0, 0, 4, 0}, // node 1
    {0, 0, 0, 8}, // node 2
    {0, 0, 0, 0}  // node 3 (the "destination")
}

So, to get from node 0(source) to node 3(destination, “maximum throughput” will be 4 per turn, because:

  • 5 packets can go from node from 0 to node 1
  • 4 packages can go from node 1 to node 2
  • 8 packages can go from node 2 to node 3

On a per-turn basis, the bottleneck is between node 1and node 2, where the maximum throughput is 4.

- , " " int[][] source destination ?

"" " ", "".

"".

+4
1

- , :

.

- :

- - O (V E 2) .

Pseudocode, , . ++ .

, ( ):

, , . , , .

, .

Max Flow, Min Cut.

0

Source: https://habr.com/ru/post/1667084/


All Articles