Lecture Notes on 15 Nov 2023 * Directed Acyclic Graphs (DAGs) https://www.cs.utexas.edu/users/mitra/csFall2023/cs313/notes/DAG.pdf Topological Sort (Topo Sort) Works on directed graphs that do not have cycles (DAGs) 0. Determine the in_degree for all vertices. The in_degree is the number of edges that are incident on that vertex. 1. Remove the vertices that have an in_degree of 0 to a list and remove the out going edges from those vertices. Sort the list in a given order. Enqueue the vertices into a Queue and then update the in_degree of all remaining vertices. 2. Repeat step 1 until there are no more vertices in the Graph. 3. Dequeue the vertices and print. * Minimum Spanning Tree (MST) - Kruskal's Algorithm and Prim's Algorithm. * Kruskal's Algorithm - Order the edges by increasing weight. - Start with an empty graph having only the vertices but no edges. Add an edge to this graph as long as it does not form a cycle. - When all the vertices are connected you are done. * Prim's Algorithm - Start with an empty graph having only the vertices. - Start with any vertex and add it to the list of visited vertices. - Choose the edge with the smallest weight to an unvisited vertex as long as it does not form a cycle. Add that vertex to the list of visited vertices. - Keep adding the edges with the smallest weight from any of the vertices in the list of visited vertices as long as those edges do not form a cycle. - When all the vertices have been visited then you are done. * Dijkstra's Single Source Shortest Path Algorithm - Choose a starting vertex. - Create a table with all the other vertices in the graph. - From the starting vertex fill the table with the cost of visiting all the other vertices. - Go to the vertex with the lowest cost and update the cost of visiting all the other vertices from the starting vertex. - Go to all the other vertices in order of increasing cost and update the costs of visiting the other vertices from the starting vertex. - When you have visited all the vertices that you can visit from the starting vertex then you are done. * Worked out example using Dijkstra's Algorithm https://www.cs.utexas.edu/users/mitra/csFall2023/cs313/notes/Dijkstra.pdf