Graph Theory Lecture Notes 7

Counting Spanning Trees

Two labeled trees are the same if their edge-sets are identical.

The number of spanning trees of Kn is nn-2, for n2, this is Cayley's Formula.

Prüfer Encoding

A Prüfer sequence of length n-2, for n2, is any sequence of integers between 1 and n, with repetitions allowed.

A labeled tree gives a Prüfer sequence by:

Prüfer Decoding

A Prüfer sequence determines a labeled tree by:

Prüfer coding and decoding are inverse operations, that means that there is a one-to-one correspondence between labeled trees with n vertices and Prüfer sequences of length n-2.

Cayley's formula now follows from counting Prüfer sequences of length n-2.

Finding Minimum Spanning Trees

Let G be a connected graph with weights assigned to its edges. We wish to find the spanning tree with the smallest sum of weights.

Prim's Algorithm: Grow a tree by picking the frontier edge with the smallest weight.

This is an example of a greedy algorithm.

Finding the Shortest Path

Let G be a connected graph with weights assigned to its edges. We wish to find for any two vertices s and t, the path from s to t whose total edge-weight is minimum.

If the weights are all equal, the problem reduces to finding the s-t path of shortest length. This can be done by using a breadth-first search starting at s, and ending when t is reached.

When the weights are non-negative, but not all equal we can use Dijkstra's algorithm (for situations where negative weights are used, Floyd's algorithm can be used).

Dijkstra's Algorithm

In this tree growing algorithm, vertices that are added to the tree are labeled with their "distance" from the starting vertex s. For a given vertex x, this label will be denoted dist[x]. Start by setting dist[s]:=0. At each step of the tree growing process, for each frontier edge e, calculate P(e) = dist[x] + wt(e), where x is the vertex of e that is in the tree (and therefore has been labeled) and wt(e) is the weight of edge e. Choose the frontier edge with the smallest P(e) value to add to the tree and label the new vertex with P(e).