The Riemann-Roch theorem for graphs and the rank in complete graphs