Grad and classes with bounded expansion II. Algorithmic aspects