There are $N$ vertices connected by $N-1$ edges, each edge has its own length.
The set { $1, 2, 3, … , N$ } contains a total of $N!$ unique permutations, let’s say the $i$-th permutation is $P_i$ and $P_{i,j}$ is its $j$-th number.
For the $i$-th permutation, it can be a traverse sequence of the tree with $N$ vertices, which means we can go from the $P_{i,1}$-th vertex to the $P_{i,2}$-th vertex by the shortest path, then go to the $P_{i,3}$-th vertex ( also by the shortest path ) , and so on. Finally we’ll reach the $P_{i,N}$-th vertex, let’s define the total distance of this route as $D(P_i)$ , so please calculate the sum of $D(P_i)$ for all $N!$ permutations.