A Theory Of Flow Network Typings And Its Optimization Problems