Perform a depth-first search on the following graph; whenever theres a choice of vertices, pick the one that is alphabetically first. Classify each edge as a tree edge or back edge, and give the pre and post number of each vertex.
Read moreTextbook Solutions for Algorithms
Chapter 3 Problem 3.21
Question
Give a linear-time algorithm to find an odd-length cycle in a directed graph. (Hint: First solvethis problem under the assumption that the graph is strongly connected.)
Solution
Step 1 of 2
A digraph has an odd-length directed cycle if and only if one or more than one of its strong components is non-bipartite means use as an undirected graph.
Subscribe to view the
full solution
full solution
Title
Algorithms 1
Author
Sanjoy Dasgupta Algorithms, Christos H. Papadimitriou Algorithms, Umesh Vazirani Algorithms
ISBN
9780073523408