Real-world networks are typically described in terms of nodes, links, and communities, having signal values often associated with them. The aim of this paper is to introduce a novel Compound Markov random field model (Compound MRF, or CMRF) for signals defined over graphs, encompassing jointly signal values at nodes, edge weights, and community labels. The proposed CMRF generalizes Markovian models previously proposed in the literature, since it accounts for different kinds of interactions between communities and signal smoothness constraints. Finally, the proposed approach is applied to (joint) graph learning and signal recovery. Numerical results on synthetic and real data illustrate the competitive performance of our method with respect to other state-of-the-art approaches.