Graph Representation

Size: px
Start display at page:

Download "Graph Representation"

Transcription

1 Graph Representation Adjacency list representation of G = (V, E) An array of V lists, one for each vertex in V Each list Adj[u] contains all the vertices v such that there is an edge between u and v Adj[u] contains the vertices adjacent to u (in arbitrary order) Can be used for both directed and undirected graphs Undirected graph / / /

2 Properties of Adjacency-List Representation Sum of the lengths of all the adjacency lists Directed graph: E Directed graph Edge (u, v) appears only once in u s list Undirected graph: 2 E u and v appear in each other s adjacency lists: edge (u, v) appears twice Undirected graph 2

3 Properties of Adjacency-List Representation Memory required (V + E) Preferred when the graph is sparse: E << V Disadvantage no quick way to determine whether there is an edge between node u and v Time to list all vertices adjacent to u: (degree(u)) Time to determine if (u, v) E: Undirected graph Directed graph O(degree(u)) 3

4 Graph Representation Adjacency matrix representation of G = (V, E) Assume vertices are numbered 1, 2, V The representation consists of a matrix A V x V : a ij = 1 if (i, j) E otherwise Matrix A is symmetric: 5 4 Undirected graph a ij = a ji A = A T 4

5 Properties of Adjacency Matrix Memory required Representation (V 2 ), independent on the number of edges in G Preferred when The graph is dense E is close to V 2 We need to quickly determine if there is an edge between two vertices Time to list all vertices adjacent to u: (V) Time to determine if (u, v) E: (1) 5

6 Weighted Graphs Weighted graphs = graphs for which each edge has an associated weight w(u, v) w: E R, weight function Storing the weights of a graph Adjacency list: Store w(u,v) along with vertex v in u s adjacency list Adjacency matrix: Store w(u, v) at location (u, v) in the matrix 6

7 Searching in a Graph Graph searching = systematically follow the edges of the graph so as to visit the vertices of the graph Two basic graph searching algorithms: Breadth-first search Depth-first search The difference between them is in the order in which they explore the unvisited edges of the graph Graph algorithms are typically elaborations of the basic graph-searching algorithms 7

8 Input: Breadth-First Search (BFS) A graph G = (V, E) (directed or undirected) A source vertex s V Goal: Explore the edges of G to discover every vertex reachable from s, taking the ones closest to s first Output: d[v] = distance (smallest # of edges) from s to v, for all v V A breadth-first tree rooted at s that contains all reachable vertices 8

9 Breadth-First Search (cont.) Discover vertices in increasing order of distance from the source s search in breadth not depth Find all vertices at 1 edge from s, then all vertices at 2 edges from s, and so on

10 Breadth-First Search (cont.) Keeping track of progress: Color each vertex in either white, gray or black Initially, all vertices are white When being discovered a vertex becomes gray After discovering all its adjacent vertices the node becomes black Use FIFO queue Q to maintain the set of gray vertices source

11 Breadth-First Tree BFS constructs a breadth-first tree Initially contains the root (source vertex s) When vertex v is discovered while scanning the adjacency list of a vertex u vertex v and edge (u, v) are added to the tree u is the predecessor (parent) of v in the breadth-first tree A vertex is discovered only once it has at most one parent source

12 BFS Additional Data Structures G = (V, E) represented using adjacency lists color[u] the color of the vertex for all u V [u] predecessor of u If u = s (root) or node u has not yet been discovered [u] = NIL d[u] the distance from the source s to vertex u Use a FIFO queue Q to maintain the set of gray vertices source d=1 = d=1 =1 d=2 =5 3 d=2 =2 12

13 BFS(G, s) 1. for each u V[G] - {s} 2. do color[u] WHITE 3. d[u] 4. [u] = NIL 5. color[s] GRAY 6. d[s] 0 7. [s] = NIL 8. Q 9. Q ENQUEUE(Q, s) r s t u v w x y r s t u v w x y r s t u 0 v w x y Q: s 13

14 BFS(V, E, s) 10. while Q 11. do u DEQUEUE(Q) 12. for each v Adj[u] 13. do if color[v] = WHITE 14. then color[v] GRAY 15. d[v] d[u] [v] = u 17. ENQUEUE(Q, v) 18. color[u] BLACK r s t u 0 v w x y r s t u 0 1 v w x y r s t u v w x y Q: s Q: w Q: w, r 14

15 r s t u 0 Example r s t u 1 0 r s t u v w x y Q: s r s t u v w x y Q: w, r r s t u v w x y Q: r, t, x r s t u v w x y Q: t, x, v r s t u v w x y Q: x, v, u r s t u v w x y Q: v, u, y r s t u v w x y Q: u, y v w x y Q: y v w x y Q: COSC3101A 15

16 Analysis of BFS 1. for each u V - {s} 2. do color[u] WHITE 3. d[u] 4. [u] = NIL 5. color[s] GRAY 6. d[s] 0 7. [s] = NIL 8. Q 9. Q ENQUEUE(Q, s) O(V) (1) 16

17 Analysis of BFS 10. while Q 11. do u DEQUEUE(Q) 12. for each v Adj[u] 13. do if color[v] = WHITE 14. then color[v] = GRAY 15. d[v] d[u] [v] = u 17. ENQUEUE(Q, v) (1) Scan Adj[u] for all vertices in the graph Each vertex is scanned only once, when the vertex is dequeued Sum of lengths of all adjacency lists = (E) Scanning operations: O(E) (1) 18. color[u] BLACK Total running time for BFS = O(V + E) 17

18 Shortest Paths Property BFS finds the shortest-path distance from the source vertex s V to each node in the graph Shortest-path distance = (s, u) Minimum number of edges in any path from s to u source r s t u v w x y 18

19 Input: Depth-First Search G = (V, E) (No source vertex given!) Goal: Explore the edges of G to discover every vertex in V starting at the most current visited node Search may be repeated from multiple sources Output: 2 timestamps on each vertex: d[v] = discovery time f[v] = finishing time (done with examining v s adjacency list) Depth-first forest

20 Depth-First Search Search deeper in the graph whenever possible Edges are explored out of the most recently discovered vertex v that still has unexplored edges After all edges of v have been explored, the search backtracks from the parent of v The process continues until all vertices reachable from the original source have been discovered If undiscovered vertices remain, choose one of them as a new source and repeat the search from that vertex DFS creates a depth-first forest

21 DFS Additional Data Structures Global variable: time-step Incremented when nodes are discovered/finished color[u] similar to BFS White before discovery, gray while processing and black when finished processing [u] predecessor of u d[u], f[u] discovery and finish times WHITE 1 d[u] < f [u] 2 V GRAY BLACK 0 d[u] f[u] 2V 21

22 DFS(G) 1. for each u V[G] 2. do color[u] WHITE 3. [u] NIL 4. time 0 5. for each u V[G] 6. do if color[u] = WHITE 7. then DFS-VISIT(u) Every time DFS-VISIT(u) is called, u becomes the root of a new tree in the depth-first forest 22

23 DFS-VISIT(u) 1. color[u] GRAY 2. time time+1 3. d[u] time 4. for each v Adj[u] 5. do if color[v] = WHITE 6. then [v] u 7. DFS-VISIT(v) 8. color[u] BLACK 9. time time f[u] time time = 1 1/ 1/ 2/ 23

24 Example 1/ 1/ 2/ 1/ 2/ 1/ 2/ 4/ 3/ 1/ 2/ B 4/5 3/6 1/ 2/ B 4/ 3/ 1/ 2/7 B 4/5 3/6 3/ 1/ 2/ B 4/5 3/ 1/ 2/7 F B 4/5 3/6 24

25 Example (cont.) 1/8 2/7 F B 1/8 2/7 9/ F B 1/8 2/7 9/ C F B 4/5 3/6 4/5 3/6 4/5 3/6 1/8 2/7 9/ C F B 4/5 3/6 10/ 1/8 2/7 9/ C F B 4/5 3/6 10/ B 1/8 2/7 9/ C F B 4/5 3/6 10/11 B 1/8 2/7 9/12 C F B 4/5 3/6 10/11 B The results of DFS may depend on: The order in which nodes are explored in procedure DFS The order in which the neighbors of a vertex are visited in DFS-VISIT 25

26 Edge Classification Tree edge (reaches a WHITE vertex): (u, v) is a tree edge if v was first discovered by exploring edge (u, v) 1/ Back edge (reaches a GRAY vertex): (u, v), connecting a vertex u to an ancestor v in a depth first tree Self loops (in directed graphs) are also back edges 1/ 2/ B 4/ 3/ 26

27 Edge Classification Forward edge (reaches a BLACK vertex & d[u] < d[v]): Non-tree edges (u, v) that connect a vertex u to a descendant v in a depth first tree Cross edge (reaches a BLACK vertex & d[u] > d[v]): Can go between vertices in same depth-first tree (as long as there is no ancestor / descendant relation) or between different depth-first trees 1/ 2/7 F B 4/5 3/6 1/8 2/7 9/ C F B 4/5 3/6 27

28 1. for each u V[G] Analysis of DFS(G) 2. do color[u] WHITE 3. [u] NIL 4. time 0 5. for each u V[G] 6. do if color[u] = WHITE 7. then DFS-VISIT(u) (V) (V) exclusive of time for DFS-VISIT 28

29 Analysis of DFS-VISIT(u) 1. color[u] GRAY 2. time time+1 3. d[u] time 4. for each v Adj[u] DFS-VISIT is called exactly once for each vertex 5. do if color[v] = WHITE 6. then [v] u 7. DFS-VISIT(v) Each loop takes Adj[v] 8. color[u] BLACK 9. time time f[u] time Total: Σ v V Adj[v] + (V) = (V + E) (E) 29

30 Properties of DFS u = [v] DFS-VISIT(v) was called during a search of u s adjacency list 1/ 2/ Vertex v is a descendant of vertex u in the depth first forest v is 3/ discovered during the time in which u is gray 30

31 Parenthesis Theorem In any DFS of a graph G, for all u, v, exactly one of the following holds: 1. [d[u], f[u]] and [d[v], f[v]] are disjoint, and neither of u and v is a descendant of the other 2. [d[v], f[v]] is entirely within [d[u], f[u]] and v is a descendant of u 3. [d[u], f[u]] is entirely within [d[v], f[v]] and u is a descendant of v y x y z s 3/6 2/9 1/10 4/5 7/8 12/13 x s z w w v t 11/16 14/ (s (z (y (x x) y) (w w) z) s) (t (v u) (u u) t) Well-formed expression: parenthesis are properly nested u v t u 31

32 Other Properties of DFS Corollary Vertex v is a proper descendant of u d[u] < d[v] < f[v] < f[u] Theorem (White-path Theorem) In a depth-first forest of a graph G, vertex v is a descendant of u if and only if at time d[u], there is a path u v consisting of only white vertices. 1/8 2/7 9/12 C F B 4/5 3/6 10/11 v u 1/ 2/ v u B 32

33 Topological Sort Topological sort of a directed acyclic graph G = (V, E): a linear order of vertices such that if there exists an edge (u, v), then u appears before v in the ordering. Directed acyclic graphs (DAGs) Used to represent precedence of events or processes that have a partial order a before b b before c a before c b before c a before c What about a and b? Topological sort helps us establish a total order 33

34 Topological Sort undershorts 11/ 16 17/ 18 socks TOPOLOGICAL-SORT(V, E) pants 12/ 15 shoes 13/ Call DFS(V, E) to compute finishing times f[v] for each 6/ 7 belt shirt tie 1/ 8 2/ 5 watch 9/ 10 vertex v 2. When each vertex is finished, insert it onto the front of a linked list jacket 3/ 4 3. Return the linked list of vertices socks undershorts pants shoes watch shirt belt tie jacket Running time: (V + E) 34

35 Topological Sort undershorts 11/ 16 17/ 18 socks 6/ 7 pants belt 12/ 15 shirt tie 1/ 8 2/ 5 shoes watch 13/ 14 9/ 10 Topological sort: an ordering of vertices along a horizontal line so that all directed edges go from left to right. jacket 3/ 4 socks undershorts pants shoes watch shirt belt tie jacket 35

36 Lemma A directed graph is acyclic a DFS on G yields no back edges. Proof: : acyclic no back edge (u, v) Assume back edge prove cycle Assume there is a back edge (u, v) v is an ancestor of u there is a path from v to u in G (v u) v u + the back edge (u, v) yield a cycle u v 36

37 Strongly Connected Components Given directed graph G = (V, E): A strongly connected component (SCC) of G is a maximal set of vertices C V such that for every pair of vertices u, v C, we have both u v and v u. 37

38 The Transpose of a Graph G T = transpose of G G T is G with all edges reversed G T = (V, E T ), E T = {(u, v) : (v, u) E} If using adjacency lists: we can create G T in (V + E) time

39 Finding the SCC Observation: G and G T have the same SCC s u and v are reachable from each other in G they are reachable from each other in G T Idea for computing the SCC of a DAG G = (V, E): Make two depth first searches: one on G and one on G T

40 Example a b c d 13/ 14 11/ 16 1/ 10 8/ 9 DFS on the initial graph G 12/ 15 3/ 4 2/ 7 5/ 6 b 16 e 15 a 14 c 10 d 9 g 7 h 6 f 4 e f g h a b c d DFS on G T: start at b: visit a, e start at c: visit d start at g: visit f start at h e f g h Strongly connected components: C 1 = {a, b, e}, C 2 = {c, d}, C 3 = {f, g}, C 4 = {h} 40

41 Component Graph a b c d c d a b e e f g h The component graph G SCC = (V SCC, E SCC ): V SCC = {v 1, v 2,, v k }, where v i corresponds to each strongly connected component C i There is an edge (v i, v j ) E SCC if G contains a directed edge (x, y) for some x C i and y C j The component graph is a DAG f g h 41

42 Lemma 1 Let C and C be distinct SCC s in G Let u, v C, and u, v C Suppose there is a path u u in G Then there cannot also be a path v v in G. Proof Suppose there is a path v v There exists u u v There exists v v u u and v are reachable from each other, so they are not in separate SCC s: contradiction! u C C u v v 42

43 Notations Extend notation for d (starting time) and f (finishing time) to sets of vertices U V: d(u) = min u U { d[u] } (earliest discovery time) f(u) = max u U { f[u] } (latest finishing time) d(c 1 ) f(c 1 ) =11 =16 C 1 C 2 a b c d 13/ 14 11/ 16 1/ 10 8/ 9 d(c 2 ) f(c 2 ) =1 =10 12/ 15 3/ 4 2/ 7 5/ 6 e f g h d(c 3 ) f(c 3 ) =2 =7 C 3 C 4 d(c 4 ) f(c 4 ) =5 =6 43

Graph: representation and traversal

Graph: representation and traversal Graph: representation and traversal CISC4080, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang! Acknowledgement The set of slides have use materials from the following resources Slides for textbook

More information

Graphs. Graph G = (V, E) Types of graphs E = O( V 2 ) V = set of vertices E = set of edges (V V)

Graphs. Graph G = (V, E) Types of graphs E = O( V 2 ) V = set of vertices E = set of edges (V V) Graph Algorithms Graphs Graph G = (V, E) V = set of vertices E = set of edges (V V) Types of graphs Undirected: edge (u, v) = (v, u); for all v, (v, v) E (No self loops.) Directed: (u, v) is edge from

More information

Representations of Graphs

Representations of Graphs ELEMENTARY GRAPH ALGORITHMS -- CS-5321 Presentation -- I am Nishit Kapadia Representations of Graphs There are two standard ways: A collection of adjacency lists - they provide a compact way to represent

More information

Graph representation

Graph representation Graph Algorithms 1 Graph representation Given graph G = (V, E). May be either directed or undirected. Two common ways to represent for algorithms: 1. Adjacency lists. 2. Adjacency matrix. When expressing

More information

Chapter 22. Elementary Graph Algorithms

Chapter 22. Elementary Graph Algorithms Graph Algorithms - Spring 2011 Set 7. Lecturer: Huilan Chang Reference: (1) Cormen, Leiserson, Rivest, and Stein, Introduction to Algorithms, 2nd Edition, The MIT Press. (2) Lecture notes from C. Y. Chen

More information

Basic Graph Algorithms

Basic Graph Algorithms Basic Graph Algorithms 1 Representations of Graphs There are two standard ways to represent a graph G(V, E) where V is the set of vertices and E is the set of edges. adjacency list representation adjacency

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms Design and Analysis of Algorithms CSE 5311 Lecture 18 Graph Algorithm Junzhou Huang, Ph.D. Department of Computer Science and Engineering CSE5311 Design and Analysis of Algorithms 1 Graphs Graph G = (V,

More information

DFS & STRONGLY CONNECTED COMPONENTS

DFS & STRONGLY CONNECTED COMPONENTS DFS & STRONGLY CONNECTED COMPONENTS CS 4407 Search Tree Breadth-First Search (BFS) Depth-First Search (DFS) Depth-First Search (DFS) u d[u]: when u is discovered f[u]: when searching adj of u is finished

More information

Elementary Graph Algorithms

Elementary Graph Algorithms Elementary Graph Algorithms Graphs Graph G = (V, E)» V = set of vertices» E = set of edges (V V) Types of graphs» Undirected: edge (u, v) = (v, u); for all v, (v, v) E (No self loops.)» Directed: (u, v)

More information

Graph: representation and traversal

Graph: representation and traversal Graph: representation and traversal CISC5835, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang Acknowledgement The set of slides have use materials from the following resources Slides for textbook

More information

Computer Science & Engineering 423/823 Design and Analysis of Algorithms

Computer Science & Engineering 423/823 Design and Analysis of Algorithms s of s Computer Science & Engineering 423/823 Design and Analysis of Lecture 03 (Chapter 22) Stephen Scott (Adapted from Vinodchandran N. Variyam) 1 / 29 s of s s are abstract data types that are applicable

More information

Computer Science & Engineering 423/823 Design and Analysis of Algorithms

Computer Science & Engineering 423/823 Design and Analysis of Algorithms Computer Science & Engineering 423/823 Design and Analysis of Algorithms Lecture 04 Elementary Graph Algorithms (Chapter 22) Stephen Scott (Adapted from Vinodchandran N. Variyam) sscott@cse.unl.edu Introduction

More information

CISC 320 Introduction to Algorithms Fall Lecture 15 Depth First Search

CISC 320 Introduction to Algorithms Fall Lecture 15 Depth First Search IS 320 Introduction to lgorithms all 2014 Lecture 15 epth irst Search 1 Traversing raphs Systematic search of every edge and vertex of graph (directed or undirected) fficiency: each edge is visited no

More information

Graph Algorithms: Chapters Part 1: Introductory graph concepts

Graph Algorithms: Chapters Part 1: Introductory graph concepts UMass Lowell Computer Science 91.503 Algorithms Dr. Haim Levkowitz Fall, 2007 Graph Algorithms: Chapters 22-25 Part 1: Introductory graph concepts 1 91.404 Graph Review Elementary Graph Algorithms Minimum

More information

Minimum Spanning Trees Ch 23 Traversing graphs

Minimum Spanning Trees Ch 23 Traversing graphs Next: Graph Algorithms Graphs Ch 22 Graph representations adjacency list adjacency matrix Minimum Spanning Trees Ch 23 Traversing graphs Breadth-First Search Depth-First Search 11/30/17 CSE 3101 1 Graphs

More information

COT 6405 Introduction to Theory of Algorithms

COT 6405 Introduction to Theory of Algorithms COT 6405 Introduction to Theory of Algorithms Topic 14. Graph Algorithms 11/7/2016 1 Elementary Graph Algorithms How to represent a graph? Adjacency lists Adjacency matrix How to search a graph? Breadth-first

More information

CHAPTER 23: ELEMENTARY GRAPH ALGORITHMS Representations of graphs

CHAPTER 23: ELEMENTARY GRAPH ALGORITHMS Representations of graphs CHAPTER 23: ELEMENTARY GRAPH ALGORITHMS This chapter presents methods for representing a graph and for searching a graph. Searching a graph means systematically following the edges of the graph so as to

More information

Graph Search. Adnan Aziz

Graph Search. Adnan Aziz Graph Search Adnan Aziz Based on CLRS, Ch 22. Recall encountered graphs several weeks ago (CLRS B.4) restricted our attention to definitions, terminology, properties Now we ll see how to perform basic

More information

Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees

Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees T. H. Cormen, C. E. Leiserson and R. L. Rivest Introduction to Algorithms, 3rd Edition, MIT Press, 2009 Sungkyunkwan University Hyunseung Choo

More information

Elementary Graph Algorithms. Ref: Chapter 22 of the text by Cormen et al. Representing a graph:

Elementary Graph Algorithms. Ref: Chapter 22 of the text by Cormen et al. Representing a graph: Elementary Graph Algorithms Ref: Chapter 22 of the text by Cormen et al. Representing a graph: Graph G(V, E): V set of nodes (vertices); E set of edges. Notation: n = V and m = E. (Vertices are numbered

More information

Basic Graph Algorithms (CLRS B.4-B.5, )

Basic Graph Algorithms (CLRS B.4-B.5, ) Basic Graph Algorithms (CLRS B.-B.,.-.) Basic Graph Definitions A graph G = (V,E) consists of a finite set of vertices V and a finite set of edges E. Directed graphs: E is a set of ordered pairs of vertices

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms Design and Analysis of Algorithms CS 5311 Lecture 19 Topological Sort Junzhou Huang, Ph.D. Department of Computer Science and ngineering CS5311 Design and Analysis of Algorithms 1 Topological Sort Want

More information

Introduction to Algorithms. Lecture 11

Introduction to Algorithms. Lecture 11 Introduction to Algorithms Lecture 11 Last Time Optimization Problems Greedy Algorithms Graph Representation & Algorithms Minimum Spanning Tree Prim s Algorithm Kruskal s Algorithm 2 Today s Topics Shortest

More information

Data Structures. Elementary Graph Algorithms BFS, DFS & Topological Sort

Data Structures. Elementary Graph Algorithms BFS, DFS & Topological Sort Data Structures Elementary Graph Algorithms BFS, DFS & Topological Sort 1 Graphs A graph, G = (V, E), consists of two sets: V is a finite non-empty set of vertices. E is a set of pairs of vertices, called

More information

Graph Algorithms. Definition

Graph Algorithms. Definition Graph Algorithms Many problems in CS can be modeled as graph problems. Algorithms for solving graph problems are fundamental to the field of algorithm design. Definition A graph G = (V, E) consists of

More information

CSI 604 Elementary Graph Algorithms

CSI 604 Elementary Graph Algorithms CSI 604 Elementary Graph Algorithms Ref: Chapter 22 of the text by Cormen et al. (Second edition) 1 / 25 Graphs: Basic Definitions Undirected Graph G(V, E): V is set of nodes (or vertices) and E is the

More information

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 16. Graph Search Algorithms. Recall BFS

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 16. Graph Search Algorithms. Recall BFS Taking Stock IE170: Algorithms in Systems Engineering: Lecture 16 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University February 28, 2007 Last Time The Wonderful World of This

More information

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 17. Depth-First Search. DFS (Initialize and Go) Last Time Depth-First Search

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 17. Depth-First Search. DFS (Initialize and Go) Last Time Depth-First Search Taking Stock IE170: Algorithms in Systems Engineering: Lecture 17 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University March 2, 2007 Last Time Depth-First Search This Time:

More information

Outlines: Graphs Part-2

Outlines: Graphs Part-2 Elementary Graph Algorithms PART-2 1 Outlines: Graphs Part-2 Graph Search Methods Breadth-First Search (BFS): BFS Algorithm BFS Example BFS Time Complexity Output of BFS: Shortest Path Breath-First Tree

More information

Part VI Graph algorithms. Chapter 22 Elementary Graph Algorithms Chapter 23 Minimum Spanning Trees Chapter 24 Single-source Shortest Paths

Part VI Graph algorithms. Chapter 22 Elementary Graph Algorithms Chapter 23 Minimum Spanning Trees Chapter 24 Single-source Shortest Paths Part VI Graph algorithms Chapter 22 Elementary Graph Algorithms Chapter 23 Minimum Spanning Trees Chapter 24 Single-source Shortest Paths 1 Chapter 22 Elementary Graph Algorithms Representations of graphs

More information

Elementary Graph Algorithms

Elementary Graph Algorithms Elementary Graph Algorithms Representations Breadth-First Search Depth-First Search Topological Sort Strongly Connected Components CS 5633 Analysis of Algorithms Chapter 22: Slide 1 Graph Representations

More information

Graph Algorithms. Chapter 22. CPTR 430 Algorithms Graph Algorithms 1

Graph Algorithms. Chapter 22. CPTR 430 Algorithms Graph Algorithms 1 Graph Algorithms Chapter 22 CPTR 430 Algorithms Graph Algorithms Why Study Graph Algorithms? Mathematical graphs seem to be relatively specialized and abstract Why spend so much time and effort on algorithms

More information

Computer Science & Engineering 423/823 Design and Analysis of Algorithms

Computer Science & Engineering 423/823 Design and Analysis of Algorithms s of s Computer Science & Engineering 423/823 Design and Analysis of Lecture 03 (Chapter 22) Stephen Scott (Adapted from Vinodchandran N. Variyam) 1 / 29 Spring 2010 s of s s are abstract data types that

More information

Graph implementations :

Graph implementations : Graphs Graph implementations : The two standard ways of representing a graph G = (V, E) are adjacency-matrices and collections of adjacencylists. The adjacency-lists are ideal for sparse trees those where

More information

Graphs. Graphs. Representation of Graphs. CSE 680 Prof. Roger Crawfis. Two standard ways. Graph G = (V, E)» V = set of vertices

Graphs. Graphs. Representation of Graphs. CSE 680 Prof. Roger Crawfis. Two standard ways. Graph G = (V, E)» V = set of vertices Introduction to Algorithms Graph Algorithms CSE 680 Prof. Roger Crawfis Partially from io.uwinnipeg.ca/~ychen2 Graphs Graph G = (V, E)» V = set of vertices» E = set of edges (V V) V) Types of graphs» Undirected:

More information

Week 5. 1 Analysing BFS. 2 Depth-first search. 3 Analysing DFS. 4 Dags and topological sorting. 5 Detecting cycles. CS 270 Algorithms.

Week 5. 1 Analysing BFS. 2 Depth-first search. 3 Analysing DFS. 4 Dags and topological sorting. 5 Detecting cycles. CS 270 Algorithms. 1 2 Week 5 3 4 5 General remarks We finish, by analysing it. Then we consider the second main graph- algorithm, depth-first (). And we consider one application of, of graphs. Reading from CLRS for week

More information

Chapter 22 Elementary Graph Algorithms

Chapter 22 Elementary Graph Algorithms Chapter 22 Elementary Graph Algorithms Graph Representations Graph G = (V,E) Directed Undirected Adjacency Lists Adjacency Matrix Graph Representations Adjacency List: Undirected Memory: Adjacency: Graph

More information

Review: Graph Theory and Representation

Review: Graph Theory and Representation Review: Graph Theory and Representation Graph Algorithms Graphs and Theorems about Graphs Graph implementation Graph Algorithms Shortest paths Minimum spanning tree What can graphs model? Cost of wiring

More information

Unit 2: Algorithmic Graph Theory

Unit 2: Algorithmic Graph Theory Unit 2: Algorithmic Graph Theory Course contents: Introduction to graph theory Basic graph algorithms Reading Chapter 3 Reference: Cormen, Leiserson, and Rivest, Introduction to Algorithms, 2 nd Ed., McGraw

More information

Data Structures and Algorithms. Chapter 7. Graphs

Data Structures and Algorithms. Chapter 7. Graphs 1 Data Structures and Algorithms Chapter 7 Werner Nutt 2 Acknowledgments The course follows the book Introduction to Algorithms, by Cormen, Leiserson, Rivest and Stein, MIT Press [CLRST]. Many examples

More information

Graph Algorithms. Andreas Klappenecker. [based on slides by Prof. Welch]

Graph Algorithms. Andreas Klappenecker. [based on slides by Prof. Welch] Graph Algorithms Andreas Klappenecker [based on slides by Prof. Welch] 1 Directed Graphs Let V be a finite set and E a binary relation on V, that is, E VxV. Then the pair G=(V,E) is called a directed graph.

More information

Data Structures and Algorithms. Werner Nutt

Data Structures and Algorithms. Werner Nutt Data Structures and Algorithms Werner Nutt nutt@inf.unibz.it http://www.inf.unibz/it/~nutt Part 9 Academic Year 2011-2012 1 Acknowledgements & Copyright Notice These slides are built on top of slides developed

More information

CS 270 Algorithms. Oliver Kullmann. Analysing BFS. Depth-first search. Analysing DFS. Dags and topological sorting.

CS 270 Algorithms. Oliver Kullmann. Analysing BFS. Depth-first search. Analysing DFS. Dags and topological sorting. General remarks Week 5 2 We finish, by analysing it. Then we consider the second main graph- algorithm, depth-first (). And we consider one application of, of graphs. Reading from CLRS for week 5 Chapter

More information

Proof: if not f[u] < d[v], then u still grey while v is being visited. DFS visit(v) will then terminate before DFS visit(u).

Proof: if not f[u] < d[v], then u still grey while v is being visited. DFS visit(v) will then terminate before DFS visit(u). Parenthesis property of DFS discovery and finishing times (Thm 23.6 of CLR): For any two nodes u,v of a directed graph, if d[u] < d[v] (i.e. u discovered before v), either f[v] < f[u] (i.e. visit time

More information

W4231: Analysis of Algorithms

W4231: Analysis of Algorithms W4231: Analysis of Algorithms 10/21/1999 Definitions for graphs Breadth First Search and Depth First Search Topological Sort. Graphs AgraphG is given by a set of vertices V and a set of edges E. Normally

More information

CS 270 Algorithms. Oliver Kullmann. Breadth-first search. Analysing BFS. Depth-first. search. Analysing DFS. Dags and topological sorting.

CS 270 Algorithms. Oliver Kullmann. Breadth-first search. Analysing BFS. Depth-first. search. Analysing DFS. Dags and topological sorting. Week 5 General remarks and 2 We consider the simplest graph- algorithm, breadth-first (). We apply to compute shortest paths. Then we consider the second main graph- algorithm, depth-first (). And we consider

More information

Practical Session No. 12 Graphs, BFS, DFS, Topological sort

Practical Session No. 12 Graphs, BFS, DFS, Topological sort Practical Session No. 12 Graphs, BFS, DFS, Topological sort Graphs and BFS Graph G = (V, E) Graph Representations (V G ) v1 v n V(G) = V - Set of all vertices in G E(G) = E - Set of all edges (u,v) in

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 7 Greedy Graph Algorithms Topological sort Shortest paths Adam Smith The (Algorithm) Design Process 1. Work out the answer for some examples. Look for a general principle

More information

Trees and Graphs Shabsi Walfish NYU - Fundamental Algorithms Summer 2006

Trees and Graphs Shabsi Walfish NYU - Fundamental Algorithms Summer 2006 Trees and Graphs Basic Definitions Tree: Any connected, acyclic graph G = (V,E) E = V -1 n-ary Tree: Tree s/t all vertices of degree n+1 A root has degree n Binary Search Tree: A binary tree such that

More information

Practical Session No. 12 Graphs, BFS, DFS Topological Sort

Practical Session No. 12 Graphs, BFS, DFS Topological Sort Practical Session No. 12 Graphs, BFS, DFS Topological Sort Graphs and BFS Graph G = (V, E) Graph Representations (VG ) v1 v n V(G) = V - Set of all vertices in G E(G) = E - Set of all edges (u,v) in G,

More information

CS473-Algorithms I. Lecture 14-A. Graph Searching: Breadth-First Search. Cevdet Aykanat - Bilkent University Computer Engineering Department

CS473-Algorithms I. Lecture 14-A. Graph Searching: Breadth-First Search. Cevdet Aykanat - Bilkent University Computer Engineering Department CS473-Algorithms I Lecture 14-A Graph Searching: Breadth-First Search 1 Graph Searching: Breadth-First Search Graph G =(V, E), directed or undirected with adjacency list repres. GOAL: Systematically explores

More information

Figure 1: A directed graph.

Figure 1: A directed graph. 1 Graphs A graph is a data structure that expresses relationships between objects. The objects are called nodes and the relationships are called edges. For example, social networks can be represented as

More information

CS 341: Algorithms. Douglas R. Stinson. David R. Cheriton School of Computer Science University of Waterloo. February 26, 2019

CS 341: Algorithms. Douglas R. Stinson. David R. Cheriton School of Computer Science University of Waterloo. February 26, 2019 CS 341: Algorithms Douglas R. Stinson David R. Cheriton School of Computer Science University of Waterloo February 26, 2019 D.R. Stinson (SCS) CS 341 February 26, 2019 1 / 296 1 Course Information 2 Introduction

More information

Strongly Connected Components

Strongly Connected Components Strongly Connected Components Let G = (V, E) be a directed graph Write if there is a path from to in G Write if and is an equivalence relation: implies and implies s equivalence classes are called the

More information

Announcements. HW3 is graded. Average is 81%

Announcements. HW3 is graded. Average is 81% CSC263 Week 9 Announcements HW3 is graded. Average is 81% Announcements Problem Set 4 is due this Tuesday! Due Tuesday (Nov 17) Recap The Graph ADT definition and data structures BFS gives us single-source

More information

CSCE 750, Fall 2002 Notes 6 Page Graph Problems ffl explore all nodes (breadth first and depth first) ffl find the shortest path from a given s

CSCE 750, Fall 2002 Notes 6 Page Graph Problems ffl explore all nodes (breadth first and depth first) ffl find the shortest path from a given s CSCE 750, Fall 2002 Notes 6 Page 1 10 Graph Algorithms (These notes follow the development in Cormen, Leiserson, and Rivest.) 10.1 Definitions ffl graph, directed graph (digraph), nodes, edges, subgraph

More information

CS Elementary Graph Algorithms

CS Elementary Graph Algorithms CS43-09 Elementary Graph Algorithms Outline Representation of Graphs Instructor: Fei Li Room 443 ST II Office hours: Tue. & Thur. 1:30pm - 2:30pm or by appointments lifei@cs.gmu.edu with subject: CS43

More information

CS Elementary Graph Algorithms

CS Elementary Graph Algorithms CS483-09 Elementary Graph Algorithms Instructor: Fei Li Room 443 ST II Office hours: Tue. & Thur. 1:30pm - 2:30pm or by appointments lifei@cs.gmu.edu with subject: CS483 http://www.cs.gmu.edu/ lifei/teaching/cs483_fall07/

More information

Tutorial. Question There are no forward edges. 4. For each back edge u, v, we have 0 d[v] d[u].

Tutorial. Question There are no forward edges. 4. For each back edge u, v, we have 0 d[v] d[u]. Tutorial Question 1 A depth-first forest classifies the edges of a graph into tree, back, forward, and cross edges. A breadth-first tree can also be used to classify the edges reachable from the source

More information

Unit 5F: Layout Compaction

Unit 5F: Layout Compaction Course contents Unit 5F: Layout Compaction Design rules Symbolic layout Constraint-graph compaction Readings: Chapter 6 Unit 5F 1 Design rules: restrictions on the mask patterns to increase the probability

More information

Unit 3: Layout Compaction

Unit 3: Layout Compaction Unit 3: Layout Compaction Course contents Design rules Symbolic layout Constraint-graph compaction Readings: Chapter 6 Unit 3 1 Design rules: restrictions on the mask patterns to increase the probability

More information

22.3 Depth First Search

22.3 Depth First Search 22.3 Depth First Search Depth-First Search(DFS) always visits a neighbour of the most recently visited vertex with an unvisited neighbour. This means the search moves forward when possible, and only backtracks

More information

Graph Theory. Many problems are mapped to graphs. Problems. traffic VLSI circuits social network communication networks web pages relationship

Graph Theory. Many problems are mapped to graphs. Problems. traffic VLSI circuits social network communication networks web pages relationship Graph Graph Usage I want to visit all the known famous places starting from Seoul ending in Seoul Knowledge: distances, costs Find the optimal(distance or cost) path Graph Theory Many problems are mapped

More information

Graphs. CSE 2320 Algorithms and Data Structures Alexandra Stefan and Vassilis Athitsos University of Texas at Arlington

Graphs. CSE 2320 Algorithms and Data Structures Alexandra Stefan and Vassilis Athitsos University of Texas at Arlington Graphs CSE 2320 Algorithms and Data Structures Alexandra Stefan and Vassilis Athitsos University of Texas at Arlington 1 Representation Adjacency matrix??adjacency lists?? Review Graphs (from CSE 2315)

More information

Chapter 22: Elementary Graph Algorithms. Definitions:

Chapter 22: Elementary Graph Algorithms. Definitions: Chapter 22: Elementary Graph Algorithms. Definitions: 1. G = (V, E), where V is a set of points and E is a set of edges connecting point-pairs from V. 2. We use V synonymously with V and E with E when

More information

CSE 2331/5331. Topic 9: Basic Graph Alg. Representations Basic traversal algorithms Topological sort CSE 2331/5331

CSE 2331/5331. Topic 9: Basic Graph Alg. Representations Basic traversal algorithms Topological sort CSE 2331/5331 Topic 9: Basic Graph Alg. Representations Basic traversal algorithms Topological sort What Is A Graph Graph G = (V, E) V: set of nodes E: set of edges a b c Example: d e f V ={ a, b, c, d, e, f } E ={(a,

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 5 Graphs Applications of DFS Topological sort Strongly connected components Sofya Raskhodnikova S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith,

More information

CS 161 Lecture 11 BFS, Dijkstra s algorithm Jessica Su (some parts copied from CLRS) 1 Review

CS 161 Lecture 11 BFS, Dijkstra s algorithm Jessica Su (some parts copied from CLRS) 1 Review 1 Review 1 Something I did not emphasize enough last time is that during the execution of depth-firstsearch, we construct depth-first-search trees. One graph may have multiple depth-firstsearch trees,

More information

Scribes: Romil Verma, Juliana Cook (2015), Virginia Williams, Date: May 1, 2017 and Seth Hildick-Smith (2016), G. Valiant (2017), M.

Scribes: Romil Verma, Juliana Cook (2015), Virginia Williams, Date: May 1, 2017 and Seth Hildick-Smith (2016), G. Valiant (2017), M. Lecture 9 Graphs Scribes: Romil Verma, Juliana Cook (2015), Virginia Williams, Date: May 1, 2017 and Seth Hildick-Smith (2016), G. Valiant (2017), M. Wootters (2017) 1 Graphs A graph is a set of vertices

More information

Taking Stock. Last Time Flows. This Time Review! 1 Characterize the structure of an optimal solution

Taking Stock. Last Time Flows. This Time Review! 1 Characterize the structure of an optimal solution Taking Stock IE170: Algorithms in Systems Engineering: Lecture 26 Jeff Linderoth Last Time Department of Industrial and Systems Engineering Lehigh University April 2, 2007 This Time Review! Jeff Linderoth

More information

Slides credited from Hsueh-I Lu, Hsu-Chun Hsiao, & Michael Tsai

Slides credited from Hsueh-I Lu, Hsu-Chun Hsiao, & Michael Tsai Slides credited from Hsueh-I Lu, Hsu-Chun Hsiao, & Michael Tsai Mini-HW 7 released Due on 11/30 (Thur) 17:20 Homework 3 released tonight Due on 12/14 (Thur) 17:20 (three weeks) Class change!! Start from

More information

CS583 Lecture 09. Jana Kosecka. Graph Algorithms Topological Sort Strongly Connected Component Minimum Spanning Tree

CS583 Lecture 09. Jana Kosecka. Graph Algorithms Topological Sort Strongly Connected Component Minimum Spanning Tree CS3 Lecture 0 Jana Kosecka Graph Algorithms Topological Sort Strongly Connected Component Minimum Spanning Tree Many slides here are based on E. Demaine, D. Luebke, Kleinberg-Tardos slides Graph Algs.

More information

22.1 Representations of graphs

22.1 Representations of graphs 22.1 Representations of graphs There are two standard ways to represent a (directed or undirected) graph G = (V,E), where V is the set of vertices (or nodes) and E is the set of edges (or links). Adjacency

More information

Undirected Graphs. DSA - lecture 6 - T.U.Cluj-Napoca - M. Joldos 1

Undirected Graphs. DSA - lecture 6 - T.U.Cluj-Napoca - M. Joldos 1 Undirected Graphs Terminology. Free Trees. Representations. Minimum Spanning Trees (algorithms: Prim, Kruskal). Graph Traversals (dfs, bfs). Articulation points & Biconnected Components. Graph Matching

More information

Topic 12: Elementary Graph Algorithms

Topic 12: Elementary Graph Algorithms Topic 12: Elementary Graph Algorithms Pierre Flener Lars-enrik Eriksson (version of 2013-02-10) Different kinds of graphs List Tree A B C A B C Directed Acyclic Graph (DAG) D A B C D E Directed Graph (Digraph)

More information

CS 220: Discrete Structures and their Applications. graphs zybooks chapter 10

CS 220: Discrete Structures and their Applications. graphs zybooks chapter 10 CS 220: Discrete Structures and their Applications graphs zybooks chapter 10 directed graphs A collection of vertices and directed edges What can this represent? undirected graphs A collection of vertices

More information

Graphs. Part I: Basic algorithms. Laura Toma Algorithms (csci2200), Bowdoin College

Graphs. Part I: Basic algorithms. Laura Toma Algorithms (csci2200), Bowdoin College Laura Toma Algorithms (csci2200), Bowdoin College Undirected graphs Concepts: connectivity, connected components paths (undirected) cycles Basic problems, given undirected graph G: is G connected how many

More information

Lecture 10: Strongly Connected Components, Biconnected Graphs

Lecture 10: Strongly Connected Components, Biconnected Graphs 15-750: Graduate Algorithms February 8, 2016 Lecture 10: Strongly Connected Components, Biconnected Graphs Lecturer: David Witmer Scribe: Zhong Zhou 1 DFS Continued We have introduced Depth-First Search

More information

CS 310 Advanced Data Structures and Algorithms

CS 310 Advanced Data Structures and Algorithms CS 31 Advanced Data Structures and Algorithms Graphs July 18, 17 Tong Wang UMass Boston CS 31 July 18, 17 1 / 4 Graph Definitions Graph a mathematical construction that describes objects and relations

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 4 Graphs Definitions Traversals Adam Smith 9/8/10 Exercise How can you simulate an array with two unbounded stacks and a small amount of memory? (Hint: think of a

More information

csci 210: Data Structures Graph Traversals

csci 210: Data Structures Graph Traversals csci 210: Data Structures Graph Traversals Graph traversal (BFS and DFS) G can be undirected or directed We think about coloring each vertex WHITE before we start GRAY after we visit a vertex but before

More information

Graph Representations and Traversal

Graph Representations and Traversal COMPSCI 330: Design and Analysis of Algorithms 02/08/2017-02/20/2017 Graph Representations and Traversal Lecturer: Debmalya Panigrahi Scribe: Tianqi Song, Fred Zhang, Tianyu Wang 1 Overview This lecture

More information

Sample Solutions to Homework #4

Sample Solutions to Homework #4 National Taiwan University Handout #25 Department of Electrical Engineering January 02, 207 Algorithms, Fall 206 TA: Zhi-Wen Lin and Yen-Chun Liu Sample Solutions to Homework #4. (0) (a) Both of the answers

More information

CS473-Algorithms I. Lecture 13-A. Graphs. Cevdet Aykanat - Bilkent University Computer Engineering Department

CS473-Algorithms I. Lecture 13-A. Graphs. Cevdet Aykanat - Bilkent University Computer Engineering Department CS473-Algorithms I Lecture 3-A Graphs Graphs A directed graph (or digraph) G is a pair (V, E), where V is a finite set, and E is a binary relation on V The set V: Vertex set of G The set E: Edge set of

More information

Graph Traversal CSCI Algorithms I. Andrew Rosenberg

Graph Traversal CSCI Algorithms I. Andrew Rosenberg Graph Traversal CSCI 700 - Algorithms I Andrew Rosenberg Last Time Introduced Graphs Today Traversing a Graph A shortest path algorithm Example Graph We will use this graph as an example throughout today

More information

Lecture 3: Graphs and flows

Lecture 3: Graphs and flows Chapter 3 Lecture 3: Graphs and flows Graphs: a useful combinatorial structure. Definitions: graph, directed and undirected graph, edge as ordered pair, path, cycle, connected graph, strongly connected

More information

Jana Kosecka. Red-Black Trees Graph Algorithms. Many slides here are based on E. Demaine, D. Luebke slides

Jana Kosecka. Red-Black Trees Graph Algorithms. Many slides here are based on E. Demaine, D. Luebke slides Jana Kosecka Red-Black Trees Graph Algorithms Many slides here are based on E. Demaine, D. Luebke slides Binary Search Trees (BSTs) are an important data structure for dynamic sets In addition to satellite

More information

Graph Algorithms Using Depth First Search

Graph Algorithms Using Depth First Search Graph Algorithms Using Depth First Search Analysis of Algorithms Week 8, Lecture 1 Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Graph Algorithms Using Depth

More information

1 Start with each vertex being its own component. 2 Merge two components into one by choosing the light edge

1 Start with each vertex being its own component. 2 Merge two components into one by choosing the light edge Taking Stock IE170: in Systems Engineering: Lecture 19 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University March 16, 2007 Last Time Minimum This Time More Strongly Connected

More information

Undirected Graphs. V = { 1, 2, 3, 4, 5, 6, 7, 8 } E = { 1-2, 1-3, 2-3, 2-4, 2-5, 3-5, 3-7, 3-8, 4-5, 5-6 } n = 8 m = 11

Undirected Graphs. V = { 1, 2, 3, 4, 5, 6, 7, 8 } E = { 1-2, 1-3, 2-3, 2-4, 2-5, 3-5, 3-7, 3-8, 4-5, 5-6 } n = 8 m = 11 Chapter 3 - Graphs Undirected Graphs Undirected graph. G = (V, E) V = nodes. E = edges between pairs of nodes. Captures pairwise relationship between objects. Graph size parameters: n = V, m = E. V = {

More information

Unweighted directed graphs

Unweighted directed graphs Unweighted directed graphs Announcements Midterm & gradescope - will get an email today to register (username name is your email) - tests should appear next Tuesday (nothing there now) Graph A directed

More information

Finding Strongly Connected Components

Finding Strongly Connected Components Yufei Tao ITEE University of Queensland We just can t get enough of the beautiful algorithm of DFS! In this lecture, we will use it to solve a problem finding strongly connected components that seems to

More information

Copyright 2000, Kevin Wayne 1

Copyright 2000, Kevin Wayne 1 Chapter 3 - Graphs Undirected Graphs Undirected graph. G = (V, E) V = nodes. E = edges between pairs of nodes. Captures pairwise relationship between objects. Graph size parameters: n = V, m = E. Directed

More information

Suggested Study Strategy

Suggested Study Strategy Final Exam Thursday, 7 August 2014,19:00 22:00 Closed Book Will cover whole course, with emphasis on material after midterm (hash tables, binary search trees, sorting, graphs) Suggested Study Strategy

More information

Homework Assignment #3 Graph

Homework Assignment #3 Graph CISC 4080 Computer Algorithms Spring, 2019 Homework Assignment #3 Graph Some of the problems are adapted from problems in the book Introduction to Algorithms by Cormen, Leiserson and Rivest, and some are

More information

Graph. Vertex. edge. Directed Graph. Undirected Graph

Graph. Vertex. edge. Directed Graph. Undirected Graph Module : Graphs Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS E-mail: natarajan.meghanathan@jsums.edu Graph Graph is a data structure that is a collection

More information

Analysis of Algorithms Prof. Karen Daniels

Analysis of Algorithms Prof. Karen Daniels UMass Lowell omputer Science 91.404 nalysis of lgorithms Prof. Karen aniels Spring, 2013 hapter 22: raph lgorithms & rief Introduction to Shortest Paths [Source: ormen et al. textbook except where noted]

More information

Shortest Path Routing Communications networks as graphs Graph terminology Breadth-first search in a graph Properties of breadth-first search

Shortest Path Routing Communications networks as graphs Graph terminology Breadth-first search in a graph Properties of breadth-first search Shortest Path Routing Communications networks as graphs Graph terminology Breadth-first search in a graph Properties of breadth-first search 6.082 Fall 2006 Shortest Path Routing, Slide 1 Routing in an

More information

Final Exam. EECS 2011 Prof. J. Elder - 1 -

Final Exam. EECS 2011 Prof. J. Elder - 1 - Final Exam Ø Wed Apr 11 2pm 5pm Aviva Tennis Centre Ø Closed Book Ø Format similar to midterm Ø Will cover whole course, with emphasis on material after midterm (maps and hash tables, binary search, loop

More information

CSE 331: Introduction to Algorithm Analysis and Design Graphs

CSE 331: Introduction to Algorithm Analysis and Design Graphs CSE 331: Introduction to Algorithm Analysis and Design Graphs 1 Graph Definitions Graph: A graph consists of a set of verticies V and a set of edges E such that: G = (V, E) V = {v 0, v 1,..., v n 1 } E

More information