A discrete-domain description of multiphase flow in porous media: Rugged energy landscapes and the origin of hysteresis