Lecture Notes for CS 512, Algorithm Design
7 September 1999
These are provisional lecture notes, expect changes.
- Topological sorting.
- Graph terms: directed, in-degree, out-degree, path, cycle, acyclic.
- Models this before that relations.
- nodes are activities; directed edges are do this before that
relations.
- Examples: programming languages; activity
charts (pert or gantt charts); related mathematically to the partial
order.
Observations - acyclic, definite starting points.
- Objective: linearize the graph to produce a list of tasks in the proper
order (a topological order).
- Observation - Many topological orders per graph; do a first nodes
first, then consider the rest.
- Questions: Are we doing it correctly? Are we making progress?
- Algorithm: find in-degrees and leaders; peel off each leader,
adjusting in-degrees and new leaders each time.
- Cost: touch each node and each edge, so cost is O(|V| + |E|).
- Graph Traversals.
- Graph terminology: child, sibling, parent, ancestor, descendent,
level, subgraphs, tree, spanning tree.
- Lots of them: Hamiltonian, Eulerian
- Depth-first search.
- mark; work; recurse; work - pre and post work for each vertex.
- all nodes and edges touched at least once (undirected).
- ergo, cost is O(|V| + |E|).
- depth-first numbering - ancestor numbers are smaller than child
numbers.
- depth-first spanning tree - Edges go up and down, not across.
- directed graphs - dfs numbers preserve ancestry over edges.
- edges - tree, back, forward, and cross.
- back edges indicate cycles.
- Breadth-first search.
- visit children first - a queue; pre-work but no post-work.
- properties - parents get to children first; the paths from node 1 to
all other nodes is shortest in the graph; non-tree edges span
adjacent levels only.
- Single-source shortest paths.
- Objective - given n, find the shortest paths from n to all other nodes
in the graph.
- Graph terminology - weights, path weights.
- acyclic graphs - use a topological sort to order the nodes; bottom up.
- arbitrary graphs - start from the top down; blob out for new paths.
- is the new path truly the minimal path from v?
- greed.
- heap insertion or deletion can take log steps; |V| deletions and
|E| modifications (additions) leads to
O(|V|log(|V|) + |E|log(|V|)) cost.
- Minimum-cost spanning tree.
- Objective - A least cost tree subgraph; broadcast.
- Observation - this is almost sssp, except now edges are important.
This page last modified on 7 September 1999.