For a given directed graph, if the vertex v is reachable from another vertex u for all vertex pair (u,v) in the above given graph then we mark 1 in the reachability matrix in the position (u,v). Otherwise it is marked 0.
The idea of finding transitive closure using DFS is simple. We call DFS from every vertex u of the graph and check which vertices v are reachable from u. And mark the position (u,v) as 1 if reachable.
The asymptotic complexity of the DFS is
if we
are using adjacency matrix, where
is the total number of
vertices in the directed graph. So the complexity of using
transitive closure is
. The
reason is DFS is called for every vertex present. So
.
But if we are running DFS using recursive approach then there is a modification we can apply and decrease the computation time. We would not call for DFS for an adjacent vertex if it has already been reach by some other vertex.

Consider the above case. We first apply DFS on vertex A. We reach vertex B from there and mark the position (A,B) as 1.
After that we run DFS on B. We reach vertex C. After that we modify the location (A,C) as 1. But note that here we already know we can reach vertex C from B. We can also modify the location (B,C) as 1. Now we run DFS on vertex C and not finding any adjacent nodes we can move back to B. Then move to vertex D. Similarly we can mark both (A,D) and (B,D) as 1.
We can reduce the complexity using this approach to
as we are travelling each edge just once. The same approach can be
done for iterative DFS.
Depth-first Search vs Breadth-first Search Please explain the difference!
please help box answer discrete math
4. Use Warshall's algorithm to find the transitive closure of the relation whose ordered pair representation is (01.3) (2.3),(2.4),(34)
4. Use Warshall's algorithm to find the transitive closure of the relation whose ordered pair representation is (01.3) (2.3),(2.4),(34)
Use Warshall's Algorithm to find the transitive closure of the relation {(a,b), (b,a), (b,c), (b,e), (c,a), (d,c), (d,d), (e,c)} on {a, b, c, d, e}. Please leave your answer in matrix form.
Find the spanning tree using Breath and Depth first search. Show
work
Using breath-first search, find a spanning tree for the graph below Using depth-first search, find a spanning tree for the graph below.
Please clearly explain what are the differences between DFS (Depth First Search) and BFS (Breadth First Search)?
6) Explain how a cycle is found using Depth First Search in the followidg graph. Must the vertex v and Parent parameters are passed and used in the recursive calls. (16) show graphicaly how eat w 6
State whether each of the statements is true or false. Depth-first search is optimal. Depth-limited search can never find an optimal solution. Breadth-first search never reaches a dead end. Depth-limited search has a greater space complexity compared to breadth-first search. Breadth-first search expands deepest node first.
Discuss graph representation, Breadth-first search and Depth-first search. Use examples to highlight pros and cons.
- 9 (d) Use Depth First Search to find a spanning tree for the graph G as shown in Figure 4. (Note: assume the searching start from node f.) Guna Kedalaman Carian Pertama untuk mencari pohon merentang bagi graf G seperti ditunjukkan dalam Rajah 4. (Nota: andaikan carian bermula dari node f.) C Figure 4/ Rajah 4 (20/100)
- 9 (d) Use Depth First Search to find a spanning tree for the graph G as shown in Figure 4. (Note:...