GRAPHS AND DIGRAPHS II STUDY GUIDE
BFS and DFS are directed graph algorithms.
Many canonical unweighted digraph problems (e.g. shortest paths and reachability) can be
solved using code that is effectively identical to code for solving problems on unweighted
Importan digraph graph traversals.
- Breadth-first search.
- Depth-first search (including preorder, postorder, and reverse postorder).
- What is a topological order?
- When is it unique?
- Under which conditions does a digraph have a topological sort?
- How do you compute a topological order?
- What is the running time of that algorithm (using adjacency lists)?
Important graph problems. You should be familiar with
the following problems.
You should know how to solve the first five—not necessarily because these problems
are so important, but because you should have at least a few examples of
how to use DFS or BFS to solve problems.
For the last four, it's good scholarship to be know whether the problem is tractable
(polynomial time) and whether there exists an easy to understand tractable algorithm. We may
even ask you how these things on an exam. You do not need to be familiar with the details of
the best known algorithm for their solution.
- Connectivity. Is there a path between s and t?
- Reachability. Is there a directed path from s to t?
- Cycle. Find a cycle in the graph (if one eists).
- Directed cycle. Find a directed cycle in the digraph (if one exists).
- Bipartiteness. Is a graph bipartite?
- Euler cycle. Find a cycle that uses every edge exactly once (if one exists).
- Hamilton cycle. Find a cycle that uses every vertex exactly once (if one exists).
- Planarity. Draw the graph in the plane with no crossing edges (if possible).
(See this online game for a fun look at the problem.)
- Graph isomorphism. Are two graphs the same graph (but with different vertex names)?
One important meta-point is that there is no easy way to determine the complexity
of a graph problem. For example, finding an Euler cycle is solvable
in Θ(E + V) time
(and the algorithm is non-trivial but not hideously complex).
By contrast, finding a Hamilton cycle is an intractable problem.
Planarity can be solved in Θ(E + V) time,
but all known algorithms are extremely complex.
Graph isomorphism is particularly notable since its tractability has
remained elusive despite decades of research.
- Spring 2012 final, #3b
- Fall 2017 Final, #5b
- Fall 2017 Final, #5c
- Fall 2019 Final, #4c
- Textbook: 4.2.10, 4.2.20
- What is the running time for BFS if we use the adjacency-matrix representation (instead of the adjacency-lists representation)?
- 4.2.19, 4.2.22
Just for fun
- Write code similar to (or copy) the web crawler shown in lecture.