Chapter 6. GRAPHS. Figure 6.1 : The bridges of Koenigsberg
|
|
- Noel Strickland
- 6 years ago
- Views:
Transcription
1 Chap : Graphs (Page ) Chapter. GRAPHS. THE GRAPH ABSTRACT DATA TYPE. ELEMENTARY GRAPH OPERATIONS. MINIMUM COST SPANNING TREES. SHORTEST PATHS AND TRANSITIVE CLOSURE. ACTIVITY NETWORKS Chap : Graphs (Page ) take bridge g to C take bridge d to A take bridge b to B take bridge f to D c C d g C c d e g A Kneiphof e D A D a b f B B f a b (a) (b) Figure. : The bridges of Koenigsberg
2 Chap : Graphs (Page ). The Graph Abstract Data Type A graph, G, consists of two sets: a finite, nonempty set of vertices, and a finite, possibly empty set of edges. V(G) and E(G) represent the sets of vertices and edges of G, respectively. Alternately, we may write G = (V, E) to represent a graph. Undirected graph is one in which the pair of vertices representing any edge is unordered. (v, v ), (v, v ) represent the same edge. Directed graph is one in which we represent each edge as a directed pair of vertices. <v, v > represents an edge in which v is the tail and v is the head. Chap : Graphs (Page ) Sample Graphs G G G V(G ) = {,,, } E(G ) = {(,), (,), (,), (,), (,), (,)} V(G ) = {,,,,,, } E(G ) = {(,), (,), (,), (,), (,), (,)} V(G ) = {,, } E(G ) = {<,>, <,>, <,>}
3 Chap : Graphs (Page ) Restriction on Graphs. A graph may not have an edge from a vertex, i, back to itself. self loops.. A graph may not have multiple occurrences of the same edge. if we allow, multigraph. Chap : Graphs (Page ) Definitions complete graph graph that has the maximum number of edges. adjacent, incident if (v, v ) is an edge in an undirected graph, then the vertices v and v are adjacent and the edge (v, v ) is incident on vertices v and v <v, v >: v is adjacent to v, while v is adjacent from v subgraph (Figure.) a subgraph of G is a graph G such that V(G ) Í V(G) and E(G ) Í E(G) path a path from vertex v p to vertex v q in a graph, G, is a sequence of vertices, v p, v i, v i,..., v in, v q such that (v p, v i ), (v i, vi ),..., (v in, v q ) are edges in an undirected graph.
4 Chap : Graphs (Page ) The length of a path is the number of edges on it. Simple (directed) path : path in which all vertices, except possibly the first and the last, are distinct. Cycle : simple path in which the first and the last vertices are the same. (Strongly) Connected In an undirected graph G, two vertices, v and v, are connected if there is a path in G from v to v. (Strongly) Connected Component : maximal connected subgraph Tree : graph that is connected and acyclic (it has no cycles). The degree of a vertex is the number of edges incident to the vertex. in-degree & out-degree digraph Chap : Graphs (Page 8) Graph Representations Adjacency Matrix The adjacency matrix of G is a two-dimensional n n array, say adj_mat. If the edge (v i, v j ) (<v i, v j > for a digraph) is in E(G), adj_mat[i][j] =. If there is no edge in E(G), adj_mat[i][j] =. ex) Undirected Graph: Symmetric Matrix
5 Chap : Graphs (Page 9) Adjacency Lists Replace the n rows of the adjacency matrix with n linked lists, one for each vertex in G. ex) headnodes vertex link null null null null null null null Chap : Graphs (Page ) Adjacency Multilists maintaining the lists as multilists, that is, lists in which nodes are shared among several lists, facilitates this operation. marked vertex vertex path path ex) headnodes The lists are: vertex : N -> N -> N vertex : N -> N -> N vertex : N -> N -> N vertex : N -> N -> N N N N N N N N null N N N N N null N N null null edge(, ) edge(, ) edge(, ) edge(, ) edge(, ) edge(, )
6 Chap : Graphs (Page ) Analysis of Graph Representations How many edges are there in G? or Is G connected? Adjacency Matrix: O(n ) time to search (n -n)/ Adjacency List: O(e+n) Good if e << n / (sparse graphs) Finding in-degree of a vertex in a digraph Adjacency Matrx: O(n) Adjacency List: O(e+n) maintaining two lists (original adjacency list & inverse adjacency list) using alternate node structure for adjacency list (Figure.) tail head column link for head row link for tail Chap : Graphs (Page ). Elementary Graph Operations. Depth First Search. Breadth First Search. Connected Components. Spanning Trees. Biconnected Components and Articulation Points
7 Chap : Graphs (Page ) Depth First Search Algorithm. begin the search by visiting the start vertex, v.. select an unvisited vertex, w, from v s adjacency list and carry out a depth first search on w. (using recursion) #define FALSE #define TRUE short int visited[max_vertices]; void dfs(int v) { node_pointer w; visited[v] = TRUE; printf( d, v); for (w = graph[v]; w; w = w->link) if (!visited[w->vertex]) dfs(w->vertex); } Chap : Graphs (Page ) ex) V V V V V V V V null null null null null null null null depth first search order : v, v, v, v, v, v, v, v
8 Chap : Graphs (Page ) Breadth First Search Algorithm. starts at vertex v and marks it as visited.. visits each of the vertices on v s adjacency list.. when we have visited all the vertices on v s adjacency list, we visit all the unvisited vertices that are adjacent to the first vertex on v s adjacency list (using queue). typedef struct queue *queue_pointer; typedef struct queue { int vertex; queue_pointer link; }; void addq(queue_pointer *, queue_pointer *, int); int deleteq(queue_pointer *); Chap : Graphs (Page ) void bfs(int v) { /* breadth first traversal of a graph, starting with node v the global array visited is initialized to, the queue */ node_pointer w; queue_pointer front =, rear = ; printf( %d, v); visited[v] = TRUE; addq(&front, &rear, v); while (front) { v = deleteq(&front); for (w = graph[v]; w; w = w->link) if (!visited[w->vertex]) { printf( %d, w->vertex); addq(&front,&rear,w->vertex); visited[w->vertex] = TRUE; } } }
9 Chap : Graphs (Page ) Connected Components whether or not an undirected graph is connected? calling either dfs() or bfs() and then determining if there are any unvisited vertices. listing the connected components of a graph. void connected (void) { /* determine the connected components of a graph */ int i for (i = ; i < n; i++) if (!visited[i]) { dfs(i); printf( n ); } } Chap : Graphs (Page 8) Spanning Trees A spanning tree is any tree that consists solely of edges in G and that includes all vertices in G. use either dfs or bfs to create a spanning tree. depth first spanning tree breadth first spanning tree V V V V V V V V V V V V V V V depth first spanning tree V breadth first spanning tree
10 Chap : Graphs (Page 9) Biconnected Components and Articulation Points Definition An articulation point is a vertex v of G such that the deletion of v, together with all edges incident on v, produces a graph, G that has at least two connected components. A biconnected graph is a connected graph that has no articulation points. A biconnected component of a connected undirected graph is a maximal biconnected subgraph, H, of G. The maximal biconnected subgraph means that G contains no other subgraph that is both biconnected and properly contains H. Chap : Graphs (Page ) ex) (a) Connected graph (b) Biconnected components Articulation point :,,,
11 Chap : Graphs (Page ) Finding Articulation Point Two Rules Root of a DFS tree is an articulation point iff it has at least two children. Any other vertex u is an articulation point iff it has at least one child w such that we cannot reach an ancestor of u using a path that consists of only w, descendants of w, and a single back edge (a) depth first spanning tree (b) Chap : Graphs (Page ) Minimum Cost Spanning Trees Definition cost of a spanning tree of a weighted undirected graph : the sum of the costs (weights) of the edges in the spanning tree Minimum cost spanning tree : a spanning tree of least cost Three algorithms for minimum cost spanning tree Kruskal s, Prim s, Sollin s algorithms All three use an greedy method. Constraints for minimum cost spanning tree algorithms. must use only edges within the graph.. must use exactly n- edges.. may not use edges that would produce a cycle.
12 Chap : Graphs (Page ) Kruskal s Algorithm Methods Builds a minimum cost tree T by adding edges to T one at a time. Selects the edges for inclusion in T in non-decreasing order of their cost. An edge is added in T if it does not form a cycle. Graph G is connected and has n > vertices, exactly n - edges will be selected Chap : Graphs (Page ) Kruskal s Algorithm (Cont d) T = {}; while ( T contains less than n- edges && E is not empty ) { choose a least cost edge (v,w) form E; delete (v,w) form E; if ((v,w) does not create a cycle in T) add (v,w) to T; else discard(v,w); } if ( T contains fewer than n- edges ) printf( No spanning tree\n );
13 Chap : Graphs (Page ) (Ex) Kruskal s Algorithm 8 8 (a) (b) (c) (d) (e) (f) Chap : Graphs (Page ) Discussion of Kruskal s Algorithm determine an edge with minimum cost edge maintain the edges in E as a sorted sequential : O(e log e) better method : use min heap finding the next cost edge : O(log e) construction of heap : O(e) Cycle checking use union-find operation Analysis union-find operations require less than choosing and deleting an edge, the latter operations determine the total computing time Total Computing Time : O(e log e)
14 Chap : Graphs (Page ) Theorem.: Let G be an undirected connected graph. Kruskal s algorithm generates a minimum cost spanning tree. proof) We shall show that a) Kruskal s method produces a spanning tree whenever a spanning tree exists. b) The spanning tree generated is of minimum cost. Chap : Graphs (Page 8) Prim s Algorithm Method: Complexity = O(n ) Constructs the minimum cost spanning tree one edge at a time. At each stage, the set of selected edges forms a tree. Begins with a tree, T, that contains a single vertex. Add a least cost edge (u,v) to T such that T {(u,v)} is also a tree.
15 Chap : Graphs (Page 9) Prim s Algorithm (Cont d) T = {}; TV = {}; /* start with vertex and no edges */ while ( T contains fewer than n- edges ) { let (u,v) be a least cost edge such that u TV and v TV; if (there is no such edge) break; add v to TV; add (u,v) to T; } if ( T contains fewer than n- edges ) printf( No spanning tree\n ); Chap : Graphs (Page ) (Ex) Prim s Algorithm 8 8 (a) (b) (c) (d) (e) (f)
16 Chap : Graphs (Page ) Sollin s Algorithm Methods Aelects several edges for inclusion in T at each stage. At the start of the stage, the selected edges, together with all n graph vertices, form a spanning forest. During a stage, select one edge for each tree in the forest. Since two trees in the forest could select the same edge, need to eliminate multiple copies of edges. At start of the first stage the set of selected edges is empty. Terminates when there is only tree at the end of a stage or no edges remain for selection. Chap : Graphs (Page ) (Ex) Sollin s Algorithm 8 8 (a) (b) (c) (d)
17 Chap : Graphs (Page ). Shortest paths and Transitive closure Problem. Is there a path from A to B?. If there is more than one path from A to B, which path is the shortest? Assume The length of a path is the sum of the weights of the edges on that path rather than the number of edges on the path. Since one-way streets are possible, the graphs are directed. Assume that all weights are positive. Chap : Graphs (Page ) Single Source All Destinations Problem ex) a directed graph, G = (V, E), a weighting function, w(e), w(e) >, for the edges of G, and a source vertex, v. Determine a shortest path from v to each of the remaining vertices of G. V V V V V V path length v v v v v v v v v v v
18 Chap : Graphs (Page ) Greedy algorithm Notation S : the set of vertices, including v, whose shortest paths have been found. For w not in S, let distance[w] be the length of the shortest path starting from v, going through vertices only in S, and ending in w. Observations. If the next shortest path is to vertex u, then the path from v to u goes through only those vertices that are in S.. Vertex u is chosen so that it has the minimum distance, distance[u], among all the vertices not in S. (from the definition of distance and observation.). Once we have selected u and generated the shortest path from v to u, u becomes a member of S. Adding u to S can change the distance[w](w S). If the distance changes, the length of the shorter path is distance[u] + length(<u,w>). Chap : Graphs (Page ) Dijkstra s algorithm Implement Dijkstra s algorithm Assume that the n vertices are numbered from to n- Maintain the set S as an array, found, with found[i] = FALSE if vertex i is not in S and found[i] = TRUE if vertex i is in S. Represent the graph by its cost adjacency matrix, with cost[i][j] being the weight of edge <i, j> If the edge <i, j> is not in G, we set cost[i][j] to some large number the number must be larger than any of the values in the cost matrix. the number must be chosen so that the statement distance[u] + cost[u][w] does not produce an overflow into the sign bit.
19 Chap : Graphs (Page ) #define MAX_VERTICES int cost[][max_vertices] = {{,,,,, }, {,,,,, }, {,,,,, }, {,,,,, }, {,,,,, }, {,,,,, }}; int distance[max_vertices], n = MAX_VERTICES; short int found[max_vertices]; int choose(int distance[], int n, short int found[]) { /* find the smallest distance not yet checked */ int i, min, minpos; min = INT_MAX; minpos = -; for (i = ; i < n; i++) if (distance[i] < min &&!found[i]) { min = distance[i]; minpos = i; } return minpos; } Chap : Graphs (Page 8) void shortestpath(int v, int cost[][max_vertices], int distance[], int n, short int found[]) { /* Implement Dijkstra s Algorithm */ int i, u, w; for (i = ; i < n; i++) { found[i] = FALSE; distance[i] = cost[v][i]; } Complexity = found[v] = TRUE; distance[v] = ; for (i = ; i < n - ; i++) { u = choose(distance, n, found); found[u] = TRUE; for (w = ; w < n; w++) if (!found[w]) if (distance[u] + cost[u][w] < distance[w]) distance[w] = distance[u] + cost[u][w]; } }
20 Chap : Graphs (Page 9) San Frnacisco Los Angeles 8 Denver Boston Chicago NewYork 9 (a) Digraph of hypothetical airline routes New Orleans Miami 8 9 Figure. : Digraph of airline routes (b) Cost adjacency matrix Chap : Graphs (Page ) Distance Iteration S Vertax selected LA [] SF [] DEN [] CHI [] BOST [] NY [] MIA [] NO [] Initial { } {,} {,,} + + {,,,} + {,,,,} {,,,,,} {,,,,,,} Figure. : Action of shortestpath on the digraph of Figure.
21 Chap : Graphs (Page ) All Pairs Shortest Paths Problem find the shortest paths between all pairs of vertices, v i, v j, i j. Solution. using shortestpath with each of the vertices in V(G) as the source : O(n ).. Dynamic programming method : O(n ) with a smaller constant factor. Chap : Graphs (Page ) Dynamic programming algorithm A k [i][j] : cost of the shortest path from i to j, using only those intermediate vertices with an index k. cost of the shortest path from i to j is A n- [i][j]. A - [i][j] = cost[i][j]. successively generate the matrices A, A, A,..., A n-. Calculate A k with A k-. the shortest path does not go through vertex k : A k [i][j] = A k- [i][j].. the shortest path does go through vertex k : A k [i][j] = A k- [i][k] + A k- [k][j]. A k [i][j] = min {A k- [i][j], A k [i][j] = A k- [i][k] + A k- [k][j] }, k. A - [i][j] = cost[i][j].
22 Chap : Graphs (Page ) void allcosts (int cost[ ] [MAX_VERTICES], int distance[] [MAX_VERTICES], int n) { /* determine the distance from each vertex to every other vertex, cost is the adjacency matrix, distance is the matrix of distances */ int i, j, k; for (i = ; i < n; i++) for (j = ; j < n; j++) distance[i][j] = cost[i][j]; for (k = ; k < n; k++) for (i = ; i < n; i++) for (j = ; j < n; j++) if (distance[i][k] + distance[k][j] < distance[i][j]) distance[i][j] = distance[i][k] + distance[k][j]; } Program. : All pairs, shortest paths function Chap : Graphs (Page ) A - A V V V A A Figure. : Matrix A k produced by allcosts for Figure.(a)
23 Chap : Graphs (Page ) Transitive Closure transitive closure matrix Denoted A +, of a directed graph, G, is a matrix such A + [i][j] = if there is a path of length > from i to j; otherwise, A + [i][j] =. reflexive transitive closure matrix Denoted A *, of a directed graph, G, is a matrix such that A * [i][j] = if there is a path of length from i to j; otherwise, A * [i][j] =. Program: Change allcosts distance[i][j] = distance[i][j] distance[i][k] && distance[k][j] Chap : Graphs (Page ) ex) transitive closure Digraph G Adjacent matrix A for G A + A *
24 Chap : Graphs (Page ). Activity Networks Activity Subproject (divide and conquer) The entire project is successfully completed when each of the activities is completed Two Networks Activity on Vertex (AOV) Networks Activity on Edge (AOE) Networks Chap : Graphs (Page 8) AOV Network Definitions: AOV Network: Digraph G (vertex = activities, edge = precedence relation) Predecessor (Successor): direct path from i to j Immediate Predecessor (Successor): <i, j> Partial Order: precedence relation that is both transitive and irreflexive Topological Order: linear ordering of vertices with precedence relation Problems How can we find out an algorithm that sorts the tasks into topological order? Topological Sort
25 Chap : Graphs (Page 9) Course number C C C C C C C C8 C9 C C C C C C Course name Programming I Discrete Mathematics Data Structures Calculus I Calculus II Linear Algebra Analysis of Algorithms Assembly Languages Operating Systems Programming Languages Compiler Design Artificial Intelligence Computational Theory Parallel Algorithms Numerical Analysis Prerequisites None None C, C None C C C, C C C, C8 C C C C C C (a) Courses needed for a computer science degree at a hypothetical university C C C C C C8 C C C C9 C C C (b) AOV network representing courses as vertices and edges as prerequisites Figure.8 : An AOV network C C Chap : Graphs (Page ) for ( i = ; i < n; i++) { if every vertex has a predecessor { fprintf (stderr, Network has a cycle.\n ); exit (); } pick a vertex v that has no predecessors; output v; delete v and all edges leading out of v from the network; } Program. : Topological sort
26 Chap : Graphs (Page ) V V V V V V V V V V V V V V V (a) initial (b) V (c) V V V V V V V (d) V (e) V (f) V (g) V Topological order generated : V, V, V, V, V, V Figure.9 : Simulation of Program. on an AOV network Chap : Graphs (Page ) Representation of AOV Network Determine if a vertex has any predecessors Keep a count of # of immediate predecessors for each vertex Delete a vertex and all of its incident edges Represent the network by its adjacency lists Declarations typedef struct node *node_pointer; typedef struct node { int vertex; node_pointer link; }; typedef struct { int count; node_pointer link; } hdnodes; hdnode graph[max_vertices]; v v v v v v count link Null Null Null Null Null Null
27 Chap : Graphs (Page ) void topsort(hdnodes graph[], int n) { int i, j, k, top; node_pointer ptr; /* PredecessorÈ Ž\ vertex stack ù */ top = -; for (i = ; i < n; i++) if (!graph[i].count) { graph[i].count = top; top = i; } for (i = ; i < n; i++) if (top == -) { fprintf(stderr, Network has a cycle.\n ); exit(); } else { j = top; /* Stack ä ä8 */ top = graph[top].count; printf( v%d,, j); for (ptr = graph[j].link; ptr; ptr = ptr->link) { /* Successor vertex count ØT */ k = ptr->vertex; graph[k].count--; if (!graph[k].count) { /* $ vertexd stack M */ graph[k].count = top; top = k; } } } } Chap : Graphs (Page ) Activity on Edge (AOE) Network Representation Edge: Activity Vertex: Event occurs when all incoming activities have been completed start v a = a = a = v v v a = v a = a = v a = 9 a = v v a 8 = a 9 = v 8 a = finish event v v v v v8 interpretation start of project completion of activity a completion of activity a and a completion of activity a and a8 completion of project (b) Interpretation of some of the events in the activity graph of (a) (a) AOE Network. Activity graph of a hypothetical project
28 Chap : Graphs (Page ) Critical Path of AOE Network Critical Path A path that has the longest length from start vertex to finish vertex Result in bottlenecks Earliest Time of an event v i Length of the longest path from start vertex v to v i (earliest() = ) earliest(v i ) Earliest start time for all outgoing activities of v i (early() = ) Latest Time, late(i), of activity a i Latest time the activity may start without increasing the project duration early() = & late() = 8, early() = & late() = Critical Activity Activity for which early(i) = late(i) Chap : Graphs (Page ) Calculation of Earliest Times Suppose activity a i is represented by edge <k, l> early(i) = earliest[k] late(i) = latest[l] - duration of activity a i Computing earliest[j] forward scan the network using topsort algorithm earliest[] = earliest[j] = max{earliest[i] + duration of <i, j>} for i P(j), where P(j) is the set of immediate predecessors of j Insert the following statement at the end of the else clause in topsort if (earliest[k] < earliest[j] + ptr->duration) earliest[k] = earliest[j] + ptr->duration
29 Chap : Graphs (Page ) count link vertex dur link V V V V V 9 V V 8 V 8 V 8 (a) Adjacency lists for Figure.(a) Chap : Graphs (Page 8) Earliest [] [] [] [] [] [] [] [] [8] Stack initial [] output V [,, ] output V [,, ] output V [, ] output V [] output V [] output V [, ] output V [] output V 8 [8] output V 8 (b) Computation of earliest Figure. : Computing earliest from topological sort
30 Chap : Graphs (Page 9) Calculation of Latest Times Computing latest[j] backward scan the network using topsort algorithm latest[n-] = earliest[n-] latest[j] = min{latest[i] - duration of <j, i>} for i S(j), where S(j) is the set of immediate successors of j Using inverse adjacence list Insert the following statement at the end of the else clause in topsort if (latest[k]> latest[j] - ptr->duration) latest[k] = latest[j] - ptr->duration Chap : Graphs (Page ) count link vertex dur link V V V V V V V 9 V V 8 (a) Inverted adjacency lists for AOE network of Figure.(a)
31 Chap : Graphs (Page ) Earliest [] [] [] [] [] [] [] [] [8] Stack initial [8] output V [, ] output V [, ] output V [, ] output V [] output V [] output V 8 8 [, ] output V 8 8 [] output V 8 8 [] (b) Computation of latest Figure. : Computing latest for AOE network of Figure.(a) Chap : Graphs (Page ) Calculation of Early(i) & Late(i) of a i Suppose activity a i is represented by edge <k, l> early(i) = earliest[k] late(i) = latest[l] - duration of activity a i Activity Early Late Late - Early Critical a a a a a a a a a 8 a 9 a 8 Yes No No Yes No No Yes Yes No Yes Yes
Konigsberg Bridge Problem
Graphs Konigsberg Bridge Problem c C d g A Kneiphof e D a B b f c A C d e g D a b f B Euler s Graph Degree of a vertex: the number of edges incident to it Euler showed that there is a walk starting at
More information國立清華大學電機工程學系. Outline
國立清華大學電機工程學系 EE Data Structure Chapter Graph (Part I) Outline The Graph Abstract Data Type Introduction Definitions Graph Representations Elementary Graph Operations Minimum Cost Spanning Trees ch.- River
More informationUNIT 5 GRAPH. Application of Graph Structure in real world:- Graph Terminologies:
UNIT 5 CSE 103 - Unit V- Graph GRAPH Graph is another important non-linear data structure. In tree Structure, there is a hierarchical relationship between, parent and children that is one-to-many relationship.
More informationOutline. Introduction. Representations of Graphs Graph Traversals. Applications. Definitions and Basic Terminologies
Graph Chapter 9 Outline Introduction Definitions and Basic Terminologies Representations of Graphs Graph Traversals Breadth first traversal Depth first traversal Applications Single source shortest path
More informationUNIT Name the different ways of representing a graph? a.adjacencymatrix b. Adjacency list
UNIT-4 Graph: Terminology, Representation, Traversals Applications - spanning trees, shortest path and Transitive closure, Topological sort. Sets: Representation - Operations on sets Applications. 1. Name
More informationUndirected Graphs. Hwansoo Han
Undirected Graphs Hwansoo Han Definitions Undirected graph (simply graph) G = (V, E) V : set of vertexes (vertices, nodes, points) E : set of edges (lines) An edge is an unordered pair Edge (v, w) = (w,
More informationChapter 9 Graph Algorithms
Chapter 9 Graph Algorithms 2 Introduction graph theory useful in practice represent many real-life problems can be slow if not careful with data structures 3 Definitions an undirected graph G = (V, E)
More information11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions
Introduction Chapter 9 Graph Algorithms graph theory useful in practice represent many real-life problems can be slow if not careful with data structures 2 Definitions an undirected graph G = (V, E) is
More informationBasic Graph Definitions
CMSC 341 Graphs Basic Graph Definitions A graph G = (V,E) consists of a finite set of vertices, V, and a finite set of edges, E. Each edge is a pair (v,w) where v, w V. V and E are sets, so each vertex
More informationChapter 14. Graphs Pearson Addison-Wesley. All rights reserved 14 A-1
Chapter 14 Graphs 2011 Pearson Addison-Wesley. All rights reserved 14 A-1 Terminology G = {V, E} A graph G consists of two sets A set V of vertices, or nodes A set E of edges A subgraph Consists of a subset
More informationGRAPHICAL ALGORITHMS. UNIT _II Lecture-12 Slides No. 3-7 Lecture Slides No Lecture Slides No
GRAPHICAL ALGORITHMS UNIT _II Lecture-12 Slides No. 3-7 Lecture-13-16 Slides No. 8-26 Lecture-17-19 Slides No. 27-42 Topics Covered Graphs & Trees ( Some Basic Terminologies) Spanning Trees (BFS & DFS)
More informationElementary Graph Algorithms CSE 6331
Elementary Graph Algorithms CSE 6331 Reading Assignment: Chapter 22 1 Basic Depth-First Search Algorithm procedure Search(G = (V, E)) // Assume V = {1, 2,..., n} // // global array visited[1..n] // visited[1..n]
More informationChapter 9 Graph Algorithms
Chapter 9 Graph Algorithms 2 Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures 3 Definitions an undirected graph G = (V, E) is a
More informationChapter 9 Graph Algorithms
Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures Chapter 9 Graph s 2 Definitions Definitions an undirected graph is a finite set
More informationThe ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value
The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value 1 Possible implementations Sorted linear implementations o Appropriate if
More informationReview of Data Structure(I)
Review of Data Structure(I) Ch. Basic Concepts: Pointers and dynamic memory allocation, data abstraction, algorithm specification, performance analysis & measurement Ch. Arrays and Structures: Dynamically
More informationGraph 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 informationGraph Traversals. CS200 - Graphs 1
Graph Traversals CS200 - Graphs 1 Tree traversal reminder A Pre order A B D G H C E F I B C In order G D H B A E C F I D E F Post order G H D B E I F C A G H I Level order A B C D E F G H I Connected Components
More informationUndirected 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 informationUNIT III TREES. A tree is a non-linear data structure that is used to represents hierarchical relationships between individual data items.
UNIT III TREES A tree is a non-linear data structure that is used to represents hierarchical relationships between individual data items. Tree: A tree is a finite set of one or more nodes such that, there
More informationCS302 - Data Structures using C++
CS302 - Data Structures using C++ Topic: Graphs - Introduction Kostas Alexis Terminology In the context of our course, graphs represent relations among data items G = {V,E} A graph is a set of vertices
More informationGraph. 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 informationGraph 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 informationA6-R3: DATA STRUCTURE THROUGH C LANGUAGE
A6-R3: DATA STRUCTURE THROUGH C LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be answered in the TEAR-OFF
More informationGraphs & Digraphs Tuesday, November 06, 2007
Graphs & Digraphs Tuesday, November 06, 2007 10:34 PM 16.1 Directed Graphs (digraphs) like a tree but w/ no root node & no guarantee of paths between nodes consists of: nodes/vertices - a set of elements
More informationROOT A node which doesn t have a parent. In the above tree. The Root is A. LEAF A node which doesn t have children is called leaf or Terminal node.
UNIT III : DYNAMIC STORAGE MANAGEMENT Trees: Binary tree, Terminology, Representation, Traversals, Applications. Graph: Terminology, Representation, Traversals Applications - spanning trees, shortest path.
More informationAlgorithm 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 informationMinimum 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 informationCOT 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 informationROOT: A node which doesn't have a parent. In the above tree. The Root is A.
TREE: A tree is a finite set of one or more nodes such that there is a specially designated node called the Root, and zero or more non empty sub trees T 1, T 2...T k, each of whose roots are connected
More informationCSCE 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 informationGraphs. Undirected edge has no orientation (u,v). u v. Undirected graph => no oriented edge. Directed graph => every edge has an orientation.
Graphs G = (V,E) V is the vertex set. Vertices are also called nodes and points. E is the edge set. Each edge connects two different vertices. Edges are also called arcs and lines. Directed edge has an
More informationGraph Representation
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]
More informationBACKGROUND: A BRIEF INTRODUCTION TO GRAPH THEORY
BACKGROUND: A BRIEF INTRODUCTION TO GRAPH THEORY General definitions; Representations; Graph Traversals; Topological sort; Graphs definitions & representations Graph theory is a fundamental tool in sparse
More informationAlgorithm Design (8) Graph Algorithms 1/2
Graph Algorithm Design (8) Graph Algorithms / Graph:, : A finite set of vertices (or nodes) : A finite set of edges (or arcs or branches) each of which connect two vertices Takashi Chikayama School of
More informationCS521 \ Notes for the Final Exam
CS521 \ Notes for final exam 1 Ariel Stolerman Asymptotic Notations: CS521 \ Notes for the Final Exam Notation Definition Limit Big-O ( ) Small-o ( ) Big- ( ) Small- ( ) Big- ( ) Notes: ( ) ( ) ( ) ( )
More informationDHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI. Department of Computer Science and Engineering CS6301 PROGRAMMING DATA STRUCTURES II
DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI Department of Computer Science and Engineering CS6301 PROGRAMMING DATA STRUCTURES II Anna University 2 & 16 Mark Questions & Answers Year / Semester: II / III
More informationCS 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 informationPart 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 informationW4231: 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 informationUnweighted Graphs & Algorithms
Unweighted Graphs & Algorithms Zachary Friggstad Programming Club Meeting References Chapter 4: Graph (Section 4.2) Chapter 22: Elementary Graph Algorithms Graphs Features: vertices/nodes/dots and edges/links/lines
More information1. Graph and Representation
Chapter Graphs Tree Root Direction: parent-child relationships No cycles Graph Vertices + Edges No tree restrictions Examples World Wide Web Maps. Graph and Representation A graph G: a pair (V, E) vertices
More informationFoundations of Discrete Mathematics
Foundations of Discrete Mathematics Chapter 12 By Dr. Dalia M. Gil, Ph.D. Trees Tree are useful in computer science, where they are employed in a wide range of algorithms. They are used to construct efficient
More information2. True or false: even though BFS and DFS have the same space complexity, they do not always have the same worst case asymptotic time complexity.
1. T F: Consider a directed graph G = (V, E) and a vertex s V. Suppose that for all v V, there exists a directed path in G from s to v. Suppose that a DFS is run on G, starting from s. Then, true or false:
More information8. Write an example for expression tree. [A/M 10] (A+B)*((C-D)/(E^F))
DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING EC6301 OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES UNIT IV NONLINEAR DATA STRUCTURES Part A 1. Define Tree [N/D 08]
More informationGraph and Digraph Glossary
1 of 15 31.1.2004 14:45 Graph and Digraph Glossary A B C D E F G H I-J K L M N O P-Q R S T U V W-Z Acyclic Graph A graph is acyclic if it contains no cycles. Adjacency Matrix A 0-1 square matrix whose
More informationGRAPHS Lecture 17 CS2110 Spring 2014
GRAPHS Lecture 17 CS2110 Spring 2014 These are not Graphs 2...not the kind we mean, anyway These are Graphs 3 K 5 K 3,3 = Applications of Graphs 4 Communication networks The internet is a huge graph Routing
More informationGraph 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 informationApplications of BDF and DFS
January 14, 2016 1 Deciding whether a graph is bipartite using BFS. 2 Finding connected components of a graph (both BFS and DFS) works. 3 Deciding whether a digraph is strongly connected. 4 Finding cut
More informationMinimum-Cost Spanning Tree. Example
Minimum-Cost Spanning Tree weighted connected undirected graph spanning tree cost of spanning tree is sum of edge costs find spanning tree that has minimum cost Example 2 4 12 6 3 Network has 10 edges.
More informationExample. Minimum-Cost Spanning Tree. Edge Selection Greedy Strategies. Edge Selection Greedy Strategies
Minimum-Cost Spanning Tree weighted connected undirected graph spanning tree cost of spanning tree is sum of edge costs find spanning tree that has minimum cost Example 2 4 12 6 3 Network has 10 edges.
More informationLecture 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 informationGraphs. The ultimate data structure. graphs 1
Graphs The ultimate data structure graphs 1 Definition of graph Non-linear data structure consisting of nodes & links between them (like trees in this sense) Unlike trees, graph nodes may be completely
More informationElementary 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 informationTrees Algorhyme by Radia Perlman
Algorhyme by Radia Perlman I think that I shall never see A graph more lovely than a tree. A tree whose crucial property Is loop-free connectivity. A tree which must be sure to span. So packets can reach
More informationLecture Notes. char myarray [ ] = {0, 0, 0, 0, 0 } ; The memory diagram associated with the array can be drawn like this
Lecture Notes Array Review An array in C++ is a contiguous block of memory. Since a char is 1 byte, then an array of 5 chars is 5 bytes. For example, if you execute the following C++ code you will allocate
More informationShortest path problems
Next... Shortest path problems Single-source shortest paths in weighted graphs Shortest-Path Problems Properties of Shortest Paths, Relaxation Dijkstra s Algorithm Bellman-Ford Algorithm Shortest-Paths
More informationInfo 2950, Lecture 16
Info 2950, Lecture 16 28 Mar 2017 Prob Set 5: due Fri night 31 Mar Breadth first search (BFS) and Depth First Search (DFS) Must have an ordering on the vertices of the graph. In most examples here, the
More informationData 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 informationCS6301 Programming and Data Structures II Unit -5 REPRESENTATION OF GRAPHS Graph and its representations Graph is a data structure that consists of following two components: 1. A finite set of vertices
More informationGraphs. 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 informationCSE 100 Minimum Spanning Trees Prim s and Kruskal
CSE 100 Minimum Spanning Trees Prim s and Kruskal Your Turn The array of vertices, which include dist, prev, and done fields (initialize dist to INFINITY and done to false ): V0: dist= prev= done= adj:
More informationDATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305
Q.1 If h is any hashing function and is used to hash n keys in to a table of size m, where n
More informationAlgorithm Analysis Graph algorithm. Chung-Ang University, Jaesung Lee
Algorithm Analysis Graph algorithm Chung-Ang University, Jaesung Lee Basic definitions Graph = (, ) where is a set of vertices and is a set of edges Directed graph = where consists of ordered pairs
More informationCS 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 informationDirected Graphs. DSA - lecture 5 - T.U.Cluj-Napoca - M. Joldos 1
Directed Graphs Definitions. Representations. ADT s. Single Source Shortest Path Problem (Dijkstra, Bellman-Ford, Floyd-Warshall). Traversals for DGs. Parenthesis Lemma. DAGs. Strong Components. Topological
More informationModule 5 Graph Algorithms
Module 5 Graph lgorithms Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 97 E-mail: natarajan.meghanathan@jsums.edu 5. Graph Traversal lgorithms Depth First
More informationRepresentations 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 informationOutline. Graphs. Divide and Conquer.
GRAPHS COMP 321 McGill University These slides are mainly compiled from the following resources. - Professor Jaehyun Park slides CS 97SI - Top-coder tutorials. - Programming Challenges books. Outline Graphs.
More informationUNIT 3. Greedy Method. Design and Analysis of Algorithms GENERAL METHOD
UNIT 3 Greedy Method GENERAL METHOD Greedy is the most straight forward design technique. Most of the problems have n inputs and require us to obtain a subset that satisfies some constraints. Any subset
More informationLecture 9 Graph Traversal
Lecture 9 Graph Traversal Euiseong Seo (euiseong@skku.edu) SWE00: Principles in Programming Spring 0 Euiseong Seo (euiseong@skku.edu) Need for Graphs One of unifying themes of computer science Closely
More informationGraphs. Motivations: o Networks o Social networks o Program testing o Job Assignment Examples: o Code graph:
Graphs Motivations: o Networks o Social networks o Program testing o Job Assignment Examples: o Code graph: S1: int x S2: If x > 0 then S3: X = x + 2; Else S4: X =x -1; End if S5: While x > 1 do S6: Print
More informationElementary Graph Algorithms: Summary. Algorithms. CmSc250 Intro to Algorithms
Elementary Graph Algorithms: Summary CmSc250 Intro to Algorithms Definition: A graph is a collection (nonempty set) of vertices and edges A path from vertex x to vertex y : a list of vertices in which
More informationGraph 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 informationLecture 4: Graph Algorithms
Lecture 4: Graph Algorithms Definitions Undirected graph: G =(V, E) V finite set of vertices, E finite set of edges any edge e = (u,v) is an unordered pair Directed graph: edges are ordered pairs If e
More informationCSC Intro to Intelligent Robotics, Spring Graphs
CSC 445 - Intro to Intelligent Robotics, Spring 2018 Graphs Graphs Definition: A graph G = (V, E) consists of a nonempty set V of vertices (or nodes) and a set E of edges. Each edge has either one or two
More informationAlgorithms Sequential and Parallel: A Unified Approach; R. Miller and L. Boxer 3rd Graph Algorithms
Algorithms Sequential and Parallel: A Unified Approach; R. Miller and L. Boxer rd Edition @ 0 www.thestudycampus.com Graph Algorithms Terminology Representations Fundamental Algorithms Computing the Transitive
More informationChapter 28 Graphs and Applications. Objectives
Chapter 28 Graphs and Applications CS2: Data Structures and Algorithms Colorado State University Original slides by Daniel Liang Modified slides by Chris Wilcox, Wim Bohm, and Russ Wakefield 1 Objectives
More informationParallel Graph Algorithms
Parallel Graph Algorithms Design and Analysis of Parallel Algorithms 5DV050 Spring 202 Part I Introduction Overview Graphsdenitions, properties, representation Minimal spanning tree Prim's algorithm Shortest
More informationHomework 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 informationLECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS
Department of Computer Science University of Babylon LECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS By Faculty of Science for Women( SCIW), University of Babylon, Iraq Samaher@uobabylon.edu.iq
More informationCSE 100: GRAPH ALGORITHMS
CSE 100: GRAPH ALGORITHMS Dijkstra s Algorithm: Questions Initialize the graph: Give all vertices a dist of INFINITY, set all done flags to false Start at s; give s dist = 0 and set prev field to -1 Enqueue
More informationHomework 5: Graphs, Minimum Spanning Trees, and Dijkstra Shortest-Path
Homework 5: Graphs, Minimum Spanning Trees, and Dijkstra Shortest-Path 1. (4 points) A graph is Hamiltonian if there is a cycle in the graph visiting each vertex exactly once. Give an example of an Eulerian
More informationWeek 11: Minimum Spanning trees
Week 11: Minimum Spanning trees Agenda: Minimum Spanning Trees Prim s Algorithm Reading: Textbook : 61-7 1 Week 11: Minimum Spanning trees Minimum spanning tree (MST) problem: Input: edge-weighted (simple,
More information3.1 Basic Definitions and Applications
Graphs hapter hapter Graphs. Basic efinitions and Applications Graph. G = (V, ) n V = nodes. n = edges between pairs of nodes. n aptures pairwise relationship between objects: Undirected graph represents
More informationCSI 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 informationData Structure. IBPS SO (IT- Officer) Exam 2017
Data Structure IBPS SO (IT- Officer) Exam 2017 Data Structure: In computer science, a data structure is a way of storing and organizing data in a computer s memory so that it can be used efficiently. Data
More informationAlgorithms (VII) Yijia Chen Shanghai Jiaotong University
Algorithms (VII) Yijia Chen Shanghai Jiaotong University Review of the Previous Lecture Depth-first search in undirected graphs Exploring graphs explore(g, v) Input: G = (V, E) is a graph; v V Output:
More informationStrongly connected: A directed graph is strongly connected if every pair of vertices are reachable from each other.
Directed Graph In a directed graph, each edge (u, v) has a direction u v. Thus (u, v) (v, u). Directed graph is useful to model many practical problems (such as one-way road in traffic network, and asymmetric
More informationLecture 2 - Graph Theory Fundamentals - Reachability and Exploration 1
CME 305: Discrete Mathematics and Algorithms Instructor: Professor Aaron Sidford (sidford@stanford.edu) January 11, 2018 Lecture 2 - Graph Theory Fundamentals - Reachability and Exploration 1 In this lecture
More informationDS UNIT 4. Matoshri College of Engineering and Research Center Nasik Department of Computer Engineering Discrete Structutre UNIT - IV
Sr.No. Question Option A Option B Option C Option D 1 2 3 4 5 6 Class : S.E.Comp Which one of the following is the example of non linear data structure Let A be an adjacency matrix of a graph G. The ij
More informationMinimum Spanning Tree
Minimum Spanning Tree 1 Minimum Spanning Tree G=(V,E) is an undirected graph, where V is a set of nodes and E is a set of possible interconnections between pairs of nodes. For each edge (u,v) in E, we
More informationCS/COE 1501 cs.pitt.edu/~bill/1501/ Graphs
CS/COE 1501 cs.pitt.edu/~bill/1501/ Graphs 5 3 2 4 1 0 2 Graphs A graph G = (V, E) Where V is a set of vertices E is a set of edges connecting vertex pairs Example: V = {0, 1, 2, 3, 4, 5} E = {(0, 1),
More informationCS 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 informationCS420/520 Algorithm Analysis Spring 2009 Lecture 14
CS420/520 Algorithm Analysis Spring 2009 Lecture 14 "A Computational Analysis of Alternative Algorithms for Labeling Techniques for Finding Shortest Path Trees", Dial, Glover, Karney, and Klingman, Networks
More informationCSE 100: GRAPH ALGORITHMS
CSE 100: GRAPH ALGORITHMS 2 Graphs: Example A directed graph V5 V = { V = E = { E Path: 3 Graphs: Definitions A directed graph V5 V6 A graph G = (V,E) consists of a set of vertices V and a set of edges
More informationUnit #9: Graphs. CPSC 221: Algorithms and Data Structures. Will Evans 2012W1
Unit #9: Graphs CPSC 1: Algorithms and Data Structures Will Evans 01W1 Unit Outline Topological Sort: Getting to Know Graphs with a Sort Graph ADT and Graph Representations Graph Terminology More Graph
More information1 Digraphs. Definition 1
1 Digraphs Definition 1 Adigraphordirected graphgisatriplecomprisedofavertex set V(G), edge set E(G), and a function assigning each edge an ordered pair of vertices (tail, head); these vertices together
More informationEnd-Term Examination Second Semester [MCA] MAY-JUNE 2006
(Please write your Roll No. immediately) Roll No. Paper Code: MCA-102 End-Term Examination Second Semester [MCA] MAY-JUNE 2006 Subject: Data Structure Time: 3 Hours Maximum Marks: 60 Note: Question 1.
More informationIntroductory Remarks
Chapter 8: Graphs Introductory Remarks Although trees are quite flexible, they have an inherent limitation in that they can only express hierarchical structures Fortunately, we can generalize a tree to
More information