We study the time-averaged flow in a model of particles that randomly hop on a finite directed graph. In the limit as the number of particles and the time window go to infinity but the graph remains finite, the large-deviation rate functional of the average flow is given by a variational formulation involving paths of the density and flow. We give sufficient conditions under which the large deviations of a given time averaged flow is determined by paths that are constant in time. We then consider a class of models on a discrete ring for which it is possible to show that a better strategy is obtained producing a time-dependent path. This phenomenon, called a dynamical phase transition, is known to occur for some particle systems in the hydrodynamic scaling limit, which is thus extended to the setting of a finite graph.