Graphs. The ultimate data structure. graphs 1

Size: px
Start display at page:

Download "Graphs. The ultimate data structure. graphs 1"

Transcription

1 Graphs The ultimate data structure graphs 1

2 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 unordered, or may be linked in any order suited to the particular application graphs 2

3 Undirected graphs Simplest form of graph Set of nodes (vertices -- one node is a vertex) and set of links between them (edges) Either or both sets may be empty Each edge connects two vertices; as the name implies, neither vertex is considered to be a point of origin or a point of destination An edge may also connect a vertex to itself graphs 3

4 Example graph v0 e0 v3 e2 v1 e1 v4 e4 v1 v3 v0 e0 e1 e2 e4 v2 v2 This graph has 5 vertices and 4 edges; a graph is defined by which vertices are connected, and which edges connect them v4 This is the same graph, even though its shape is different graphs 4

5 Application: an undirected state graph Each vertex represents the state of some object or situation Each edge represents the possibility of moving directly from one state to another There exists a path from one state to another if there is an edge connecting each vertex and any vertices between them graphs 5

6 Undirected state graph example graphs 6

7 Directed graphs Each edge has an orientation, or direction One vertex connected by the edge is the source, while the other is the target Directed graphs are diagrammed like undirected graphs, except the edges are represented by arrows instead of lines graphs 7

8 Directed graph example Each arrow represents the direction of the edge; to get from point a to point f, you must pass through c, d and b c (in that order), but to get from f to a requires only going through b (by the shortest route) e a d b f graphs 8

9 More graph terminology Loop: an edge that connects a vertex to itself; in the illustration, edge e3 is a loop Multiple edges: two or more edges connecting to vertices in the same direction e4 and e5 are multiple edges e1 and e2 are not Simple graph: a graph with no loops or multiple edges graphs 9

10 Directed graph application examples Route diagrams for airline routes Course pre- and co-requisites Program flow charts Programming language syntax diagrams graphs 10

11 Modeling with graphs - examples Niche overlap graph in ecology: each species represented by vertex undirected edge connects 2 vertices if the species compete Influence graph: each person in group is represented by vertex directed edge from vertex a to vertex b when a has influence on b 11

12 Modeling with graphs - examples Round-robin tournament graph: each team represented by vertex (a,b) is an edge if team a beats team b Precedence graph: vertices represent statements in a computer program directed edge between vertices means 1st statement must be executed before 2nd 12

13 Terms related to undirected graphs Adjacent: 2 vertices u & v in an undirected graph G are adjacent (neighbors) in G if there is an edge {u,v} Incident, connect: if edge e = {u,v}, e is incident with vertices u & v, and e connects u and v Endpoints: vertices u & v are endpoints of edge e 13

14 Terms related to undirected graphs Degree of vertex in an undirected graph is the number of edges incident with it loops count twice degree of vertex v is denoted deg(v) Example: what are the degrees of the vertices in this graph? 14

15 Terms related to undirected graphs Isolated vertex (like e in previous example) has degree 0, not adjacent to any other vertex Pendant vertex (like d in previous example) - adjacent to exactly one vertex The sum of the degrees of all vertices in a graph is exactly twice the number of edges in the graph 15

16 Handshaking Theorem Let G=(V,E) be an undirected graph with e edges; then 2e = deg(v) v V Note that sum of degrees of vertices is always even; this leads to the theorem: An undirected graph has an even number of vertices of odd degree 16

17 Terminology related to directed graphs Let G be a directed graph, with an edge e=(u,v): u is initial vertex v is terminal, or end vertex u is adjacent TO v v is adjacent FROM u initial & terminal vertex of a loop are the same 17

18 Terminology related to digraphs In-degree of vertex v, denoted deg-(v), is the number of edges with v as the terminal vertex Out-degree of vertex v, denoted deg+(v), is the number of edges with v as the initial vertex A loop has one of each 18

19 Terminology related to digraphs The sum of in-degrees is equal to the sum of outdegrees Both are equal to the number of edges in the graph: Let G=(V,E) be a directed graph; then v V deg ( v ) = deg+ ( v) = E v V The undirected graph that results from ignoring arrows in a directed graph is called the underlying undirected graph 19

20 Classes of simple graphs Complete graphs: complete graph on n vertices, denoted Kn, is the simple graph that contains exactly one edge between each pair of distinct vertices; Examples: 20

21 Classes of Simple Graphs Cycle: Cn, where n 3, consists of n vertices v1, v2,, vn and edges {v1, v2}, {v2, v3},, {vn-1, vn} Examples: 21

22 Classes of Simple Graphs Wheel: a cycle with an additional vertex, which is adjacent to all other vertices; example: 22

23 Classes of Simple Graphs n-cube: denoted Qn, is a graph representing the 2n bit strings of length n: 2 vertices are adjacent if and only if the bit strings they represent differ in exactly one position. Examples: 23

24 Bipartite Graphs A simple graph G is called bipartite if its vertex set V can be partitioned into 2 disjoint non-empty sets V1 and V2 such that: every edge connects a vertex in V1 with a vertex in V2 no edge connects 2 vertices in V1 or in V2 24

25 Example: lining up 1st graders Cate Mary Mary Ann Mary Pat Marie John Mark Terry Tim Jimmy 25

26 Example - cycle C6 is bipartite; can partition its vertex set into 2 distinct sets: V1 = {v1, v3, v5) V2 = {v2, v4, v6} with every edge connecting a vertex in V1 with one in V2 26

27 Examples Graph at left is not bipartite; to divide into 2 sets, one set must include 2 vertices and to be bipartite, those vertices must not be connected But every vertex in this graph is connected to 2 others This graph, on the other hand, is bipartite; the two sets are V1 = {v1, v3, v5} and V2 = {v2, v4, v6} Note that the definition doesn t say a vertex in one set can t connect to more than one vertex in the other - only that each in one must connect to one in the other, and no vertex in a set can connect to a vertex in the same set 27

28 Examples: are they bipartite? 28

29 Complete Bipartite Graphs Denoted Km,n is the graph that has its vertex set partitioned into 2 subsets of m vertices and n vertices There is an edge between 2 vertices if and only if one vertex is in the first subset and the other is in the second subset 29

30 Examples 30

31 Applications of Special Types of Graphs: LAN topology A star is a complete bipartite K1,n graph: A ring is an n-cycle: A redundant network may have both a central hub and a ring, forming a wheel: 31

32 Subgraph Graph obtained by removing vertices and their associated edges from a larger graph; more formally: Subgraph of G=(V,E) is H=(W,F) where W V and F E 32

33 Subgraph Example 33

34 Can combine graphs, forming a union Let G1 = (V1, E1) and G2 = (V2, E2) The union, G1 G2 = (V1 V2, E1 E2) 34

35 Graph implementations All of the following representations can be used to create an instance of a directed graph in which loops are allowed: adjacency list adjacency matrix edge lists edge sets incidence matrices graphs 35

36 Representing Graphs Adjacency list: specifies vertices adjacent with each vertex in a simple graph can be used for directed graph as well - list terminal vertices adjacent from each vertex Vertex Adjacent vertices a c,d b e c a,d d a,c,e e d,b 36

37 Adjacency matrix Square grid of true/false values that represent the edges of a graph If the intersection of a row and column has a true value in it, there exists an edge between the vertices represented by the two indexes Since this is a directed graph, the value will be true only if there is an edge from the vertex indicated by the row index to the vertex indicated by the column index graphs 37

38 Adjacency matrix An adjacency matrix can be stored in a twodimensional array of bools or ints Each vertex is represented by one row and one column For a graph with four vertices, the following declaration could be used: boolean [][] amatrix = new boolean [4][4]; graphs 38

39 Adjacency matrix The graph above could be represented by the adjacency matrix on the right row [0] [1] [2] [3] column [0] [1] [2] [3] f t f f f f f t f f f f f t t t graphs 39

40 Representing Graphs: mathematical POV Adjacency matrix: n x n zero-one matrix with 1 representing adjacency, 0 representing non-adjacency Adjacency matrix of a graph is based on chosen ordering of vertices; for a graph with n vertices, there are n! different adjacency matrices Adjacency matrix of graph with few edges is a sparse matrix - many 0s, few 1s 40

41 Simple graph adjacency matrix With ordering a,b,c,d,e:

42 Using adjacency matrices for multigraphs and pseudographs With multiple edges, matrix is no longer zero-one: if more than one edge exists, list the number of edges A loop is represented with a 1 in position i,i Adjacency matrices for simple graphs, including multigraphs and pseudographs, are symmetric 42

43 Adjacency matrices and digraphs For directed graphs, the adjacency matrix has a 1 in its (i,j)th position if there is an edge from vi to vj Directed multigraphs can be represented by placing the number of edges in in position i,j that exist from vi to vj Adjacency matrices for digraphs are not necessarily symmetric 43

44 Edge lists Linked lists are used to represent vertices Each vertex is a linked list; nodes in each list contain numbers indicating the target vertices for that particular source vertex In other words, if list A contains a link to vertex B, there is an edge from A to B graphs 44

45 Edge lists For n vertices, there must be n lists; often the lists are stored as an array of list head references A vertex that is not a source would be represented in the array by a NULL pointer graphs 45

46 Edge lists [0] [1] [2] [3] 1 3 null 1 The graph above could be repesented by the array of edge lists on the right null null 2 3 graphs 46 null

47 Edge Sets Requires a previously programmed implementation of a set ADT Properties of a set: contains an unordered collection of entries each item is unique operations include insertion, deletion, and checking for the presence of a specific item To represent a graph with 4 vertices, can declare an array of 4 sets of ints graphs 47

48 Incidence Matrices In an adjacency matrix, both rows and columns represent vertices In an incidence matrix, rows represent vertices while columns represent edges A 1 in any matrix position means the edge in that column is incident with the vertex in that row Multiple edges are represented identical columns depicting the edges 48

49 Incidence Matrix Example e1 e2 e3 e4 e5 e6 e7 e8 e9 a b c d e

50 Choosing an implementation Adjacency matrix is easier to implement & use than any of the edge-based solutions Frequency of certain operations may dictate another solution graphs 50

51 Choosing an implementation Both adding and removing edges and checking for the presence of a particular edge are O(N) operations in the worst case for edge lists; may be as low as O(logN) for edge sets, depending on representation Edge lists are very efficient for operations that execute one time for each edge with a particular vertex graphs 51

52 Disadvantages of adjacency matrix Operations on all edges for a vertex require stepping through entire row (whether or not an entry is an edge) -- this is O(N) If each vertex has very few edges, an adjacency matrix is mostly wasted space graphs 52

53 Simple graph ADT implementation: labeled graph Operations: constructor add/removeedge size: returns number of vertices in graph isedge: returns true if edge exists between specified source & target clone get/setlabel neighbors: returns array of neighbors of a specified vertex graphs 53

54 Simple graph ADT implementation: labeled graph Data components: 2-dimensional int array representing edges array of vertex labels: each vertex includes data consisting of an informational label graphs 54

55 Labeled graph class definition public class Graph implements Cloneable { private boolean[ ][ ] edges; private Object[ ] labels; public Graph(int n) // n: # of vertices { edges = new boolean[n][n]; // All values initially false labels = new Object[n]; // All values initially null } graphs 55

56 Labeled graph class definition public void addedge(int source, int target) { edges[source][target] = true; } public void removeedge(int source, int target) { edges[source][target] = false; } public boolean isedge(int source, int target) { return edges[source][target]; } graphs 56

57 Labeled graph class definition public Object getlabel(int vertex) { return labels[vertex]; } public void setlabel(int vertex, Object newlabel) { labels[vertex] = newlabel; } public int size( ) { return labels.length; } graphs 57

58 Labeled graph class definition public int[ ] neighbors(int vertex) { int i, count=0; int[ ] answer; // First count how many edges have the vertex as their source for (i = 0; i < labels.length; i++) { if (edges[vertex][i]) count++; } // Allocate the array for the answer answer = new int[count]; graphs 58

59 Labeled graph class definition // Fill the array for the answer count = 0; for (i = 0; i < labels.length; i++) { if (edges[vertex][i]) answer[count++] = i; } return answer; } graphs 59

60 Labeled graph class definition public Object clone( ) { // Clone a Graph object. Graph answer; try { answer = (Graph) super.clone( ); } catch (CloneNotSupportedException e) { // This would indicate an internal error in the Java runtime system // because super.clone always works for an Object. throw new InternalError(e.toString( )); } answer.edges = (boolean [ ][ ]) edges.clone( ); answer.labels = (Object [ ]) labels.clone( ); return answer; } graphs 60

61 Graph traversals Traversal: visiting all nodes in a data structure Can t apply tree traversal methods to graphs, since nodes in a graph don t have the same child/parent relationships Graph traversal methods utilize subsidiary data structures (queues and stacks) to keep track of vertices to be visited graphs2 61

62 Graph traversals Purpose of traversal algorithm: starting at a given vertex, process the information at that vertex, then move along an edge to process a neighbor When traversal is complete, all vertices that can be reached from the start vertex (but not necessarily all vertices in the graph) have been visited graphs2 62

63 Depth-first search After processing the initial vertex, a depth-first search moves along an edge to one of the vertex s neighbors Once the second vertex is processed, the search moves along an edge to one of its neighbors The process continues to move forward as long as vertices can be reached in this manner graphs2 63

64 Depth-first search The search always proceeds forward until no further forward moves can be made Once forward motion is no longer possible at the current node, the search backs up to the previous vertex and visits any previously unvisited neighbors Eventually the search backs up to the original starting node, having visited all nodes that were reachable from this point graphs2 64

65 Depth-first search example v0 v1 v2 v3 v4 v5 graphs2 65

66 Depth-first printing routine public static void depthfirstprint(graph g, int start) { boolean[ ] marked = new boolean [g.size( )]; depthfirstrecurse(g, start, marked); } // The part of a stack is played here by the system stack; // the depthfirstrecurse method stacks up activation records // with each call graphs 66

67 Recursive method for depth-first printing public static void depthfirstrecurse(graph g, int v, boolean[ ] marked) { int[ ] connections = g.neighbors(v); int i, nextneighbor; marked[v] = true; System.out.println(g.getLabel(v)); // Traverse all the neighbors, looking for unmarked vertices: for (i = 0; i < connections.length; i++) { nextneighbor = connections[i]; if (!marked[nextneighbor]) depthfirstrecurse(g, nextneighbor, marked); } } graphs 67

68 Breadth-first search Uses queue to keep track of vertices which might still have unprocessed neighbors Initial vertex is processed, marked, and placed in queue Repeats the following until queue is empty: remove vertex from front of queue for each unmarked neighbor of the current vertex, mark the neighbor, then place the neighbor on the queue graphs2 68

69 Breadth-first search example v0 v2 v4 v2 v0 v1 v4 Queue of visited nodes v1 v2 v3 v4 v5 graphs2 69

70 Graph Isomorphism The simple graphs G1=(V1,E1) and G2=(V2,E2) are isomorphic if there is a one-to-one and onto function f from V1 to V2 with vertices a and b adjacent in G1 if and only if f(a) and f(b) are adjacent in G2 for all vertices a and b in G1 Function f is called an isomorphism 70

71 Determining Isomorphism The number of vertices, number of edges, and degrees of the vertices are invariants under isomorphism If any of these quantities differ in two simple graphs, the graphs are not isomorphic If these quantities are the same, the graphs may or may not be isomorphic 71

72 Determining Isomorphism To show that a function f from the vertex set of graph G to the vertex set of graph H is an isomorphism, we need to show that f preserves edges Adjacency matrices can help with this: we can show that the adjacency matrix of G is the same as the adjacency matrix of H when rows and columns are arranged according to f 72

73 Example Consider the two graphs below: Both have six vertices and seven edges; Both have four vertices of degree 2 and two vertices of degree 3; The subgraphs of G and H consisting of vertices of degree 2 and the edges connecting them are isomorphic 73

74 Example continued Need to define a function f and then determine whether or not it is an isomorphism: deg(u1) in G is 2; u1 is not adjacent to any other degree 2 vertex, so the image of u1 must be either v4 or v6 in H can arbitrarily set f(u1) = v6 (if that doesn t work, we can try v4) 74

75 Example continued Continuing definition of f: Since u2 is adjacent to u1, the possible images of u2 are v3 and v5 We set f(u2) = v3 (again, arbitrarily) Continuing in this fashion, using adjacency and degree of vertices as guides, we derive f for all vertices in G, as shown on next slide 75

76 Example continued f(u1) = v6 f(u2) = v3 f(u3) = v4 f(u4) = v5 f(u5) = v1 f(u6) = v2 Next, we set up adjacency matrices for G and H, arranging the matrix for H so that the images of G s vertices line up with their corresponding vertices 76

77 Example continued u1 u2 u3 u4 u5 u6 u u u u u u AG v6 v3 v4 v5 v1 v2 v v v v v v AH 77

78 Example concluded Since AG = AH, it follows that f preserves edges, and we conclude that f is an isomorphism; thus G and H are isomorphic If f were not an isomorphism, we would not have proved that G and H are not isomorphic, since another function might show isomorphism 78

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. 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. 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. Introduction To Graphs: Exercises. Definitions:

Graphs. Introduction To Graphs: Exercises. Definitions: Graphs Eng.Jehad Aldahdooh Introduction To Graphs: Definitions: A graph G = (V, E) consists of V, a nonempty set of vertices (or nodes) and E, a set of edges. Each edge has either one or two vertices associated

More information

CHAPTER 2. Graphs. 1. Introduction to Graphs and Graph Isomorphism

CHAPTER 2. Graphs. 1. Introduction to Graphs and Graph Isomorphism CHAPTER 2 Graphs 1. Introduction to Graphs and Graph Isomorphism 1.1. The Graph Menagerie. Definition 1.1.1. A simple graph G = (V, E) consists of a set V of vertices and a set E of edges, represented

More information

Foundations of Discrete Mathematics

Foundations of Discrete Mathematics Foundations of Discrete Mathematics Chapters 9 By Dr. Dalia M. Gil, Ph.D. Graphs Graphs are discrete structures consisting of vertices and edges that connect these vertices. Graphs A graph is a pair (V,

More information

CPCS Discrete Structures 1

CPCS Discrete Structures 1 Let us switch to a new topic: Graphs CPCS 222 - Discrete Structures 1 Introduction to Graphs Definition: A simple graph G = (V, E) consists of V, a nonempty set of vertices, and E, a set of unordered pairs

More information

Graphs. Pseudograph: multiple edges and loops allowed

Graphs. Pseudograph: multiple edges and loops allowed Graphs G = (V, E) V - set of vertices, E - set of edges Undirected graphs Simple graph: V - nonempty set of vertices, E - set of unordered pairs of distinct vertices (no multiple edges or loops) Multigraph:

More information

Varying Applications (examples)

Varying Applications (examples) Graph Theory Varying Applications (examples) Computer networks Distinguish between two chemical compounds with the same molecular formula but different structures Solve shortest path problems between cities

More information

Elements of Graph Theory

Elements of Graph Theory Elements of Graph Theory Quick review of Chapters 9.1 9.5, 9.7 (studied in Mt1348/2008) = all basic concepts must be known New topics we will mostly skip shortest paths (Chapter 9.6), as that was covered

More information

CS 311 Discrete Math for Computer Science Dr. William C. Bulko. Graphs

CS 311 Discrete Math for Computer Science Dr. William C. Bulko. Graphs CS 311 Discrete Math for Computer Science Dr. William C. Bulko Graphs 2014 Definitions Definition: A graph G = (V,E) consists of a nonempty set V of vertices (or nodes) and a set E of edges. Each edge

More information

(5.2) 151 Math Exercises. Graph Terminology and Special Types of Graphs. Malek Zein AL-Abidin

(5.2) 151 Math Exercises. Graph Terminology and Special Types of Graphs. Malek Zein AL-Abidin King Saud University College of Science Department of Mathematics 151 Math Exercises (5.2) Graph Terminology and Special Types of Graphs Malek Zein AL-Abidin ه Basic Terminology First, we give some terminology

More information

Introduction III. Graphs. Motivations I. Introduction IV

Introduction III. Graphs. Motivations I. Introduction IV Introduction I Graphs Computer Science & Engineering 235: Discrete Mathematics Christopher M. Bourke cbourke@cse.unl.edu Graph theory was introduced in the 18th century by Leonhard Euler via the Königsberg

More information

DEFINITION OF GRAPH GRAPH THEORY GRAPHS ACCORDING TO THEIR VERTICES AND EDGES EXAMPLE GRAPHS ACCORDING TO THEIR VERTICES AND EDGES

DEFINITION OF GRAPH GRAPH THEORY GRAPHS ACCORDING TO THEIR VERTICES AND EDGES EXAMPLE GRAPHS ACCORDING TO THEIR VERTICES AND EDGES DEFINITION OF GRAPH GRAPH THEORY Prepared by Engr. JP Timola Reference: Discrete Math by Kenneth H. Rosen A graph G = (V,E) consists of V, a nonempty set of vertices (or nodes) and E, a set of edges. Each

More information

CS200: Graphs. Prichard Ch. 14 Rosen Ch. 10. CS200 - Graphs 1

CS200: Graphs. Prichard Ch. 14 Rosen Ch. 10. CS200 - Graphs 1 CS200: Graphs Prichard Ch. 14 Rosen Ch. 10 CS200 - Graphs 1 Graphs A collection of nodes and edges What can this represent? n A computer network n Abstraction of a map n Social network CS200 - Graphs 2

More information

Discrete Structures CISC 2315 FALL Graphs & Trees

Discrete Structures CISC 2315 FALL Graphs & Trees Discrete Structures CISC 2315 FALL 2010 Graphs & Trees Graphs A graph is a discrete structure, with discrete components Components of a Graph edge vertex (node) Vertices A graph G = (V, E), where V is

More information

Section 8.2 Graph Terminology. Undirected Graphs. Definition: Two vertices u, v in V are adjacent or neighbors if there is an edge e between u and v.

Section 8.2 Graph Terminology. Undirected Graphs. Definition: Two vertices u, v in V are adjacent or neighbors if there is an edge e between u and v. Section 8.2 Graph Terminology Undirected Graphs Definition: Two vertices u, v in V are adjacent or neighbors if there is an edge e between u and v. The edge e connects u and v. The vertices u and v are

More information

Discrete Mathematics (2009 Spring) Graphs (Chapter 9, 5 hours)

Discrete Mathematics (2009 Spring) Graphs (Chapter 9, 5 hours) Discrete Mathematics (2009 Spring) Graphs (Chapter 9, 5 hours) Chih-Wei Yi Dept. of Computer Science National Chiao Tung University June 1, 2009 9.1 Graphs and Graph Models What are Graphs? General meaning

More information

CMSC 380. Graph Terminology and Representation

CMSC 380. Graph Terminology and Representation CMSC 380 Graph Terminology and Representation GRAPH BASICS 2 Basic Graph Definitions n A graph G = (V,E) consists of a finite set of vertices, V, and a finite set of edges, E. n Each edge is a pair (v,w)

More information

Graph Theory. Part of Texas Counties.

Graph Theory. Part of Texas Counties. Graph Theory Part of Texas Counties. We would like to visit each of the above counties, crossing each county only once, starting from Harris county. Is this possible? This problem can be modeled as a graph.

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

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

1. a graph G = (V (G), E(G)) consists of a set V (G) of vertices, and a set E(G) of edges (edges are pairs of elements of V (G))

1. a graph G = (V (G), E(G)) consists of a set V (G) of vertices, and a set E(G) of edges (edges are pairs of elements of V (G)) 10 Graphs 10.1 Graphs and Graph Models 1. a graph G = (V (G), E(G)) consists of a set V (G) of vertices, and a set E(G) of edges (edges are pairs of elements of V (G)) 2. an edge is present, say e = {u,

More information

Basics of Graph Theory

Basics of Graph Theory Basics of Graph Theory 1 Basic notions A simple graph G = (V, E) consists of V, a nonempty set of vertices, and E, a set of unordered pairs of distinct elements of V called edges. Simple graphs have their

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

Introduction to Graphs

Introduction to Graphs Graphs Introduction to Graphs Graph Terminology Directed Graphs Special Graphs Graph Coloring Representing Graphs Connected Graphs Connected Component Reading (Epp s textbook) 10.1-10.3 1 Introduction

More information

UNIT Name the different ways of representing a graph? a.adjacencymatrix b. Adjacency list

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

v V Question: How many edges are there in a graph with 10 vertices each of degree 6?

v V Question: How many edges are there in a graph with 10 vertices each of degree 6? ECS20 Handout Graphs and Trees March 4, 2015 (updated 3/9) Notion of a graph 1. A graph G = (V,E) consists of V, a nonempty set of vertices (or nodes) and E, a set of pairs of elements of V called edges.

More information

CS 441 Discrete Mathematics for CS Lecture 26. Graphs. CS 441 Discrete mathematics for CS. Final exam

CS 441 Discrete Mathematics for CS Lecture 26. Graphs. CS 441 Discrete mathematics for CS. Final exam CS 441 Discrete Mathematics for CS Lecture 26 Graphs Milos Hauskrecht milos@cs.pitt.edu 5329 Sennott Square Final exam Saturday, April 26, 2014 at 10:00-11:50am The same classroom as lectures The exam

More information

An Introduction to Graph Theory

An Introduction to Graph Theory An Introduction to Graph Theory CIS008-2 Logic and Foundations of Mathematics David Goodwin david.goodwin@perisic.com 12:00, Friday 17 th February 2012 Outline 1 Graphs 2 Paths and cycles 3 Graphs and

More information

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. An Introduction to Graph Theory

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. An Introduction to Graph Theory SCHOOL OF ENGINEERING & BUILT ENVIRONMENT Mathematics An Introduction to Graph Theory. Introduction. Definitions.. Vertices and Edges... The Handshaking Lemma.. Connected Graphs... Cut-Points and Bridges.

More information

UNIT 5 GRAPH. Application of Graph Structure in real world:- Graph Terminologies:

UNIT 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 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

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

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

A good picture is worth a thousand words

A good picture is worth a thousand words A good picture is worth a thousand words VCU, Department of Computer Science CMSC 3 Graphs Vojislav Kecman Expressive power is the first explanation for a success of graphs More claims for graphs come

More information

Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees

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

More information

Adjacent: Two distinct vertices u, v are adjacent if there is an edge with ends u, v. In this case we let uv denote such an edge.

Adjacent: Two distinct vertices u, v are adjacent if there is an edge with ends u, v. In this case we let uv denote such an edge. 1 Graph Basics What is a graph? Graph: a graph G consists of a set of vertices, denoted V (G), a set of edges, denoted E(G), and a relation called incidence so that each edge is incident with either one

More information

Logic: The Big Picture. Axiomatizing Arithmetic. Tautologies and Valid Arguments. Graphs and Trees

Logic: The Big Picture. Axiomatizing Arithmetic. Tautologies and Valid Arguments. Graphs and Trees Axiomatizing Arithmetic Logic: The Big Picture Suppose we restrict the domain to the natural numbers, and allow only the standard symbols of arithmetic (+,, =, >, 0, 1). Typical true formulas include:

More information

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

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

More information

Characterizing Graphs (3) Characterizing Graphs (1) Characterizing Graphs (2) Characterizing Graphs (4)

Characterizing Graphs (3) Characterizing Graphs (1) Characterizing Graphs (2) Characterizing Graphs (4) S-72.2420/T-79.5203 Basic Concepts 1 S-72.2420/T-79.5203 Basic Concepts 3 Characterizing Graphs (1) Characterizing Graphs (3) Characterizing a class G by a condition P means proving the equivalence G G

More information

context. (Similarly, we write ν for ν(g), etc. if there is no risk of confusion.) For a subset A V we write N G (A) = {v V ( w A)(v w)} (the set of

context. (Similarly, we write ν for ν(g), etc. if there is no risk of confusion.) For a subset A V we write N G (A) = {v V ( w A)(v w)} (the set of Graph Theory CMSC-27500 Spring 2015 http://people.cs.uchicago.edu/ laci/15graphs Homework set #4. First batch posted 4-9, 8am, updated 10:20am. Problems 4.16 4.31 added at 11:30pm. Due Tuesday, April 14

More information

Review: Graph Theory and Representation

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

More information

Graphs and trees come up everywhere. We can view the internet as a graph (in many ways) Web search views web pages as a graph

Graphs and trees come up everywhere. We can view the internet as a graph (in many ways) Web search views web pages as a graph Graphs and Trees Graphs and trees come up everywhere. We can view the internet as a graph (in many ways) who is connected to whom Web search views web pages as a graph Who points to whom Niche graphs (Ecology):

More information

MTL 776: Graph Algorithms. B S Panda MZ 194

MTL 776: Graph Algorithms. B S Panda MZ 194 MTL 776: Graph Algorithms B S Panda MZ 194 bspanda@maths.iitd.ac.in bspanda1@gmail.com Lectre-1: Plan Definitions Types Terminology Sb-graphs Special types of Graphs Representations Graph Isomorphism Definitions

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

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

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

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

Ordinary Differential Equation (ODE)

Ordinary Differential Equation (ODE) Ordinary Differential Equation (ODE) INTRODUCTION: Ordinary Differential Equations play an important role in different branches of science and technology In the practical field of application problems

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

Graph and Digraph Glossary

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

Graphs. Graph Structures

Graphs. Graph Structures Graphs A graph G consists of a set V of vertices and a set E of pairs of distinct vertices from V. These pairs of vertices are called edges. If the pairs of vertices are unordered, G is an undirected graph.

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

Graph Theory S 1 I 2 I 1 S 2 I 1 I 2

Graph Theory S 1 I 2 I 1 S 2 I 1 I 2 Graph Theory S I I S S I I S Graphs Definition A graph G is a pair consisting of a vertex set V (G), and an edge set E(G) ( ) V (G). x and y are the endpoints of edge e = {x, y}. They are called adjacent

More information

Math 776 Graph Theory Lecture Note 1 Basic concepts

Math 776 Graph Theory Lecture Note 1 Basic concepts Math 776 Graph Theory Lecture Note 1 Basic concepts Lectured by Lincoln Lu Transcribed by Lincoln Lu Graph theory was founded by the great Swiss mathematician Leonhard Euler (1707-178) after he solved

More information

MATH 363 Final Wednesday, April 28. Final exam. You may use lemmas and theorems that were proven in class and on assignments unless stated otherwise.

MATH 363 Final Wednesday, April 28. Final exam. You may use lemmas and theorems that were proven in class and on assignments unless stated otherwise. Final exam This is a closed book exam. No calculators are allowed. Unless stated otherwise, justify all your steps. You may use lemmas and theorems that were proven in class and on assignments unless stated

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

GRAPHS Lecture 19 CS2110 Spring 2013

GRAPHS Lecture 19 CS2110 Spring 2013 GRAPHS Lecture 19 CS2110 Spring 2013 Announcements 2 Prelim 2: Two and a half weeks from now Tuesday, April16, 7:30-9pm, Statler Exam conflicts? We need to hear about them and can arrange a makeup It would

More information

Introduction to Graph Theory

Introduction to Graph Theory Introduction to Graph Theory Tandy Warnow January 20, 2017 Graphs Tandy Warnow Graphs A graph G = (V, E) is an object that contains a vertex set V and an edge set E. We also write V (G) to denote the vertex

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

Graph Theory. ICT Theory Excerpt from various sources by Robert Pergl

Graph Theory. ICT Theory Excerpt from various sources by Robert Pergl Graph Theory ICT Theory Excerpt from various sources by Robert Pergl What can graphs model? Cost of wiring electronic components together. Shortest route between two cities. Finding the shortest distance

More information

Definition of Graphs and Trees. Representation of Trees.

Definition of Graphs and Trees. Representation of Trees. Definition of Graphs and Trees. Representation of Trees. Chapter 6 Definition of graphs (I) A directed graph or digraph is a pair G = (V,E) s.t.: V is a finite set called the set of vertices of G. E V

More information

March 20/2003 Jayakanth Srinivasan,

March 20/2003 Jayakanth Srinivasan, Definition : A simple graph G = (V, E) consists of V, a nonempty set of vertices, and E, a set of unordered pairs of distinct elements of V called edges. Definition : In a multigraph G = (V, E) two or

More information

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

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

More information

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

Math 170- Graph Theory Notes

Math 170- Graph Theory Notes 1 Math 170- Graph Theory Notes Michael Levet December 3, 2018 Notation: Let n be a positive integer. Denote [n] to be the set {1, 2,..., n}. So for example, [3] = {1, 2, 3}. To quote Bud Brown, Graph theory

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

Graph theory. Po-Shen Loh. June We begin by collecting some basic facts which can be proved via bare-hands techniques.

Graph theory. Po-Shen Loh. June We begin by collecting some basic facts which can be proved via bare-hands techniques. Graph theory Po-Shen Loh June 013 1 Basic results We begin by collecting some basic facts which can be proved via bare-hands techniques. 1. The sum of all of the degrees is equal to twice the number of

More information

Math 778S Spectral Graph Theory Handout #2: Basic graph theory

Math 778S Spectral Graph Theory Handout #2: Basic graph theory Math 778S Spectral Graph Theory Handout #: Basic graph theory Graph theory was founded by the great Swiss mathematician Leonhard Euler (1707-178) after he solved the Königsberg Bridge problem: Is it possible

More information

Information Science 2

Information Science 2 Information Science 2 - Applica(ons of Basic ata Structures- Week 03 College of Information Science and Engineering Ritsumeikan University Agenda l Week 02 review l Introduction to Graph Theory - Basic

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 Notes. char myarray [ ] = {0, 0, 0, 0, 0 } ; The memory diagram associated with the array can be drawn like this

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

Trees. Arash Rafiey. 20 October, 2015

Trees. Arash Rafiey. 20 October, 2015 20 October, 2015 Definition Let G = (V, E) be a loop-free undirected graph. G is called a tree if G is connected and contains no cycle. Definition Let G = (V, E) be a loop-free undirected graph. G is called

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

Paths. Path is a sequence of edges that begins at a vertex of a graph and travels from vertex to vertex along edges of the graph.

Paths. Path is a sequence of edges that begins at a vertex of a graph and travels from vertex to vertex along edges of the graph. Paths Path is a sequence of edges that begins at a vertex of a graph and travels from vertex to vertex along edges of the graph. Formal Definition of a Path (Undirected) Let n be a nonnegative integer

More information

1 Digraphs. Definition 1

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

The 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 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 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

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

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

Lecture 5: Graphs. Rajat Mittal. IIT Kanpur

Lecture 5: Graphs. Rajat Mittal. IIT Kanpur Lecture : Graphs Rajat Mittal IIT Kanpur Combinatorial graphs provide a natural way to model connections between different objects. They are very useful in depicting communication networks, social networks

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

Unit #9: Graphs. CPSC 221: Algorithms and Data Structures. Will Evans 2012W1

Unit #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 information

MAT 7003 : Mathematical Foundations. (for Software Engineering) J Paul Gibson, A207.

MAT 7003 : Mathematical Foundations. (for Software Engineering) J Paul Gibson, A207. MAT 7003 : Mathematical Foundations (for Software Engineering) J Paul Gibson, A207 paul.gibson@it-sudparis.eu http://www-public.it-sudparis.eu/~gibson/teaching/mat7003/ Graphs and Trees http://www-public.it-sudparis.eu/~gibson/teaching/mat7003/l2-graphsandtrees.pdf

More information

Data Structure. IBPS SO (IT- Officer) Exam 2017

Data 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 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

Graph Theory CS/Math231 Discrete Mathematics Spring2015

Graph Theory CS/Math231 Discrete Mathematics Spring2015 1 Graphs Definition 1 A directed graph (or digraph) G is a pair (V, E), where V is a finite set and E is a binary relation on V. The set V is called the vertex set of G, and its elements are called vertices

More information

CHAPTER 10 Graphs. 258 Chapter 10 Graphs

CHAPTER 10 Graphs. 258 Chapter 10 Graphs 258 Chapter 10 Graphs SECTION 10.1 Graphs and Graph Models CHAPTER 10 Graphs 2. a) A simple graph would be the model here, since there are no parallel edges or loops, and the edges are undirected. b) A

More information

Discrete Mathematics

Discrete Mathematics Discrete Mathematics Lecturer: Mgr. Tereza Kovářová, Ph.D. tereza.kovarova@vsb.cz Guarantor: doc. Mgr. Petr Kovář, Ph.D. Department of Applied Mathematics, VŠB Technical University of Ostrava About this

More information

22 Elementary Graph Algorithms. There are two standard ways to represent a

22 Elementary Graph Algorithms. There are two standard ways to represent a VI Graph Algorithms Elementary Graph Algorithms Minimum Spanning Trees Single-Source Shortest Paths All-Pairs Shortest Paths 22 Elementary Graph Algorithms There are two standard ways to represent a graph

More information

Number Theory and Graph Theory

Number Theory and Graph Theory 1 Number Theory and Graph Theory Chapter 6 Basic concepts and definitions of graph theory By A. Satyanarayana Reddy Department of Mathematics Shiv Nadar University Uttar Pradesh, India E-mail: satya8118@gmail.com

More information

0.0.1 Network Analysis

0.0.1 Network Analysis Graph Theory 0.0.1 Network Analysis Prototype Example: In Algonquian Park the rangers have set up snowmobile trails with various stops along the way. The system of trails is our Network. The main entrance

More information

Assignment 4 Solutions of graph problems

Assignment 4 Solutions of graph problems Assignment 4 Solutions of graph problems 1. Let us assume that G is not a cycle. Consider the maximal path in the graph. Let the end points of the path be denoted as v 1, v k respectively. If either of

More information

A graph is finite if its vertex set and edge set are finite. We call a graph with just one vertex trivial and all other graphs nontrivial.

A graph is finite if its vertex set and edge set are finite. We call a graph with just one vertex trivial and all other graphs nontrivial. 2301-670 Graph theory 1.1 What is a graph? 1 st semester 2550 1 1.1. What is a graph? 1.1.2. Definition. A graph G is a triple (V(G), E(G), ψ G ) consisting of V(G) of vertices, a set E(G), disjoint from

More information

Decreasing a key FIB-HEAP-DECREASE-KEY(,, ) 3.. NIL. 2. error new key is greater than current key 6. CASCADING-CUT(, )

Decreasing a key FIB-HEAP-DECREASE-KEY(,, ) 3.. NIL. 2. error new key is greater than current key 6. CASCADING-CUT(, ) Decreasing a key FIB-HEAP-DECREASE-KEY(,, ) 1. if >. 2. error new key is greater than current key 3.. 4.. 5. if NIL and.

More information

Graphs II: Trailblazing

Graphs II: Trailblazing Graphs II: Trailblazing Paths In an undirected graph, a path of length n from u to v, where n is a positive integer, is a sequence of edges e 1,, e n of the graph such that f(e 1 )={x 0,x 1 }, f(e 2 )={x

More information

Discrete mathematics II. - Graphs

Discrete mathematics II. - Graphs Emil Vatai April 25, 2018 Basic definitions Definition of an undirected graph Definition (Undirected graph) An undirected graph or (just) a graph is a triplet G = (ϕ, E, V ), where V is the set of vertices,

More information

UNIT IV -NON-LINEAR DATA STRUCTURES 4.1 Trees 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 T1,

More information

Outline. Graphs. Divide and Conquer.

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