Build the Graph / Tree
var adj = Array . from ( Array ( V + 1 ) , ( ) => Array ( ) ) ; addEdge ( adj , 1 , 2 ) ; addEdge ( adj , 1 , 3 ) ; var A = [ 1 , - 1 , 1 ] ; var minOperations = findMinOperation ( adj , A , V ) ; document . write ( minOperations ) ;