I think the condition you are proposing is when the critical critical value is correct. But there is no need to actually find the cycle and check every edge of it.
The Kruskal algorithm adds edges in order of increasing weight, so the sequence of edge additives can be divided into blocks with equal weight additions to the edge. Inside each block with equal weight, if there is more than one edge connecting the same two components, then all these edges are non-critical, because you can choose any of the other edges instead. (I say that they are all non-critical, because in reality we are not providing a specific MST as part of the input - if we were then it would identify a specific edge to call non-critical. The edge that Kruskal actually chooses is just artifact of initial edge ordering or how sorting was done.)
But this is not enough: maybe after adding all the ribs of weight 4 or less in the MST, we find that there are 3 weights of 5 ribs connecting the pairs of components (1, 2), (2, 3) and (1, 3). Although none of the component pairs is connected to more than one of these three edges, we only need (any) of them 2 - using all 3 would create a loop.
For each block with equal weight, with the weight denoted by w, we really need to (conceptually) create a new graph in which each MST component so far (i.e. using edges having weight <w) is a vertex, and there is an edge between two vertices when there is an edge of weight-w between these components. (This can lead to multiple edges.) Then we run DFS on each component of this graph to find any cycles, and mark each edge that belongs to such a cycle as non-critical. DFS takes O (nEdges) time, so the sum of the DFS time for each block (the sum of the sizes of which is E) is O (E).
Note that the Kruskal algorithm takes O (Elog E) time, not O (E), as you seem to imply - although people like Bernard Chazel have come close to the linear construction of MST, TTBOMK is not there yet! :)
source share