(A) Consider the following algorithm for computing a topological
sort of a DAG G: add the vertices to an initially empty list in
non-decreasing order of their indegrees. Either argue that the
algorithm correctly computes a topological sort of G, or provide an
example on which the algorithm fails.
(B) Can the number of strongly connected components of a graph
decrease if a new edge is added? Why or why not? Can it increase?
Why or why not?
(C) What is the minimum number of strongly connected components that a directed acyclic graph (DAG) on n nodes can have? What is the maximum number? Justify your answers.
A. No above process will not always work to give topological sorting. Consider the directed chain graph shown below :-

As evident from the figure, only one topological order exist in above graph is A,B,C,D,E where source vertex comes before target vertex.
But as per the proposed algorithm, vertex A have minimum in-degree of zero, so it will first selected vertex A. But now every remaining vertex have in-degree 1 and hence algorithm can pick any one of them which is wrong. Hence algorithm fail in this case.
B. Adding a new edge into a graph enhances the connectivity of a graph. So adding a new edge can either join two disconnected component in which number of connected component will reduce by one or it will remain same when newly added edge connects two vertices in same connected component. But number of connected component will never increase by adding a new edge.
C. A set of vertices in a directed graph is said to be part of strongly connected component if there is directed path between every pair of vertices.
Since there does not exist any cycle in DAG, this means if there is directed path from vertex A to B, then there cannot be directed path from B to A, otherwise they will form cycle. Hence in a DAG, there does not exist any pair of vertices which are in same strongly connected component. In other words, every single vertices is only part of its own connected component. Hence minimum strongly connected component in DAG in n, where n is number of vertices.
The maximum number of connected component will also be n since number of strongly connected component cannot exceeds number of vertices.
Please comment for any clarification.
(A) Consider the following algorithm for computing a topological sort of a DAG G: add the...
Which of the following is TRUE about Topological Sorting? Topological Sort can be used as a subroutine to find shortest paths in a weighted DAG in time O(V+E); in particular, the time does not depend on the magnitudes of the weights on the edges, and the weights on the edges may be negative. A Topological Sort algorithm sorts the nodes of an arbitrary directed graph G in an order that is consistent with all the paths in G, that is...
Suppose G is a DAG,i.e., a directed acyclic graph. Lets and t be two nodes in the graph. Describe an O(n+m) algorithm that computes the number of paths from s to t . (Hint: start by topologically ordering G.)
Apply the topological sort algorithm to the graph. Follow the
algorithm in you textbook and clearly show the content of the three
lists: resultList, noIncoming and remainingEdges after each
iteration.
2. Apply the topological sort algorithm to the graph below. Follow the algorithm in you textbook and clearly show the content of the three lists: resultList, nolncoming and remainingEdges after each iteration GraphTopologicalSort (graph) { resultList = empty list of vertices no Incoming = list of all vertices with no...
Student Name: Q5-15 pts) Run the Depth First Search algorithm on the following directed acyclic graph (DAG) and determine a topological sort of the vertices as well as identify the tree edges, forward edges and cross edges 3 5 0 2 4 7
Write a C++ program called ts.cpp that implements the topological sorting algorithm based on the DFS algorithm. Your program should read an input file name and determine if the input graph is a DAG (= directed acyclic graph) or not. If the graph is not a DAG, your program has to stop without further processing. However, if it’s a DAG, your program should display the starting node(s), popping-off order, and topologically sorted list. In the problem, you can assume that...
Consider the following directed graph for each of the
problems:
1. Perform a breadth-first search on the graph assuming that the
vertices and adjacency lists
are listed in alphabetical order. Show the breadth-first search
tree that is generated.
2. Perform a depth-first search on the graph assuming that the
vertices and adjacency lists
are listed in alphabetical order. Classify each edge as tree, back
or cross edge. Label each
vertex with its start and finish time.
3. Remove all the...
Consider a directed acyclic graph G = (V, E) without edge lengths and a start vertex s E V. (Recall, the length of a path in an graph without edge lengths is given by the number of edges on that path). Someone claims that the following greedy algorithm will always find longest path in the graph G starting from s. path = [8] Ucurrent = s topologically sort the vertices V of G. forall v EV in topological order do...
You are given an unweighted DAG (Directed Acyclic Graph) G, along with a start node s and a target node t. Design a linear time (i.e., runtime O(IV+ EI)) dynamic programming algorithm for computing the number of all paths (not necessarily shortest) from s to t.
Problem 1: Dynamic Programming in DAG Let G(V,E), |V| = n, be a directed acyclic graph presented in adjacency list representation, where the vertices are labelled with numbers in the set {1, . . . , n}, and where (i, j) is and edge inplies i < j. Suppose also that each vertex has a positive value vi, 1 ≤ i ≤ n. Define the value of a path as the sum of the values of the vertices belonging to...
ignore red marks. Thanks
10. (16) You will compute the strongly connected components of this graph in three steps. a. STRONGLY-CONNECTED-COMPONENTS (G) (7) Perform a depth-first search on call DFS(G) to compute finishing times w/ for each vertex the following graph. (To make 2 compute GT this easier to grade, everyone call DFS(GT), but in the main loop of DFS, consider the vertices in order of decreasing wf (as computed in line 1) please start with vertex "a" and 4...