Recursive algorithm for steady flow in a canal network