DSAVisualiseData Structures & Algorithms Studio
Graphs & Connectivity Medium

Electricity Network (Minimum Spanning Tree)

Connect buildings with the least total wire cost by considering the cheapest candidate first.

Trace input

Bounded JSON

Edit the lesson input, then build a deterministic source-linked trace.

This lesson validates its own input and operation limits.

Source scenarios

Complexity

BestO(E log E + E α(V))
AverageO(E log E + E α(V))
WorstO(E log E + E α(V))
SpaceO(V + E)

Array state

Follow the active comparisons and writes.

Live snapshot

Current operation

Trace state
Ready to explore
Source behavior & common mistakes

Return the cost of the minimum spanning tree using Kruskal's algorithm and Union-Find.

  • Adding an edge that already closes a cycle.
  • Comparing stored sizes for non-root vertices.
  • Assuming the implementation rejects disconnected graphs; it returns a minimum spanning forest cost.

Algorithm code

Java
Electricity.javaStep linked
The highlighted line follows the current step.

Ready to begin

Press Play to see what happens.

Detailed execution
Snapshot 1 / 1
Visited 0 · Writes 0