water distribution algorithms