cost_sum and cost functions moved in Network class