Minimum weight spanning tree (MST)
You are usually given a non-oriented graph (if the graph is oriented, consider it as non-oriented) with a weight on your edges. Your job is to create a Minimum weight spanning tree (
Arbre couvrant de poids minimum (ACM)) by minimizing the total weight.
- Draw all of your vertices
- While we can add new edges (not a tree yet)
- take the edges with the least weight
- try adding it (if you are not making a cycle)
- Draw a starting vertex and add it links in $S$
- While $S$ isn't empty
- pick the edge in $S$ having the least weight
- if you can add it without creating a cycle, then add it
- else destroy/remove the link
- add the new vertex edges in $S$
Exercise 1 (Kruskal)
Create a tree from this table. The value at the line "Chatelet" and the column "N" is the cost for constructing a road from "N" (Neuilly) to "Chatelet".
We are creating 8 vertices for our 8 destinations. Then we are looking at the least cost in the whole table. It's 5. If adding B (Bourse) - Opera is creating a cycle
- then we do not add it
- otherwise, we add it
And we are doing that until all the nodes are linked.
Exercise 2 (Prim)
Apply Prim's algorithm on this graph, starting from a.
I colored in red the edges we may pick. Then, among the ones in red, simply try to add the one with the least weight. If you can, then add the added vertex's edges in red. If I couldn't add an edge, then I colored it in grey.
Some may pick b-c instead of a-h, since both weights are $8$. I picked a-h, but this doesn't matter, the rest of the graph would be the same aside from this one edge.