Let $G$ be an infinite locally finite connected graph with finitely many ends. A real-valued function $f : G \to \mathbb{R}$ is **harmonic** if

$$f(v) = \frac{1}{d_v} \sum_{v \sim w} f(w)$$

where $v \sim w$ means that $v, w$ are connected by an edge. Playing around with a few examples leads me to suspect that the dimension of the space of harmonic functions on $G$ is the number of ends. (Heuristic: given a harmonic function, start with a vertex $v$ and move to a neighbor $w$ of $v$ such that $f(w) \ge f(v)$. If $f$ is nonconstant this should give a path converging to an end, and this should be possible for any end. Moreover a harmonic function should be determined by its "values at the ends.") Does anyone know if this is true and, if so, does anyone know of a reference for this fact?

(Tags are because a major application is to Cayley graphs of finitely generated groups and I would be interested in seeing how far one can push this method to prove basic facts about ends of such graphs.)