About a year ago, a friend and I thought of a way to implement Kruskal's algorithm for dense graphs in better than the usual $O(m \log m)$ bound (without assuming pre-sorted edges). Specifically, we achieve $\Theta(n^2)$ in all cases, similar to Prim's when implemented using adjacency matrices.
I've posted a bit about the algorithm in my blog, including C++ code and benchmarks, but here's the general idea:
Maintain one representative node for each connected component. Initially, all nodes represent themselves.
Maintain a vector
dist[i]
such that, for every componenti
, has the lightest component-crossing edge incident toi
.When finding the lightest edge that crosses partitions, simply find
i
that minimizes the weight ofdist[i]
, in linear time.When joining two components $c_i$ and $c_j$, modify the adjacency matrix $A$, such that now $A_{i, k} = \min \{A_{i, k}, A_{j, k}\}$ for all components $k$, and mark $i$ as no longer representative of its connected component (only $j$ will now remain).
The contracting of the lightest edge and the finding of said edge can thus both be done in linear time. We do this $n - 1$ times to find the MST. A little bookkeeping is needed to actually find which edge we want to add to the MST, but does not increase the complexity. Thus the runtime is $\Theta(n^2)$. The implementation is just a couple of for loops.
Is this version of Kruskal well-known in the literature?