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

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

View Full Document Right Arrow Icon
CSC2100A Spring 2006-2007 1 CSC2100A Tutorial Graph Spring 2006/2007
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
Background image of page 5

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

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7

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

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9

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

View Full DocumentRight Arrow Icon
Background image of page 10
Background image of page 11

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

View Full DocumentRight Arrow Icon
Background image of page 12
Background image of page 13

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

View Full DocumentRight Arrow Icon
Background image of page 14
Background image of page 15
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 Right Arrow Icon
Ask a homework question - tutors are online