On the commuting graph of rings