Algorithm Analysis (CSC 301 2015F) : Outlines
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning]
Current: [Outline] [EBoard] [Reading] [Lab] [Assignment]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Readings]
Reference: [Algorist]
Related Courses: [Walker (2014F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker]
Held: Monday, 9 November 2015
Back to Outline 28 - Sets and Union-Find. On to Outline 30 - Pause for Breath.
Summary
We consider a variety of shortest-path problems in weighted graphs.
Related Pages
Overview
Administrivia
The shortest-path problem is relatively straightforward: Given two nodes, source and sink, an an edge-weighted graph, find the shortest path from source to sink.
There are many variants:
Dijkstra's works for graphs with non-negative edge weights, either directed or undirected. Instead of finding the shortest path from source to sink, it finds the shortest path from source to every node.
Node predecessor[n] // Predecessor on shortest path
int distance[n] // Distance to node; initialize to infinite
boolean processed[n]// Have we processed node n.
distance[source] = 0
while there are unprocessed nodes
find u, the unprocessed node with the shortest distance
mark u as processed
for each edge (u,v)
if (distance[u] + weight[u,v] < distance[v])
predecessor[v] = u
distance[v] = distance[u] + weight[u,v]
We'll probably generate a randomized graph on the fly.
How would you build a matrix of the lengths of all of the shortest paths between any two vertices in a graph?
We will gradually build the matrix by looking at paths that only go through vertices 0 .. k.
Suppose we've correctly built the matrix for 0 .. k-1. How do we build the matrix for k?