Search code examples
algorithmlanguage-agnosticgraph-algorithmkruskals-algorithm

Kruskal worst case time scenario


I wanna make a graph that force the kruskal algorithm to worst case. So, lets say that we dont care for sorting the edges time or other operations, but we care only about how we make the edges so that the algorithm makes the most union operations when taking them.

Maybe something like this. Can you give me an example with more nodes, or the idea for how to make the graph?

enter image description here


Solution

  • My idea is, take any graph with more nodes and with less no of cycles.For ex, take a graph with 20 nodes and with one cycle of length 3. In this case, The no of edges we can avoid in MST is only of that contribute cycle. If the graph doesn't contain more cycles we would obviously need many union operations, since most of the vertices belong to different sets.