move the computation of node degree to a higher level
revising duality gap computation