Adding getNumNodes function.