We compute an MST on edges: .
We then walk the tree, avoiding duplicates: O(n).
Total: (not too bad).