A network flow approach to cost allocation for rooted trees