UF’s biggest pro is that it is convenient to add or delete connections. For example, in Knuth’s MST algorithm, you need to add black edges contiguously, so using UF is good.
If you have a fixed shape of graph, DFS can be better than UF.
UF’s biggest pro is that it is convenient to add or delete connections. For example, in Knuth’s MST algorithm, you need to add black edges contiguously, so using UF is good.
If you have a fixed shape of graph, DFS can be better than UF.