The famous max-flow min-cut theorem states that a source node can send information through a network ( ) to a sink node at a rate determined by the min-cut separating and . Recently, it has been shown that this rate can also be achieved for multicasting to several sinks provided that the intermediate nodes are allowed to re-encode the information they receive. We demonstrate examples of networks where theachievable rates obtained by coding at intermediate nodes are arbitrarily larger than if coding is not allowed. We give deterministic polynomial time algorithms and even faster randomized algorithms fordesigning linear codes for directed acyclic graphs with edges of unit capacity. We extend these algorithms to integer capacities and tocodes that are tolerant to edge failures.