cs251-week14

cs251-week14 - CS251 Notes November 29 Announcements: Sign...

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

View Full Document Right Arrow Icon
CS251 Notes – November 29 Announcements: Sign up for lab 5 demo/grading slots Will be demo’ing labs with a map that has 100 locations in it Graphs: A graph G = (V,E) is composed of: V: a set of vertices E: a set of edges connecting vertices An edge e = (u,v) connects vertices u and v. V = { A, B, C, D, E} E = { (a,b) (b,c), … (d,e) } Graphs are useful because many problems can be represented by them: i.e. communication networks. (internet) i.e. transportation networks. (lab 5) i.e. event dependencies. (house building) If you can represent a problem in Graph, there already exists algorithms to help you find a solution. - Such as topological sort, shortest path, and spanning tree. Undirected Graph: A graph whose edge’s don’t have direction O ----- O Directed Graph: A graph whose edge’s have direction. O ----> O
Background image of page 1

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

View Full DocumentRight Arrow Icon
Graph Representation: Edge list: a list of edges A list containing (a,b) (a,c) (b,d) … (f,e) Adjacency list: a list of neighbors for each A {B,C} B {A,D} F {D,E} Adjacency Matrix: an MxM matrix where m = # of vertices. A B C D E F A 0 1 1 0 0 0 B 1 0 0 1 0 0 C 1 0 0 1 0 0 D 0 1 1 0 1 1 E 0 0 0 1 0 1 F 0 0 0 1 1 0 Notice that an undirected graph has a symmetric matrix. Matrix[i][j] equals 1 if they are adjacent, 0 if not.
Background image of page 2
Shortest Path Algorithm Weighted Graph: edges are associated with a weight ( i.e. distance on a transportation graph) Dijkstra created Shortest Path Algorithm ( sometimes called Dijkstra’s algo.) Dijkstra’s Algorithm Pseudo Code: ( note weights must all be positive)
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

cs251-week14 - CS251 Notes November 29 Announcements: Sign...

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

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