This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ce to keep track of paths we discover, their costs, etc. In particular, our scratch space (in computer science lingo, this is called a data structure) is a table with one row per vertex (destination). For our example, we would need a table with 5 rows for vertices A, B, C, D, and E. In the table we will keep track of two pieces of information: The best path we have discovered (so far) and the corresponding cost. 8 Next, we would need to initialize our table.
In particular, it is obvious that if we pick A (the start vertex) as our destination, then we just stay where we are, and the cost of doing so is zero! Thus, we initialize the cost and path for A accordingly. For all other vertices, since at this stage we do not know how to get to any of them (from A), we initialize their costs to infinity. 9 In our table, we will distinguish between two sets of vertices: 1. Those for which we have computed a (proven) shortest path. We will color these RED. Initially, the start vertex is the only RED vertex 2. Those for which we do not have a (proven) shortest path. We will color these BLUE. Initially, all vertices except the start vertex are BLUE. Our goal (eventually, by the end of our procedure) is to compute the shortest path for all vertices. In other words, our goal is to turn all BLUE vertices to RED vertices. We will try to do this incrementally by turning one vertex from BLUE to RED at a time. 10 The only way to reach any of the blue vertices from the start vertex is to follow one of the green‐colored edges (basically, there is no other way to get to these blue ve...
View Full Document
This note was uploaded on 02/10/2014 for the course CS 109 taught by Professor Azerbestavros during the Spring '13 term at BU.
- Spring '13