Driver Code
let N = 11 , M = 10 ; let edges = [ ] ; edges . push ( [ 0 , 1 ] ) ; edges . push ( [ 0 , 2 ] ) ; edges . push ( [ 0 , 3 ] ) ; edges . push ( [ 1 , 4 ] ) ; edges . push ( [ 1 , 5 ] ) ; edges . push ( [ 3 , 6 ] ) ; edges . push ( [ 4 , 7 ] ) ; edges . push ( [ 6 , 10 ] ) ; edges . push ( [ 6 , 8 ] ) ; edges . push ( [ 6 , 9 ] ) ; let cost = [ 1 , 2 , - 1 , 3 , 4 , 5 , 8 , 2 , 6 , 12 , 7 ] ;