In the game theory approach to cost allocation, the main computational issue is an algorithm for finding solutions such as the Shapley value and the nucleolus. In this article, we consider the problem of allocating the maintenance cost of a tree network that connects the supply source at the root to the users at the leaves. We show that the core of the game can be expressed in terms of network flows. Based on this observation, we present O(n log n) algorithms for computing the nucleolus and the egalitarian allocation.