UNDIRECTED GRAPHS STUDY GUIDE


Graph representation.   There are many possible internal representations of a graph. We discussed three. You should be familiar with the tradeoffs for each.

Usually, we use the adjacency-lists representation because most real-world graphs are sparse.

Important graph problems.   You should be familiar with the following problems.

You should know how to solve the first three—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.

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 linear 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 linear time, but all known algorithms are extremely complex. Graph isomorphism is particularly notable since its tractability has remained elusive despite decades of research.

Graph traversal.

Graph client design pattern (used for 4.1, 4.2, 4.3, and 4.4).   Instead of creating bloated data types that both provide basic graph operations and solve graph problems, we have one class (e.g. Graph) that provides basic graph operations and many special-purpose clients, each of which solves one graph problem (e.g. ConnectedComponents).

Recommended Problems

C level

  1. Fall 09 Final, #2a
  2. Textbook: 4.1.12

B level

  1. Fall 09 Final, #2b
  2. Fall 10 Final, #2c
  3. Textbook: 4.1.14, 4.1.10
  4. What is the running time for DFS or BFS if we use an adjacency matrix insted of adjacency lists?

A level

  1. Fall 12 Final, #15
  2. Textbook: 4.1.33