グラフアルゴリズムIntermediate

Prim's Algorithm

Finds the Minimum Spanning Tree (MST) by growing a tree from a starting vertex. Always adds the minimum weight edge connecting a vertex in the tree to one outside. Uses a priority queue for efficient edge selection. Ideal for dense graphs.

#graph#mst#greedy#priority-queue

Complexity Analysis

Time (Average)

O(E log V)

Expected case performance

Space

O(V)

Memory requirements

Time (Best)

O(E log V)

Best case performance

Time (Worst)

O(E log V)

Worst case performance

📚 CLRS Reference

Introduction to AlgorithmsChapter 23Section 23.2

Presets:
Step: 1 / 0
500ms
SlowFast
Keyboard Shortcuts
Space Play/Pause StepR Reset1-4 Speed

Real-time Statistics

Algorithm Performance Metrics

Progress0%
Comparisons
0
Swaps
0
Array Accesses
0
Steps
1/ 0

Algorithm Visualization

Step 1 of 0

Initialize array to begin

Default
Comparing
Swapped
Sorted

Code Execution

Currently executing
Previously executed

Implementation

Prim's Algorithm - Algorithm Vision