  In these two lectures we shall discuss how the cavity approach can be used
efficiently to study optimization problems with global (topological)
constraints and how the same techniques can be generalized to study inverse
problems in irreversible dynamical processes. These two classes of problems are
formally very similar: they both require an efficient procedure to trace over
all trajectories of either auxiliary variables which enforce global
constraints, or directly dynamical variables defining the inverse dynamical
problems. We will mention three basic examples, namely the Minimum Steiner Tree
problem, the inverse threshold linear dynamical problem, and the patient-zero
problem in epidemic cascades. All these examples are root problems in
optimization and inference over networks. They appear in many modern
applications and in a variety of different contexts. Credit for these results
should be shared with A. Braunstein, A. Ramezanpour, F. Altarelli, L.
Dall'Asta, I. Biazzo and A. Lage-Castellanos.
