# Graph - – Dequeue a vertex X from the queue – Set its...

This preview shows pages 1–15. Sign up to view the full content.

CSC2100A Spring 2006-2007 1 CSC2100A Tutorial Graph Spring 2006/2007

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

View Full Document
CSC2100A Spring 2006-2007 2 Graph - overview – A subgraph of G = ( V , E ) is a graph G’ = ( V’ , E’ ) such that V’ V and E’ E A B C D E
CSC2100A Spring 2006-2007 3 Graph - shortest path – Unweighted shortest path • Find the shortest path from a vertex s to every other vertex in the graph – Algorithm • A queue is used • For each vertex, we have three variables – A boolean called Known – An integer d v for storing the shortest distance from – A variable called p v for tracing the shortest path

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

View Full Document
CSC2100A Spring 2006-2007 4 Graph - shortest path –S teps : • Initialize all Known to 0, all d v to (except the d v of vertex s to 0) and all p • Enqueue vertex

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

View Full Document

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

View Full Document

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

View Full Document

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: – Dequeue a vertex X from the queue – Set its Known to 1 – For each vertex Y that is adjacent to vertex X, • If vertex Y’s d v is infinity Set Y’s d v to (X’s d v + 1), Y’s p v to X and then enqueue vertex Y. CSC2100A Spring 2006-2007 5 Graph-Shortest path program CSC2100A Spring 2006-2007 6 Vertex A B C D E CSC2100A Spring 2006-2007 7 MapEntry & hash CSC2100A Spring 2006-2007 8 Get vertex CSC2100A Spring 2006-2007 9 Add Edge CSC2100A Spring 2006-2007 10 Print Path CSC2100A Spring 2006-2007 11 Clear all CSC2100A Spring 2006-2007 12 destruction CSC2100A Spring 2006-2007 13 Unweighted CSC2100A Spring 2006-2007 14 Process Request CSC2100A Spring 2006-2007 15 Sample main...
View Full Document

## This note was uploaded on 12/28/2010 for the course CSC CSC1110 taught by Professor Cjyuan during the Fall '06 term at CUHK.

### Page1 / 15

Graph - – Dequeue a vertex X from the queue – Set its...

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

View Full Document
Ask a homework question - tutors are online