where the sum goes over all pairs of types in the derivation plan such that to is the original type and td the type derived from it and d(to,td) is the distance of the types
1/Σ(to,td)d(to,td)
派生關係有向邊,邊權爲兩個串的不同字符的個數,要求的是找出一種用到所有串的派生關係,使得Q最小,(因爲是1/Q),所以這題就是求最小生成樹
最樸素的最小生成樹AC