We prove well-posedness for general linear wave-and diffusion equations on compact or non-compact metric graphs allowing various conditions in the vertices. More precisely, using the theory of strongly continuous operator semigroups we show that a large class of (not necessarily self-adjoint) second order differential operators with general (possibly non-local) boundary conditions generate cosine families, hence also analytic semigroups, on2010 Mathematics Subject Classification. 47D06, 35R02, 35G46, 35K05, 35L05. 1 xn ⊺ .Using this notation we define the transformationsJ ϕ e f e ∶= f e ○ ϕ e for f e ∈ X e , Jφi ∈ L(X i ),Then J ϕ e and Jφi are invertible with bounded inverses J −1 ϕ e = J (ϕ e ) −1 ∈ L(X e ) and J −1 ϕ i = J (φ i ) −1 ∈ L(X i ). These maps will be used in Lemma 2.4 to transform space dependent diffusion coefficients into constant ones.