  The purpose of this paper is to develop a general existence theory for
constrained minimization problems for functionals defined on function spaces on
metric measure spaces $(\mathcal M, d, \mu)$. We apply this theory to
functionals defined on metric graphs $\mathcal G$, in particular
$L^2$-constrained minimization problems for functionals of the form $$E(u) =
\frac{1}{2} a(u,u) - \frac{1}{q}\int_{\mathcal K} |u|^q \, \mathrm dx,$$ where
$q>2$, $a(\cdot, \cdot)$ is a suitable symmetric sesquilinear form on some
function space on $\mathcal G$ and $\mathcal K \subseteq \mathcal G$ is given.
  We show how the existence of solutions can be obtained via decomposition
methods using spectral properties of the operator $A$ associated with the form
$a(\cdot, \cdot)$ and discuss the spectral quantities involved. An example that
we consider is the higher-order variant of the stationary NLS (nonlinear
Schr\"odinger) energy functional with potential $V\in L^2+ L^\infty(\mathcal
G)$ $$ E^{(k)}(u)= \frac{1}{2} \int_{\mathcal G} |u^{(k)}|^2+ V(x) |u|^2 \,
\mathrm dx - \frac{1}{p} \int_{\mathcal K} |u|^q \, \mathrm dx$$ defined on a
class of higher-order Sobolev spaces $H^k(\mathcal G)$ that we introduce. When
$\mathcal K$ is a bounded subgraph, one has localized nonlinearities, which we
treat as a special case. When $k=1$ we also consider metric graphs with
infinite edge set as well as magnetic potentials. Then the operator $A$
associated to the linear form is a Schr\"odinger operator, and in the
$L^2$-subcritical case $2<q<6$, we obtain generalizations of existence results
for the NLS functional as for instance obtained by Adami, Serra and Tilli [JFA
271 (2016), 201-223], and Cacciapuoti, Finco and Noja [Nonlinearity 30 (2017),
3271-3303], among others.
