matrix tree theorem and tarjan's implementation of chu-liu-edmonds