UNDIRECTED GRAPHS BBM 201 DATA STRUCTURES DEPT. OF COMPUTER ENGINEERING

Size: px
Start display at page:

Download "UNDIRECTED GRAPHS BBM 201 DATA STRUCTURES DEPT. OF COMPUTER ENGINEERING"

Transcription

1 Acknowledgement: he course slides are adapted from the slides prepared by R. Sedgewick and K. Wayne of Princeton Uniersity. BBM DAA SRUCURES DEP. O COMPUER ENGINEERING UNDIRECED GRAPHS

2 Undirected Graphs Graph API Depth-first search Breadth-first search ODAY

3 Undirected graphs Graph. Set of ertices connected pairwise by edges. Why study graph algorithms? housands of practical applications. Hundreds of graph algorithms known. Interesting and broadly useful abstraction. Challenging branch of computer science and discrete math.

4 Undirected graphs Graph. Set of ertices connected pairwise by edges. Why study graph algorithms? housands of practical applications. Hundreds of graph algorithms known. Interesting and broadly useful abstraction. Challenging branch of computer science and discrete math.

5 Protein-protein interaction network Reference: Jeong et al, Nature Reiew Genetics

6 he Internet as mapped by the Opte Project

7 Map of science clickstreams

8 million acebook friends "Visualizing riendships" by Paul Butler

9 Graph applications graph ertex edge communication telephone, computer fiber optic cable circuit gate, register, processor wire mechanical joint rod, beam, spring financial stock, currency transactions transportation street intersection, airport highway, airway route internet class C network connection game board position legal moe social relationship person, actor friendship, moie cast neural network neuron synapse protein network protein protein-protein interaction chemical compound molecule bond

10 Graph terminology Path. Sequence of ertices connected by edges. Cycle. Path whose first and last ertices are the same. wo ertices are connected if there is a path between them.

11 Some graph-processing problems Path. Is there a path between s and t? Shortest path. What is the shortest path between s and t? Cycle. Is there a cycle in the graph? Euler tour. Is there a cycle that uses each edge exactly once? Hamilton tour. Is there a cycle that uses each ertex exactly once? Connectiity. Is there a way to connect all of the ertices? MS. What is the best way to connect all of the ertices? Biconnectiity. Is there a ertex whose remoal disconnects the graph? Planarity. Can you draw the graph in the plane with no crossing edges? Graph isomorphism. Do two adjacency lists represent the same graph? Challenge. Which of these problems are easy? difficult? intractable?

12 Graph API Depth-first search Breadth-first search UNDIRECED GRAPHS

13 Graph representation Graph drawing. Proides intuition about the structure of the graph. two drawings of the same graph Caeat. Intuition can be misleading.

14 Graph representation Vertex representation. his lecture: use integers between and V. Applications: conert between names and integers with symbol table. A B C G symbol table D E Anomalies.

15 Graph API: sample client Graph input format. tinyg.txt

16 Set-of-edges graph representation Maintain a list of the edges (linked list or array).

17 Adjacency-matrix graph representation Maintain a two-dimensional V-by-V boolean array; for each edge w in graph: adj[][w] = adj[w][] = true. two entries for each edge

18 Adjacency-list graph representation Maintain ertex-indexed array of lists.

19 Adjacency-list graph representation: Jaa implementation //for each edge call addedge twice addedge(,w); addedge(w,); public oid addedge(int, int w){ node *q; //acquire memory for the new node q=(node*)malloc(sizeof(node)); q->ertex=w; typedef struct node { struct node *next; int ertex; }node; node * adj []; q->next=null; //insert the node to beginning of the linked list q->next=adj[]; adj[]= q; }

20 Graph representations In practice. Use adjacency-lists representation. Algorithms based on iterating oer ertices adjacent to. Real-world graphs tend to be sparse. huge number of ertices, small aerage ertex degree

21 Graph representations In practice. Use adjacency-lists representation. Algorithms based on iterating oer ertices adjacent to. Real-world graphs tend to be sparse. huge number of ertices, small aerage ertex degree representation space add edge edge between and w? iterate oer ertices adjacent to? list of edges E E E adjacency matrix V V adjacency lists E + V degree() degree()

22 Graph API Depth-first search Breadth-first search UNDIRECED GRAPHS

23 Depth-first search Goal. Systematically search through a graph. DS (to isit a ertex ) Mark as isited. Recursiely isit all unmarked ertices w adjacent to. ypical applications. ind all ertices connected to a gien source ertex. ind a path between two ertices.

24

25 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. graph G

26 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] graph G

27 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] isit

28 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] isit

29 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] isit

30 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] isit

31 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] isit

32 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] isit

33 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] isit

34 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] done

35 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] isit

36 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] isit

37 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] done

38 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] isit

39 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] isit

40 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] done

41 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] done

42 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] isit

43 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] isit

44 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] done

45 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] isit

46 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] isit

47 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] done

48 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] done

49 Depth-first search o isit a ertex : Mark ertex as isited. Recursiely isit all unmarked ertices adjacent to. marked[] edgeo[] ertices reachable from

50 Depth-first search Goal. ind all ertices connected to s (and a path). Algorithm. Use recursion (ball of string). Mark each isited ertex (and keep track of edge taken to isit it). Return (retrace steps) when no unisited options. Data structures. boolean[] marked to mark isited ertices. int[] edgeo to keep tree of paths. (edgeo[w] == ) means that edge -w taken to isit w for first time

51 Depth-first search oid DS(int i) { node *p = adj[i]; isited[i]=; while(p!= NULL) { i = p->ertex; if(!isited[i]) DS(i); p = p->next; } } typedef struct node { struct node *next; int ertex; }node; //GLOBAL PARAMEERS node * adj []; int isited[];

52 Graph API Depth-first search Breadth-first search UNDIRECED GRAPHS

53 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. graph G

54 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] add to queue

55 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

56 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

57 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

58 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

59 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] done

60 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

61 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

62 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

63 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

64 Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. Breadth-first search dequeue edgeo[] queue

65 Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. Breadth-first search done edgeo[] queue

66 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

67 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

68 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

69 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] done

70 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

71 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

72 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

73 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] done

74 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

75 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

76 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

77 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

78 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] done

79 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

80 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

81 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] dequeue

82 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. queue edgeo[] done

83 Breadth-first search Repeat until queue is empty: Remoe ertex from queue. Add to queue all unmarked ertices adjacent to and mark them. edgeo[] done

84 Breadth-first search Depth-first search. Put unisited ertices on a stack. Breadth-first search. Put unisited ertices on a queue. Shortest path. ind path from s to t that uses fewest number of edges. BS (from source ertex s) Put s onto a IO queue, and mark s as isited. Repeat until the queue is empty: - remoe the least recently added ertex - add each of 's unisited neighbors to the queue, and mark them as isited. Intuition. BS examines ertices in increasing distance from s.

85 Breadth-first search properties Proposition. BS computes shortest path (number of edges) from s in a connected graph in time proportional to E + V. Pf. [correctness] Queue always consists of zero or more ertices of distance k from s, followed by zero or more ertices of distance k +. Pf. [running time] Each ertex connected to s is isited once. standard drawing dist = dist = dist =

UNDIRECTED GRAPHS BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING

UNDIRECTED GRAPHS BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING BBM - ALGORIHMS DEP. O COMPUER ENGINEERING UNDIRECED GRAPHS Acknowledgement: he course slides are adapted from the slides prepared by R. Sedgewick and K. Wayne of Princeton Uniersity. Undirected Graphs

More information

UNDIRECTED GRAPHS TODAY BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING. Undirected graphs. Graph applications

UNDIRECTED GRAPHS TODAY BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING. Undirected graphs. Graph applications BBM - ALGORIHMS ODAY DEP. O COMPUER ENGINEERING UNDIRECED GRAPHS Undirected Graphs Graph API Depth-first search Challenges Acknowledgement: he course slides are adapted from the slides prepared by R. Sedgewick

More information

DIRECTED GRAPHS BBM 201 DATA STRUCTURES DEPT. OF COMPUTER ENGINEERING

DIRECTED GRAPHS BBM 201 DATA STRUCTURES DEPT. OF COMPUTER ENGINEERING Acknowledgement: he course slides are adapted from the slides prepared by R. Sedgewick and K. Wayne of Princeton University. BBM DAA SRUCURES DEP. O COMPUER ENGINEERING DIRECED GRAPHS Directed Graphs Digraph

More information

! Interesting and broadly useful abstraction. ! Challenging branch of computer science and discrete math. ! Hundreds of graph algorithms known.

! Interesting and broadly useful abstraction. ! Challenging branch of computer science and discrete math. ! Hundreds of graph algorithms known. Undirected Graphs Undirected Graphs Graph. Set of objects with pairwise connections. Why study graph algorithms?! Interesting and broadly useful abstraction.! Challenging branch of computer science and

More information

GRAPHS (Undirected) Graph: Set of objects with pairwise connections. Why study graph algorithms?

GRAPHS (Undirected) Graph: Set of objects with pairwise connections. Why study graph algorithms? GRAPHS (Undirected) Graph: Set of objects with pairwise connections. Why study graph algorithms? Interesting and broadly useful abstraction. Challenging branch of computer science and discrete math. Hundreds

More information

Graph Algorithms. Parallel and Distributed Computing. Department of Computer Science and Engineering (DEI) Instituto Superior Técnico.

Graph Algorithms. Parallel and Distributed Computing. Department of Computer Science and Engineering (DEI) Instituto Superior Técnico. Graph Algorithms Parallel and Distributed Computing Department of Computer Science and Engineering (DEI) Instituto Superior Técnico May, 0 CPD (DEI / IST) Parallel and Distributed Computing 0-0-0 / Outline

More information

Undirected Graphs. graph API maze exploration depth-first search breadth-first search connected components challenges.

Undirected Graphs. graph API maze exploration depth-first search breadth-first search connected components challenges. Undirected graphs Graph. Set of vertices connected pairwise by edges. Undirected Graphs References: Algorithms in Java, Chapters and Why study graph algorithms? Interesting and broadly useful abstraction.

More information

CS 4407 Algorithms Lecture 5: Graphs an Introduction

CS 4407 Algorithms Lecture 5: Graphs an Introduction CS 4407 Algorithms Lecture 5: Graphs an Introduction Prof. Gregory Provan Department of Computer Science University College Cork 1 Outline Motivation Importance of graphs for algorithm design applications

More information

Undirected Graphs. introduction Graph API maze exploration depth-first search breadth-first search connected components challenges.

Undirected Graphs. introduction Graph API maze exploration depth-first search breadth-first search connected components challenges. Undirected Graphs Graph. Set of vertices connected pairwise by edges. Undirected Graphs Why study graph algorithms? Interesting and broadly useful abstraction. Challenging branch of computer science and

More information

Graph Algorithms. Andreas Klappenecker

Graph Algorithms. Andreas Klappenecker Graph Algorithms Andreas Klappenecker Graphs A graph is a set of vertices that are pairwise connected by edges. We distinguish between directed and undirected graphs. Why are we interested in graphs? Graphs

More information

CMSC 132: Object-Oriented Programming II

CMSC 132: Object-Oriented Programming II CMSC 132: Object-Oriented Programming II DIRECTED GRAPHS Graphs slides are modified from COS 126 slides of Dr. Robert Sedgewick. 1 Directed graphs Digraph Set of vertices connected pairwise by directed

More information

DIRECTED GRAPHS BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING ERKUT ERDEM. Apr. 3, 2013

DIRECTED GRAPHS BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING ERKUT ERDEM. Apr. 3, 2013 BBM - ALGORIHMS DEP. O COMPUER ENGINEERING ERKU ERDEM DIRECED GRAPHS Apr., Acknowledgement: he course slides are adapted from the slides prepared by R. Sedgewick and K. Wayne of Princeton Uniersity. Directed

More information

3. GRAPHS. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Copyright 2013 Kevin Wayne. Last updated on Sep 8, :19 AM

3. GRAPHS. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Copyright 2013 Kevin Wayne. Last updated on Sep 8, :19 AM 3. GRAPHS basic definitions and applications graph connectivity and graph traversal testing bipartiteness connectivity in directed graphs DAGs and topological ordering Lecture slides by Kevin Wayne Copyright

More information

Breadth First Search. cse2011 section 13.3 of textbook

Breadth First Search. cse2011 section 13.3 of textbook Breadth irst Search cse section. of textbook Graph raversal (.) Application example Given a graph representation and a vertex s in the graph, find all paths from s to the other vertices. wo common graph

More information

Breadth First Search. Graph Traversal. CSE 2011 Winter Application examples. Two common graph traversal algorithms

Breadth First Search. Graph Traversal. CSE 2011 Winter Application examples. Two common graph traversal algorithms Breadth irst Search CSE Winter Graph raversal Application examples Given a graph representation and a vertex s in the graph ind all paths from s to the other vertices wo common graph traversal algorithms

More information

COP 4531 Complexity & Analysis of Data Structures & Algorithms

COP 4531 Complexity & Analysis of Data Structures & Algorithms COP Complexity & Analysis of Data Structures & Algorithms Overview of Graphs Breadth irst Search, and Depth irst Search hanks to several people who contributed to these slides including Piyush Kumar and

More information

Algorithms: Lecture 10. Chalmers University of Technology

Algorithms: Lecture 10. Chalmers University of Technology Algorithms: Lecture 10 Chalmers University of Technology Today s Topics Basic Definitions Path, Cycle, Tree, Connectivity, etc. Graph Traversal Depth First Search Breadth First Search Testing Bipartatiness

More information

This course is intended for 3rd and/or 4th year undergraduate majors in Computer Science.

This course is intended for 3rd and/or 4th year undergraduate majors in Computer Science. Lecture 9 Graphs This course is intended for 3rd and/or 4th year undergraduate majors in Computer Science. You need to be familiar with the design and use of basic data structures such as Lists, Stacks,

More information

Chapter 3. Graphs CLRS Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 3. Graphs CLRS Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 3 Graphs CLRS 12-13 Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 3.1 Basic Definitions and Applications Undirected Graphs Undirected graph. G = (V, E) V

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 5 Exploring graphs Adam Smith 9/5/2008 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Puzzles Suppose an undirected graph G is connected.

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

DIRECTED GRAPHS BBM ALGORITHMS TODAY DEPT. OF COMPUTER ENGINEERING. Mar. 31, Directed graphs. Road network

DIRECTED GRAPHS BBM ALGORITHMS TODAY DEPT. OF COMPUTER ENGINEERING. Mar. 31, Directed graphs. Road network BBM - ALGORIHMS ODAY DEP. O COMPUER ENGINEERING Directed Graphs Digraph API Digraph search opological sort Strong components DIRECED GRAPHS Mar., Acknowledgement: he course slides are adapted from the

More information

3.1 Basic Definitions and Applications

3.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 information

! Vertex = species. ! Edge = from prey to predator.

! Vertex = species. ! Edge = from prey to predator. irected Graphs irected Graphs igraph. Set of objects with oriented pairwise connections. x. One-way street, hyperlink. Reference: Chapter 19, Algorithms in Java, 3 rd dition, Robert Sedgewick. Robert Sedgewick

More information

DIRECTED GRAPHS BBM ALGORITHMS TODAY DEPT. OF COMPUTER ENGINEERING ERKUT ERDEM. Apr. 3, Directed graphs. Road network

DIRECTED GRAPHS BBM ALGORITHMS TODAY DEPT. OF COMPUTER ENGINEERING ERKUT ERDEM. Apr. 3, Directed graphs. Road network BBM - ALGORIHMS ODAY DEP. O COMPUER ENGINEERING ERKU ERDEM Directed Graphs Digraph API Digraph search opological sort Strong components DIRECED GRAPHS Apr., Acknowledgement: he course slides are adapted

More information

Basic Graph Search. Algorithms and Data Structures, Fall Rasmus Pagh. Based on slides by Kevin Wayne, Princeton

Basic Graph Search. Algorithms and Data Structures, Fall Rasmus Pagh. Based on slides by Kevin Wayne, Princeton Algorithms and Data Structures, Fall Basic Graph Search Rasmus Pagh Based on slides by Kevin Wayne, Princeton Algorithms, th Edition Robert Sedgewick and Kevin Wayne Copyright Mid-term evaluation Thanks

More information

implementing the breadth-first search algorithm implementing the depth-first search algorithm

implementing the breadth-first search algorithm implementing the depth-first search algorithm Graph Traversals 1 Graph Traversals representing graphs adjacency matrices and adjacency lists 2 Implementing the Breadth-First and Depth-First Search Algorithms implementing the breadth-first search algorithm

More information

Graphs. The ultimate data structure. graphs 1

Graphs. 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 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

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

LECTURE 17 GRAPH TRAVERSALS

LECTURE 17 GRAPH TRAVERSALS DATA STRUCTURES AND ALGORITHMS LECTURE 17 GRAPH TRAVERSALS IMRAN IHSAN ASSISTANT PROFESSOR AIR UNIVERSITY, ISLAMABAD STRATEGIES Traversals of graphs are also called searches We can use either breadth-first

More information

Chapter 14. Graphs Pearson Addison-Wesley. All rights reserved 14 A-1

Chapter 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 information

CSE 100: GRAPH ALGORITHMS

CSE 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 information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 3 Data Structures Graphs Traversals Strongly connected components Sofya Raskhodnikova L3.1 Measuring Running Time Focus on scalability: parameterize the running time

More information

Graphs. Data Structures 1 Graphs

Graphs. Data Structures 1 Graphs Graphs Graph Applications Definitions Graph Representations(adjacency matrix/list) Graph ADT Graph Traversals: BFS, DFS Shortest Path Algorithms Minimum Spanning Tree Algorithms Data Structures Graphs

More information

3.1 Basic Definitions and Applications. Chapter 3. Graphs. Undirected Graphs. Some Graph Applications

3.1 Basic Definitions and Applications. Chapter 3. Graphs. Undirected Graphs. Some Graph Applications Chapter 3 31 Basic Definitions and Applications Graphs Slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley All rights reserved 1 Undirected Graphs Some Graph Applications Undirected graph G = (V,

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

Chapter 3. Graphs. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 3. Graphs. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 3 Graphs Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 3.1 Basic Definitions and Applications Undirected Graphs Undirected graph. G = (V, E) V = nodes. E

More information

Majority and Friendship Paradoxes

Majority and Friendship Paradoxes Majority and Friendship Paradoxes Majority Paradox Example: Small town is considering a bond initiative in an upcoming election. Some residents are in favor, some are against. Consider a poll asking the

More information

Paths, Circuits, and Connected Graphs

Paths, Circuits, and Connected Graphs Paths, Circuits, and Connected Graphs Paths and Circuits Definition: Let G = (V, E) be an undirected graph, vertices u, v V A path of length n from u to v is a sequence of edges e i = {u i 1, u i} E for

More information

Graphs. Terminology. Graphs & Breadth First Search (BFS) Extremely useful tool in modeling problems. Consist of: Vertices Edges

Graphs. Terminology. Graphs & Breadth First Search (BFS) Extremely useful tool in modeling problems. Consist of: Vertices Edges COMP Spring Graphs & BS / Slide Graphs Graphs & Breadth irst Search (BS) Extremely useful tool in modeling problems. Consist of: Vertices Edges Vertex A B D C E Edge Vertices can be considered sites or

More information

CS2 Algorithms and Data Structures Note 9

CS2 Algorithms and Data Structures Note 9 CS2 Algorithms and Data Structures Note 9 Graphs The remaining three lectures of the Algorithms and Data Structures thread will be devoted to graph algorithms. 9.1 Directed and Undirected Graphs A graph

More information

Algorithms: Graphs. Amotz Bar-Noy. Spring 2012 CUNY. Amotz Bar-Noy (CUNY) Graphs Spring / 95

Algorithms: Graphs. Amotz Bar-Noy. Spring 2012 CUNY. Amotz Bar-Noy (CUNY) Graphs Spring / 95 Algorithms: Graphs Amotz Bar-Noy CUNY Spring 2012 Amotz Bar-Noy (CUNY) Graphs Spring 2012 1 / 95 Graphs Definition: A graph is a collection of edges and vertices. Each edge connects two vertices. Amotz

More information

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

Understand graph terminology Implement graphs using

Understand graph terminology Implement graphs using raphs Understand graph terminology Implement graphs using djacency lists and djacency matrices Perform graph searches Depth first search Breadth first search Perform shortest-path algorithms Disjkstra

More information

3.1 Basic Definitions and Applications

3.1 Basic Definitions and Applications Chapter 3 Graphs Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 3.1 Basic Definitions and Applications Undirected Graphs Undirected graph. G = (V, E) V = nodes. E

More information

Lecture 24 Notes Search in Graphs

Lecture 24 Notes Search in Graphs Lecture 24 Notes Search in Graphs 15-122: Principles of Imperative Computation (Spring 2016) Frank Pfenning, André Platzer, Rob Simmons, Penny Anderson 1 Introduction In this lecture, we will discuss the

More information

CSE 373 NOVEMBER 20 TH TOPOLOGICAL SORT

CSE 373 NOVEMBER 20 TH TOPOLOGICAL SORT CSE 373 NOVEMBER 20 TH TOPOLOGICAL SORT PROJECT 3 500 Internal Error problems Hopefully all resolved (or close to) P3P1 grades are up (but muted) Leave canvas comment Emails tomorrow End of quarter GRAPHS

More information

GRAPH THEORY. What are graphs? Why graphs? Graphs are usually used to represent different elements that are somehow related to each other.

GRAPH THEORY. What are graphs? Why graphs? Graphs are usually used to represent different elements that are somehow related to each other. GRPH THEORY Hadrian ng, Kyle See, March 2017 What are graphs? graph G is a pair G = (V, E) where V is a nonempty set of vertices and E is a set of edges e such that e = {a, b where a and b are vertices.

More information

To list all vertices connected to a vertex u in graph G we can use the following loop:

To list all vertices connected to a vertex u in graph G we can use the following loop: Using nextdjacent() To list all vertices connected to a vertex u in graph we can use the following loop: for (int v=.nextdjacent(u,-1); v>=0; v=.nextdjacent(u,v)) { System.out.print(v); djacency Lists

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

CS 206 Introduction to Computer Science II

CS 206 Introduction to Computer Science II CS 206 Introduction to Computer Science II 04 / 06 / 2018 Instructor: Michael Eckmann Today s Topics Questions? Comments? Graphs Definition Terminology two ways to represent edges in implementation traversals

More information

DS UNIT 4. Matoshri College of Engineering and Research Center Nasik Department of Computer Engineering Discrete Structutre UNIT - IV

DS 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 information

CSE 373: Data Structures and Algorithms

CSE 373: Data Structures and Algorithms CSE 373: Data Structures and Algorithms Lecture 15: Graph Data Structures, Topological Sort, and Traversals (DFS, BFS) Instructor: Lilian de Greef Quarter: Summer 2017 Today: Announcements Graph data structures

More information

Directed Graphs. digraph API digraph search transitive closure topological sort strong components. Directed graphs

Directed Graphs. digraph API digraph search transitive closure topological sort strong components. Directed graphs Directed graphs Digraph. Set of vertices connected pairwise by oriented edges. Directed Graphs digraph API digraph search transitive closure topological sort strong components References: Algorithms in

More information

- Logic and Algorithms - Graph Algorithms

- Logic and Algorithms - Graph Algorithms Fundamentals of Computer Sience and Digital Communications - Logic and Algorithms - Graph Algorithms Johan Larsson Marco Loh 22..24 Overview What is a Graph? Representations of Graphs Breadth-first Search

More information

Graphs. The ultimate data structure. graphs 1

Graphs. 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 information

Graphs. Ric Glassey

Graphs. Ric Glassey Graphs Ric Glassey glassey@kth.se Overview Graphs Aim: Introduce graphs as a fundamental data structure that can be applied in many real-world problems Applications of graphs Definition and types of graphs

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

Multidimensional Arrays & Graphs. CMSC 420: Lecture 3

Multidimensional Arrays & Graphs. CMSC 420: Lecture 3 Multidimensional Arrays & Graphs CMSC 420: Lecture 3 Mini-Review Abstract Data Types: List Stack Queue Deque Dictionary Set Implementations: Linked Lists Circularly linked lists Doubly linked lists XOR

More information

Introduction To Graphs and Networks. Fall 2013 Carola Wenk

Introduction To Graphs and Networks. Fall 2013 Carola Wenk Introduction To Graphs and Networks Fall 2013 Carola Wenk What is a Network? We have thought of a computer as a single entity, but they can also be connected to one another. Internet What are the advantages

More information

CS 3410 Ch 14 Graphs and Paths

CS 3410 Ch 14 Graphs and Paths CS 3410 Ch 14 Graphs and Paths Sections 14.1-14.3 Pages 527-552 Exercises 1,2,5,7-9 14.1 Definitions 1. A vertex (node) and an edge are the basic building blocks of a graph. Two vertices, (, ) may be connected

More information

Math.3336: Discrete Mathematics. Chapter 10 Graph Theory

Math.3336: Discrete Mathematics. Chapter 10 Graph Theory Math.3336: Discrete Mathematics Chapter 10 Graph Theory Instructor: Dr. Blerina Xhabli Department of Mathematics, University of Houston https://www.math.uh.edu/ blerina Email: blerina@math.uh.edu Fall

More information

Algorithms. Graphs. Algorithms

Algorithms. Graphs. Algorithms Algorithms Graphs Algorithms Graphs Definition: A graph is a collection of edges and vertices. Each edge connects two vertices. Algorithms 1 Graphs Vertices: Nodes, points, computers, users, items,...

More information

GRAPHS Lecture 17 CS2110 Spring 2014

GRAPHS 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 information

Graphs. The ultimate data structure. graphs 1

Graphs. 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 information

Introduction to Graphs. common/notes/ppt/

Introduction to Graphs.   common/notes/ppt/ Introduction to Graphs http://people.cs.clemson.edu/~pargas/courses/cs212/ common/notes/ppt/ Introduction Graphs are a generalization of trees Nodes or verticies Edges or arcs Two kinds of graphs irected

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

Lecture 24 Search in Graphs

Lecture 24 Search in Graphs Lecture 24 Search in Graphs 15-122: Principles of Imperative Computation (Fall 2018) Frank Pfenning, André Platzer, Rob Simmons, Penny Anderson, Iliano Cervesato In this lecture, we will discuss the question

More information

Algorithms and Theory of Computation. Lecture 3: Graph Algorithms

Algorithms and Theory of Computation. Lecture 3: Graph Algorithms Algorithms and Theory of Computation Lecture 3: Graph Algorithms Xiaohui Bei MAS 714 August 20, 2018 Nanyang Technological University MAS 714 August 20, 2018 1 / 18 Connectivity In a undirected graph G

More information

Algorithms: Lecture 7. Chalmers University of Technology

Algorithms: Lecture 7. Chalmers University of Technology Algorithms: Lecture 7 Chalmers University of Technology Today s Lecture Divide & Conquer Counting Inversions Closest Pair of Points Multiplication of large integers Intro to the forthcoming problems Graphs:

More information

lecture27: Graph Traversals

lecture27: Graph Traversals lecture27: Largely based on slides by Cinda Heeren CS 225 UIUC 25th July, 2013 Announcements mp7.1 extra credit due tomorrow night (7/26) Code challenge tomorrow night (7/26) at 6pm in 0224 lab hash due

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

Homework 6 Solutions CS330 Discrete Structures, Fall 2017

Homework 6 Solutions CS330 Discrete Structures, Fall 2017 Homework 6 Solutions CS330 Discrete Structures, Fall 2017 Instructor: Professor Edward Reingold TA: Jiahui Hou, Haohua Du Solutions 1. 10 pts) Algorithm 1 Basic Euler Circuit Algorithm. procedure Euler(G

More information

Network Basics. CMSC 498J: Social Media Computing. Department of Computer Science University of Maryland Spring Hadi Amiri

Network Basics. CMSC 498J: Social Media Computing. Department of Computer Science University of Maryland Spring Hadi Amiri Network Basics CMSC 498J: Social Media Computing Department of Computer Science University of Maryland Spring 2016 Hadi Amiri hadi@umd.edu Lecture Topics Graphs as Models of Networks Graph Theory Nodes,

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

NANYANG TECHNOLOGICAL UNIVERSITY SEMESTER II EXAMINATION MH 1301 DISCRETE MATHEMATICS TIME ALLOWED: 2 HOURS

NANYANG TECHNOLOGICAL UNIVERSITY SEMESTER II EXAMINATION MH 1301 DISCRETE MATHEMATICS TIME ALLOWED: 2 HOURS NANYANG TECHNOLOGICAL UNIVERSITY SEMESTER II EXAMINATION 2015-2016 MH 1301 DISCRETE MATHEMATICS May 2016 TIME ALLOWED: 2 HOURS INSTRUCTIONS TO CANDIDATES 1. This examination paper contains FIVE (5) questions

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

Graphs. Tessema M. Mengistu Department of Computer Science Southern Illinois University Carbondale Room - Faner 3131

Graphs. Tessema M. Mengistu Department of Computer Science Southern Illinois University Carbondale Room - Faner 3131 Graphs Tessema M. Mengistu Department of Computer Science Southern Illinois University Carbondale tessema.mengistu@siu.edu Room - Faner 3131 1 Outline Introduction to Graphs Graph Traversals Finding a

More information

2 hours THE UNIVERSITY OF MANCHESTER. 23 May :45 11:45

2 hours THE UNIVERSITY OF MANCHESTER. 23 May :45 11:45 2 hours MAT20902 TE UNIVERSITY OF MANCESTER DISCRETE MATEMATICS 23 May 2018 9:45 11:45 Answer ALL TREE questions in Section A (30 marks in total). Answer TWO of the TREE questions in Section B (50 marks

More information

Lecture 10. Graphs Vertices, edges, paths, cycles Sparse and dense graphs Representations: adjacency matrices and adjacency lists Implementation notes

Lecture 10. Graphs Vertices, edges, paths, cycles Sparse and dense graphs Representations: adjacency matrices and adjacency lists Implementation notes Lecture 10 Graphs Vertices, edges, paths, cycles Sparse and dense graphs Representations: adjacency matrices and adjacency lists Implementation notes Reading: Weiss, Chapter 9 Page 1 of 24 Midterm exam

More information

BACKGROUND: A BRIEF INTRODUCTION TO GRAPH THEORY

BACKGROUND: 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 information

1 Graphs and networks

1 Graphs and networks 1 Graphs and networks A graph or a network is a collection of vertices (or nodes or sites or actors) joined by edges (or links or connections or bonds or ties). We ll use the terms interchangeably, although

More information

Graphs Chapter 24. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Graphs Chapter 24. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Graphs Chapter 24 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 2 Scope Graphs: Directed and undirected graphs Weighted graphs (networks) Common graph algorithms Wk12.5 Slide 2 3 Graphs

More information

Social Network Analysis With igraph & R. Ofrit Lesser December 11 th, 2014

Social Network Analysis With igraph & R. Ofrit Lesser December 11 th, 2014 Social Network Analysis With igraph & R Ofrit Lesser ofrit.lesser@gmail.com December 11 th, 2014 Outline The igraph R package Basic graph concepts What can you do with igraph? Construction Attributes Centrality

More information

Unweighted Graphs & Algorithms

Unweighted 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 information

CSE 100: GRAPH SEARCH

CSE 100: GRAPH SEARCH CSE 100: GRAPH SEARCH Announcements PA3 released Checkpoint due Tuesday, May 5 @10:00pm Final submission due Thursday, May 14 @10:00PM Start early! Start early! Start early! Start early! Start early! I

More information

CSE 373 Final Exam 3/14/06 Sample Solution

CSE 373 Final Exam 3/14/06 Sample Solution Question 1. (6 points) A priority queue is a data structure that supports storing a set of values, each of which has an associated key. Each key-value pair is an entry in the priority queue. The basic

More information

BIL694-Lecture 1: Introduction to Graphs

BIL694-Lecture 1: Introduction to Graphs BIL694-Lecture 1: Introduction to Graphs Lecturer: Lale Özkahya Resources for the presentation: http://www.math.ucsd.edu/ gptesler/184a/calendar.html http://www.inf.ed.ac.uk/teaching/courses/dmmr/ Outline

More information

Basic Graph Definitions

Basic 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 information

Lecture 23 Representing Graphs

Lecture 23 Representing Graphs Lecture 23 Representing Graphs 15-122: Principles of Imperative Computation (Fall 2018) Frank Pfenning, André Platzer, Rob Simmons, Penny Anderson, Iliano Cervesato In this lecture we introduce graphs.

More information

Graph Algorithms using Map-Reduce. Graphs are ubiquitous in modern society. Some examples: The hyperlink structure of the web

Graph Algorithms using Map-Reduce. Graphs are ubiquitous in modern society. Some examples: The hyperlink structure of the web Graph Algorithms using Map-Reduce Graphs are ubiquitous in modern society. Some examples: The hyperlink structure of the web Graph Algorithms using Map-Reduce Graphs are ubiquitous in modern society. Some

More information

CS302 - Data Structures using C++

CS302 - 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 information

Konigsberg Bridge Problem

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

Lecture 9 Graph Traversal

Lecture 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 information

GRAPHS, GRAPH MODELS, GRAPH TERMINOLOGY, AND SPECIAL TYPES OF GRAPHS

GRAPHS, GRAPH MODELS, GRAPH TERMINOLOGY, AND SPECIAL TYPES OF GRAPHS GRAPHS, GRAPH MODELS, GRAPH TERMINOLOGY, AND SPECIAL TYPES OF GRAPHS DR. ANDREW SCHWARTZ, PH.D. 10.1 Graphs and Graph Models (1) A graph G = (V, E) consists of V, a nonempty set of vertices (or nodes)

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

Graphs & Digraphs Tuesday, November 06, 2007

Graphs & 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 information

Outline. Introduction. Representations of Graphs Graph Traversals. Applications. Definitions and Basic Terminologies

Outline. 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 information

Graphs: A graph is a data structure that has two types of elements, vertices and edges.

Graphs: A graph is a data structure that has two types of elements, vertices and edges. Graphs: A graph is a data structure that has two types of elements, vertices and edges. An edge is a connection between two vetices If the connection is symmetric (in other words A is connected to B B

More information