Optimization of metabolic and signal-transduction networks