  For a fixed infinite graph $H$, we study the largest density of a
monochromatic subgraph isomorphic to $H$ that can be found in every
two-coloring of the edges of $K_{\mathbb{N}}$. This is called the Ramsey upper
density of $H$, and was introduced by Erd\H{o}s and Galvin. Recently, the
Ramsey upper density of the infinite path was determined. Here, we find the
value of this density for all locally finite graphs $H$ up to a factor of 2,
answering a question of DeBiasio and McKenney.
  We also find the exact density for a wide class of bipartite graphs,
including all locally finite forests. Our approach relates this problem to the
solution of an optimization problem for continuous functions. We show that,
under certain conditions, the density depends only on the chromatic number of
$H$, the number of components of $H$, and the expansion ratio $|N(I)|/|I|$ of
the independent sets of $H$.
