Sayyiduna Anas (may Allah be pleased with him) said that the Messenger of Allah (peace and blessings be upon him) forbade, and he mentioned the meat of sacrificial animals, vessels and visiting graves; then he mentioned his permission for all of them. In a hadith it is: "I used to forbid you from visiting graves, then it became clear to me (otherwise); so visit them, for they soften the heart, make the eyes shed tears and remind of the Hereafter. So visit them, but do not wail."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الجنائز / 7198