Apr 11
Discuss the homework due today - my solutions are in the
hw apr11 folder.
textbook material
We'll see which ones we want to take up and either
discuss a little, or discuss a lot and code, possibly as homework.
These two we've already discussed.
- The Word Ladder Problem (from the textbook)
- The Knights Tour Problem (also in the textbook)
Strongly Connected Components
(i.e. for URL links, in the textbook)
The last one uses these ideas for a particular depth-first-search.
The textbook discusses some addition ideas sometimes used in depth first search,
used for directed graphs (edges are arrows that point from one vertex to another).
"Strongly Connected subset": set {V} such that if there is a path from V[i] to V[j],
then there is also a path from V[j] to V[i].
"Forest": a set of Trees, each unconnected from the other.
In the depth first algorithm, if the graph is directed then starting in the "middle"
means that some vertices can't be reached. For example, A -> B -> C starting at B.
The fix is that rather than just starting at one vertex, start at all non-white
(i.e. unvisited) nodes after each depth_first_search. So starting at B would visit B -> C,
then start again at A which fills in A -> B . (Since B is visited, the rest of
the tree isn't recomputed.) This may end up with a forest if the graph is unconnected.
"Start time" , "Finish time" : the depth first algorithm as done in the
textbook starts nodes as white (unvisited), then turns them grey (scheduled),
then black (visited). If we keep a "time" counter for how many vertices have
been seen, then we can record for each vertex the time at which it turns
grey ("start time") and the time at which it turns black ("end time").
these times can be used to put them in order. (This is only really useful
for directed graphs.)
I've collected their code for this stuff in the
textbook folder.
"shortest" algorithms
There are a number of algorithms to find various "shortest" graph properties.
Below are a few of the well known ones.
Some of these are in the text, others we may do with other resources.
Remembering the details isn't the main point, instead I would like you to get exposed to what sorts of techniques are out there.
Notice that they commonly use the data structures that we've already discussed (such as stacks, queues, binary heaps). Note also that there are tradeoffs in the O() behavior, and that different algorithms may be better depending on the qualities (such as sparseness) of the graph.
Minimum spanning tree
Shortest path
path finding (often used in game or robot motion)
- an extension of Dijkstra's using heuristic guess to order search
- A* at wikipedia
- discussion
Graph Diameter - longest shortest path (I asked about this in the April 11 homework)