Prim's algorithm
Prim's algorithm is a greedy algorithm that finds a minimum spanning tree in a weighted graph. Starting with an arbitrary vertex, the algorithm builds a tree one vertex at a time, always selecting the cheapest possible edge that leads out of the tree until every vertex is included, at which point it returns a spanning tree:
algorithm prim is
input: a connected, weighted graph G = (V, E)
output: a minimum spanning tree of G
let T be an empty graph
add any vertex in G to T
while T does not include every vertex in G
find a minimum-weight edge (v, w) in G such that v is in T and w is not
add (v, w) to T
add w to T
return T
With every new vertex added, the set of candidate edges changes. To perform Prim's algorithm correctly, make sure to choose the cheapest possible edge during each iteration.
Logic & Proofs
Integer •
Rational number •
Inequality •
Real number •
Theorem •
Proof •
Statement •
Proof by exhaustion •
Universal generalization •
Counterexample •
Existence proof •
Existential instantiation •
Axiom •
Logic •
Truth •
Proposition •
Compound proposition •
Logical operation •
Logical equivalence •
Tautology •
Contradiction •
Logic law •
Predicate •
Domain •
Quantifier •
Argument •
Rule of inference •
Logical proof •
Direct proof •
Proof by contrapositive •
Irrational number •
Proof by contradiction •
Proof by cases •
Summation •
Disjunctive normal form
Set Theory
Set •
Element •
Empty set •
Universal set •
Subset •
Power set •
Cartesian product •
String •
Binary string •
Empty string •
Set operation •
Set identity •
Set proof
Functions
Algorithms
Relations
Number Theory
Induction
Combinatorics
Graph Theory
Graph •
Walk •
Subgraph •
Regular graph •
Complete graph •
Empty graph •
Cycle graph •
Hypercube graph •
Bipartite graph •
Component •
Eulerian circuit •
Eulerian trail •
Hamiltonian cycle •
Hamiltonian path •
Tree •
Huffman tree •
Substring •
Forest •
Path graph •
Star •
Spanning tree •
Weighted graph •
Minimum spanning tree •
Greedy algorithm •
Prim's algorithm
Recursion