A Riemann-Roch theorem for edge-weighted graphs