Graph Theory Lecture Notes 7a

Embed Size (px)

Citation preview

  • 7/28/2019 Graph Theory Lecture Notes 7a

    1/2

    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 Knis nn-2, for n 2, this isCayley's Formula.

    Prfer Encoding

    A Prfer sequenceof length n-2, for n 2, is any sequence of integers between 1 and n, with repetitions

    allowed.

    A labeled tree gives a Prfer sequence by:

    Repeat n-2 times:Pick the 1-valent vertex with the smallest label, call it v.Put the label of v's neighbor in the output sequence.Remove v from the tree.

    Prfer Decoding

    A Prfer sequence determines a labeled tree by:

    Let L be the ordered list of numbers 1, 2, ..., n. Let P be the Prfer sequence. Start with n labeledisolated vertices.Repeat n-2 times:Let k be the smallest number in L which is not in P.Let j be the first number in P.

    Add the edge kj to the graph.Remove k from L and the first number in P.When this is completed there will be two numbers left in L, add the edge corresponding to these twonumbers.

    Prfer coding and decoding are inverse operations, that means that there is a one-to-one correspondencebetween labeled trees with n vertices and Prfer sequences of length n-2.

    Cayley's formula now follows from counting Prfer 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 thesmallest sum of weights.

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

    This is an example of agreedy algorithm.

    Finding the Shortest Path

    h Theory Lecture Notes 7a http://www-math.ucdenver.edu/~wcherowi/courses/m4408/g

    2 3/25/2013

  • 7/28/2019 Graph Theory Lecture Notes 7a

    2/2

    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 byusing 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 wherenegative 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 thestarting vertex s. For a given vertex x, this label will be denoted dist[x]. Start by setting dist[s]:=0. At eachstep of the tree growing process, for each frontier edge e, calculate P(e) = dist[x] + wt(e), where x is thevertex of e that is in the tree (and therefore has been labeled) and wt(e) is the weight of edge e. Choose thefrontier edge with the smallest P(e) value to add to the tree and label the new vertex with P(e).

    h Theory Lecture Notes 7a http://www-math.ucdenver.edu/~wcherowi/courses/m4408/g

    2 3/25/2013