# Is there an algorithm for the distrubution of ducks into ponds?

The following is small-scale example is meant to illustrate the general distribution problem

Consider 4 parks, each with exactly 1 pond. Parks are marked as vertices in the following undirected graph:

Each park has a number of ducks in them, and each pond has a maximum capacity of ducks (the parks themselves do not have a max capacity):

• Park A has 8 ducks and its pond has a max capacity of 5 ducks.
• Park B has 4 ducks and its pond has a max capacity of 6 ducks.
• Park C has 10 ducks and its pond has a max capacity of 4 ducks.
• Park D has 11 ducks and its pond has a max capacity of 9 ducks.

Now, all ducks have to fly to a pond in another park. Ducks can only fly to adjacent parks as marked by the edges - or they can fly away if all adjacent ponds are full (meaning that surplus/leftover ducks are not important wrt. the objective and can be ignored). The objective is to fill all ponds to their max capacity.

Is there an algorithm or a class of algorithms that can be used for this problem? I am not interested in the solution for the example, but rather more general approaches (though you are of course welcome to use the example to demonstrate a general approach).

Cheers!

• Could you clarify what you mean by "they can fly away if all adjacent ponds are full"? Sep 1, 2023 at 14:38