Spanning Trees
Prims MST Algorithm Algorithm ( this is also greedy) Select an arbitrary vertex to start the tree, while there are fringe vertices: 1)select an edge of minimum weight between a tree vertex and a fringe vertex. 2)add the selected edge and the fringe vertex to the tree. end.
Prims Algorithm Minimal Spanning Tree
Example: start with 7
Prims Algorithm Minimal Spanning Tree
MST weight = 15 4
Topological Sorting Algorithm while (the graph has a node with no successor) do remove one of those nodes from the graph and add it to the end of a list if (the graph is empty) then the list contains the reverse of some topological order else the graph contains a cycle
A B C D E F G HI J L K M
A B C D E F G HI J L K M D
A B C E F G HI J L K M D E
A B C F G HI J L K M DE F
A B C G HI J L K M DEF C
A B G HI J L K M DEFC B
A G H I J L K M DEFCB I
A G H J L K M DEFCBI H
A G J L K M DEFCBIH G
A J L K M DEFCBIHG A
J L K M DEFCBIHGA K
J L M DEFCBIHGAK M
J L DEFCBIHGAKM L
J DEFCBIHGAKML J
DEFCBIHGAKMLJ J L M K A G H I B C F E D