Fix the bug. Not assuming node id starts from zero anymore. Also updated
Update degree method.