Add out - degree of each node
for ( int i = 1 ; i <= size ; i ++ ) calculatedAnswer += adj [ i ] . size ( ) ; if ( actualAnswer == calculatedAnswer ) System . out . print ( " Calculated ▁ Answer ▁ is ▁ " + calculatedAnswer + " and is Equal to Actual AnswerNEW_LINE"); else System . out . print ( "Calculated Answer is IncorrectNEW_LINE"); }