A linear-time algorithm for minimum cost flow on undirected one-trees