Section 2: Trees Flashcards
Cycle in a graph G
a subgraph of G isomorphic to Ck
for some k ≥ 3.
Forest
a graph that contains no cycles
Tree
connected acyclic graph
Spanning tree for a connected graph G
a spanning subgraph of G that is a tree
Spanning forest
a subgraph of G that is a forest
Cayley’s Formula
A complete graph with n vertices
has n^(n−2) (labelled) spanning trees.
Kruskal’s Algorithm
a) Set T = (V, ∅).
b) Let E’ be the subset of edges e ∈ E such that
* e is not already in T, and
* adding e to T does not create a cycle;
add to T the edge in E’
that has the smallest weight.
c) If T is not connected, go to step 2.
d) Output T.
Theorem about Kruskal’s algorithm
Given any weighted connected graph G = (V, E) as input, Kruskal’s algorithm will output a spanning tree of minimum weight
Prim’s Algorithm
a) Set T = (V, ∅).
b) Add an edge of minimum weight to T.
c) Let E’ be the subset of edges e in E such that
* e is not already in T,
* adding e to T does not create a cycle, and
* e is incident with an edge already in T;
add to T the edge in E’
that has the smallest weight.
d) If T is not connected, go to step 3.
e) Output T.