A description is given of an O(NL + L log L) time algorithm, where N is the total number of transistor chains and L is the channel length, to determine the orientation of each transistor chain such that the channel density is minimized. It is shown that the problem of flipping chains and subchains to minimize channel density can also be solved optimally. Finally, it is observed that the algorithm can be used to optimally solve a generalized channel routing problem. They have implemented their algorithm in the custom cell synthesis system of the MCC Physical Satellite. For the cells selected from industry, the algorithm reduced channel density by 18%. They also tested the algorithm on several channel routing problems and reductions of up to 30% in channel density were obtained.