The Riemann-Roch theorem on a graph G is related to Alexander duality in combinatorial commutive algebra. We study the lattice ideal given by chip firing on G and the initial ideal whose standard monomials are the G-parking functions. When G is a saturated graph, these ideals are generic and the Scarf complex is a minimal free resolution. Otherwise, syzygies are obtained by degeneration. We also develop a self-contained Riemann-Roch theory for artinian monomial ideals.