I have the task to calculate the maximum throughput in a graph.
The easiest way to describe the graph is as int[][]
. The inner array is the nodes in graph and the outer array is the distance connecting each node in the graph, e.g.:
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
(the source) to node 3
(the destination the "maximum throughput" would be 4 per turn, because:
- 5 packets can go from node 0 to node 1
- 4 packets can go from node 1 to node 2
- 8 packets can go from node 2 to node 3
On a "per turn" basis, the bottleneck is between node 1
and node 2
, where the maximum throughput capacity is 4.
Can someone point me to an algorithm that would solve this "maximum throughput" problem for any given graph defined in this way as int[][]
and given source
and destination
nodes?
The example graph is to be extended with multiple "sources" and "destinations" where I will need to calculate the maximum throughput of the entire system on any given "turn".
I'd appreciate help in the form of algorithms to study or "pseudo-code".