Lecture25-aug10 - Assignment 5 Q&A Additional optimizations OK Exam due Wed Routing problems find an optimal path in a network 2 on Friday record

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Assignment 5 – Q&A – due Wed. Additional optimizations OK Exam 2 on Friday record your team stats for assignments 3, 4, 5 Last time – Types of graphs and properties of – Graph representation techniques – Traversals: DFS, BFS Today’s topics Finish Graphs (Chapter 12) Applets Routing problems – find an optimal path in a network A shortest path in a graph/digraph A cheapest path in a weighted graph/digraph Example – a directed graph that models an airline network Vertices represent cities Direct arcs represent flights connecting cities Task: find most direct route (least # of flights) Most direct route is equivalent to Finding length of shortest path Finding minimum number of arcs from start vertex to destination vertex Search algorithm for this shortest path An easy modification of the breadth-first search algorithm The shortest-path algorithm includes a queue that indirectly stores the vertices, using the corresponding node index (as in BFS). Each iterative step removes a vertex from the queue and searches its adjacency set/list to locate all of the unvisited neighbors and adds them to the queue. What is the shortest path from B to E ? 1. Visit start vertex and label it with a 0 2. Initialize distance to 0 3. Initialize a queue to contain only start 4. While destination is not yet visited and the queue not empty repeat the following: a) Remove a vertex v from the queue (dequeue) b) If the label of v > distance , increment distance c) For each vertex w that is adjacent to v if w has not been visited then i. Visit w and label it with distance + 1 ii. Add w to the queue (enqueue) End for End while From start to destination 5. If destination has not been visited then display "Destination not reachable from start vertex" else Find and list the vertices p[0] … p[distance] on shortest path as follows a. Initialize p[distance] to destination b. For each value of k ranging from distance – 1 down to 0 Find a vertex p[k] adjacent to p[k+1] with label k End for 6. stop Length 3 path: A B D F 0 1 1 1 2 3 3
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Brute force technique: Find all paths (non cyclic) from A to D and their total weights (DFS) Choose the minimum(s) from that set Works OK for a small graph Dijkstra's algorithm for Digraphs •Goal is to determine a path from a starting vertex s to an ending vertex d , of minimum weight •Its like the shortest path algorithm except this time we store the minimum weight (initialized to infinity) along a path from start (
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/15/2009 for the course EE 322C taught by Professor Nettles during the Summer '08 term at University of Texas at Austin.

Page1 / 7

Lecture25-aug10 - Assignment 5 Q&A Additional optimizations OK Exam due Wed Routing problems find an optimal path in a network 2 on Friday record

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online