Minimum Spanning Tree (Kruskal & Prim)

A Minimum Spanning Tree connects all |V| vertices of a weighted undirected graph using exactly |V| - 1 edges of minimum total weight, solved greedily by Kruskal or Prim algorithms.

Technical Reference & Equations

  • Spanning Tree Edge Invariant: |E_{\text{MST}}| = |V| - 1, \quad W_{\text{MST}} = \sum_{e \in T} w(e) (Any acyclic connected subgraph spanning all |V| vertices has exactly |V| - 1 edges.)
  • Kruskal Union-Find Time Complexity: T_{\text{Kruskal}} = O(E \log E) = O(E \log V) (Dominated by sorting edges; disjoint-set union with path compression runs in O(alpha(V)).)
  • Prim Binary Heap Time Complexity: T_{\text{Prim}} = O\big((V + E)\log V\big) (Expands a single connected cut frontier using a min-priority queue.)

View full Data Structures & Algorithms Formula Sheet | Constants Table

Related Data Structures Calculators

  • Dijkstra Shortest Path: Edit edge weights on a network graph and watch Dijkstra’s shortest-path tree update.
  • Binary Heap & Priority Queue: Synchronize Min-Heap and Max-Heap binary trees with their 0-indexed backing arrays, Sift-Up/Sift-Down paths, Extract-Root, and Floyd O(n) Build-Heap.
  • AVL Self-Balancing Tree & Rotations: Insert and delete keys with live per-node balance factors, heights, automatic LL/RR/LR/RL rotations, and a step-by-step rotation audit log.
  • Sorting Algorithm Visualizer: Step through Quick, Merge, Insertion, Selection, and Bubble Sort with comparison and swap counters.
  • Big-O Growth Comparator: Compare asymptotic complexity curves and estimated wall-clock runtimes across input sizes.
  • Binary Search Tree Visualizer: Insert, delete, and search nodes on a live binary search tree with in-order, pre-order, and post-order traversals.