# lec12 - 6.006 Introduction to Algorithms Lecture 12 Graph...

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

6.006- Introduction to Algorithms Lecture 12 – Graph Algorithms Prof. Manolis Kellis CLRS 22.2-22.3

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

View Full Document
Combinatorics Ponytail No ponytail Beard Erik ? No Beard Piotr Manolis
Unit #4 – Games, Graphs, Searching, Networks 3

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

View Full Document
Unit #4 Overview: Searching Today: Introduction to Games and Graphs Rubik’s cube, Pocket cube, Game space Graph definitions, representation, searching Tuesday: Graph algorithms and analysis Breadth First Search, Depth First Search Queues, Stacks, Augmentation, Topological sort Thursday: Networks in biology and real world Network/node properties, metrics, motifs, clusters Dynamic processes, epidemics, growth, resilience
Last time: Games and Graphs

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

View Full Document
Pocket Cube 2 × 2 × 2 Rubik’s cube Start with any colors Moves are quarter turns of any face “Solve” by making each side one color
Searching for a solution path Graph algorithms allow us explore space – Nodes: configurations – Edges: moves between them – Paths to ‘solved’ configuration: solutions 1 turn 6 neighbors 27 two-away How big is the space?

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

View Full Document
Graphs V={a,b,c,d} E={{a,b}, {a,c}, {b,c}, {b,d}, {c,d}} V = {a,b,c} E = {(a,c), (a,b) (b,c), (c,b)} a c d b a b c G=(V,E) V a set of vertices Usually number denoted by n E V × V a set of edges (pairs of vertices) Usually number denoted by m Note m n(n-1) = O(n 2 ) Undirected example Directed example
Graph Representation Adjacency lists Incidence lists Adjacency matrix Implicit representation a b c c c / b / b / a b c (a,c) (a,b) / (b,c) / (c,b) / a (1) b (2) c (3) 0 1 1 a (1) 0 0 1 b (2) 0 1 0 c (3) Neighbors(a) [c,b] Neighbors(b) [b] Neighbors(c) [b] a b c

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

View Full Document
Today: Searching graphs ?
Searching Graph We want to get from current Rubik state to “solved” state How do we explore?

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

View Full Document
Breadth First Search start with vertex v list all its neighbors (distance 1) then all their neighbors (distance 2) etc. algorithm starting at s: define frontier F initially F={s} repeat F=all neighbors of vertices in F until all vertices found