0% found this document useful (0 votes)
49 views

MinimumSpanningTrees MST

The document describes minimum spanning trees and two algorithms for finding them: Prim's algorithm and Kruskal's algorithm. Prim's algorithm begins with an arbitrary edge and successively adds the lowest weight edge connected to the current tree. Kruskal's algorithm begins with the lowest weight edge and adds subsequent edges as long as they do not form cycles, building up a minimum spanning tree one edge at a time. Examples applying each algorithm to a weighted graph are provided.

Uploaded by

ikx00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

MinimumSpanningTrees MST

The document describes minimum spanning trees and two algorithms for finding them: Prim's algorithm and Kruskal's algorithm. Prim's algorithm begins with an arbitrary edge and successively adds the lowest weight edge connected to the current tree. Kruskal's algorithm begins with the lowest weight edge and adds subsequent edges as long as they do not form cycles, building up a minimum spanning tree one edge at a time. Examples applying each algorithm to a weighted graph are provided.

Uploaded by

ikx00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ICS 241: Discrete Mathematics II (Spring 2015)

11.5 Minimum Spanning Trees


Minimum Spanning Tree

A minimum spanning tree in a connected weighted graph is a spanning tree that has the smallest
possible sum of weights of its edges.

Prim’s Algorithm

An algorithm for finding a minimum spanning tree.

• Begin by choosing any edge with smallest weight, putting it into the spanning tree.

• Successively add to the tree edges of minimum weight that are incident to a vertex already
in the tree, never forming a simple circuit with those edges already in the tree.

• Stop when n − 1 edges have been added.

Algorithm 3 Prim(G : weighted connected undirected graph with n vertices)


1: T = a minimum-weight edge
2: for i = 1 to n − 2 do
3: e = an edge of minimum weight incident to a vertex in T and not forming a simple circuit
in T if added to T
4: T = T with e added
5: end for
6: return T {T is a minimum spanning tree of G}

Kruskal’s Algorithm

An algorithm for finding a minimum spanning tree.

• Begin by choosing an edge in the graph with minimum weight.

• Successively add edges with minimum weight that do not form a simple circuit with those
edges already chosen.

• Stop after n − 1 edges have been selected.

Algorithm 4 Kruskal(G : weighted connected undirected graph with n vertices)


1: T = empty graph
2: for i = 1 to n − 1 do
3: e = any edge in G with smallest weight that does not form a simple circuit when added to T
4: T = T with e added
5: end for
6: return T {T is a minimum spanning tree of G}

1
ICS 241: Discrete Mathematics II (Spring 2015)

11.5 pg. 802 # 3

Use Prim’s algorithm to find a minimum spanning tree for the given weighted graph.

Choice Edge Weight


1 {e, f } 1 a b c
2 {c, f } 3
3 {e, h} 3
4 {h, i} 2
d e f
5 {b, c} 4
6 {b, d} 3
7 {a, d} 2
8 {g, h} 4 g h i
total: 22

11.5 pg. 802 # 7

Use Kruskal’s algorithm to find a minimum spanning tree for the weighted graph in Exercise 3.

Choice Edge Weight


1 {e, f } 1 a b c
2 {a, d} 2
3 {h, i} 2
4 {b, d} 3
d e f
5 {c, f } 3
6 {e, h} 3
7 {b, c} 4
8 {g, h} 4 g h i
total: 22

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy