Function to generate the tree
function sumOfshortestPath ( N , E , edges ) { let g = new Array ( N ) ; for ( let i = 0 ; i < N ; i ++ ) { g [ i ] = new Array ( N ) ; for ( let j = 0 ; j < N ; j ++ ) { g [ i ] [ j ] = INF ; } }