Consider an n-node undirected graph G(V,E) with a pre-assigned port numbering for the outgoing edges of each node. The port numbers assigned to a node u of degree are . In certain contexts it is necessary to maintain a directed spanning tree of G, in which case each node needs to remember the port number leading to its parent. Hence the cost of a spanning tree T is the total number of bits the nodes need to store in order to remember T. This paper addresses the question of asymptotically bounding the cost of the optimal tree, as a function of the graph size. A tight upper bound of O(n) is established on this cost, thus improving on the best previously known bound of O(nloglogn)  and proving the conjecture raised therein. This is achieved by presenting a polynomial time algorithm for constructing a spanning tree T of cost O(n) for a given general graph G with an arbitrary port labeling.