Comments: v3: fixed one misprint in the proof of Lemma 2.1; v2: minor edits, some details added. To appear in the Electronic Journal of Combinatorics. 10 pages
The classification of complete multipartite graphs whose edge rings are nearly Gorenstein as well as that of finite perfect graphs whose stable set rings are nearly Gorenstein is achieved.