Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Graphs Theory UNIT IV. 2Contents  Basic terminology,  Multi graphs and weighted graphs  Paths and circuits  Shortest path in weighted graph  Hamiltonian.

Similar presentations


Presentation on theme: "1 Graphs Theory UNIT IV. 2Contents  Basic terminology,  Multi graphs and weighted graphs  Paths and circuits  Shortest path in weighted graph  Hamiltonian."— Presentation transcript:

1 1 Graphs Theory UNIT IV

2 2Contents  Basic terminology,  Multi graphs and weighted graphs  Paths and circuits  Shortest path in weighted graph  Hamiltonian and Euler paths and circuits  Planer graph  Travelling salesman problem.

3 3 Introduction to Graphs Definition: A graph is collection of points called vertices & collection of lines called edges each of which joins either a pair of points or single points to itself. Mathematically graph G is an ordered pair of (V, E) Each edge e ij is associated with an ordered pair of vertices (V i,V j ).

4 4 Introduction to Graphs For Example, In Fig. G has graph 4 vertices namely v1, v2, v3, v4& 7 edges Namely e1, e2, e3, e4, e5, e6, e7 Then e1=(v1, v2) Similarly for other edges. In short, we can represent G=(V,E) where V=(v1, v2, v3, v4) & E=(e1, e2, e3, e4, e5, e6,e7 ) v1v2 v3 v4 e1 e2 e4 e5 e3 e6 e7 Graph G

5 5 Self Loops & Parallel Edges Definition: If the end vertices V i & V j of any edge e ij are same, then edge eij called as Self Loop. For Example, In graph G, the edge e 6 =(v 3, v 3 ) is self loop. Definition: If there are more than one edge is associated with given pair of vertices then those edge called as Parallel or Multiple edge. For Example, In graph G, e 4 & e 7 has (v 3, v 4 ) are called as Parallel edge.

6 6 Simple & Multiple Graphs Definition: A graph that has neither self loops or parallel edge is called as Simple Graph otherwise it is called as Multiple Graph. For Example, G1 (Simple Graph ) G2 (Multiple Graph) G1 (Simple Graph ) G2 (Multiple Graph)

7 7 Weighted Graph Definition: If each edge or each vertex or both are associated with some +ve no. then the graph is called as Weighted Graph For Example, V1 V2 V4 V3 1.4 1.5 1.7 6

8 8 Finite & Infinite Graph Definition: A graph is Finite no. of vertices as well as finite no. of edges called as Finite Graph otherwise it is Infinite Graph. For Example, The graph G1 & G2 is Finite Graph. Definition: A graph G=(V,E) is called as Labeled Graph if its edges are labeled with some names or data. For Example, Graph G is labeled graph.

9 9 Adjacency & Incidence Definition: Two vertices v 1 & v 2 vertices of G joins directly by at least one edge then there vertices called Adjacent Vertices. For Example, In Graph G, v 1 & v 2 are adjacent vertices. Definition: If V i is end vertex of edge e ij =(v i,v j ) then edge e ij is said to be Incident on v i. Similarly e ij is said to be Incident on v j. For Example, In Graph G, e 1 is incident on v 1 & v 2.

10 10 Degree of a Vertex Definition: The no. of edges incident on a vertex v i with self loop counted twice is called as degree of vertex vi. For Example, Consider the Graph G, d(v 1 )=3,d(v 2 )=2,d(v 3 )=5,d(v 4 )= 4 Definition : A vertex with degree zero is called as Isolated Vertex & A vertex with degree one is called as Pendant Vertex. v1v2 v3 v4 e1 e2 e4 e5 e3 e6 e7

11 11 Handshaking Lemma Theorem: The graph G with e no. of edges & n no. of vertices, since each edge contributes two degree, the sum of the degrees of all vertices in G is twice no. of edges in G. i.e.  d(v i )=2e is called as Handshaking Lemma. Example: How many edges are there in a graph with 10 vertices, each of degree 6? Solution: The sum of the degrees of the vertices is 6*10 = 60. According to the Handshaking Theorem, it follows that 2e = 60, so there are 30 edges. n i=1

12 12 Matrix Representation of Graphs A graph can also be represented by matrix. Two ways are used for matrix representation of graph are given as follows, 1.Adjacent Matrix 2.Incident Matrix Lets see one by one…

13 13 1. Adjacent Matrix The A.M. of Graph G with n vertices & no parallel edges is a symmetric binary matrix A(G)=[a ij ] or order n*n where, a ij =1, if there is as edge between vi &vj. a ij =0, if v i & v j are not adjacent. A self loop at vertex vi corresponds to a ij =1. For Example, A(G)= A(G)=

14 14 1. Adjacent Matrix The A.M. of multigraph G with n vertices is an n*n matrix A(G)=[a ij ] where, a ij =N, if there one or more edge are there between v i &v j & N is no. of edges between v i & v j. a ij =0, otherwise. For Example, A(G)= A(G)=

15 15 2. Incident Matrix Given a graph G with n vertices, e edges & no self loops. The incidence matrix x(G)=[X ij ] of the other graph G is an n*e matrix where, X ij =1, if j th edge e j is incident on i th vertex v i, X ij =0, otherwise. Here n vertices are rows & e edges are columns. X(G)= X(G)=

16 16 Directed Graph or Diagraph Definition: If each edge of the graph G has a direction then graph called as diagraph. In a graph with directed edges, the in-degree of a vertex v, denoted by deg - (v) & out-degree of v, denoted by deg + (v). See the example in Next page….

17 17 Directed Graph or Diagraph Example: What are the in-degrees and out- degrees of the vertices a, b, c, d in this graph: ab cd deg - (a) = 1 deg + (a) = 2 deg - (b) = 4 deg + (b) = 2 deg - (d) = 2 deg + (d) = 1 deg - (c) = 0 deg + (c) = 2

18 18 Adjacency Matrix of a diagraph It is defined in similar fashion as it defined for undirected graph. For Example, A(D)= A(D)=

19 19 Incident matrix of diagraph Given a graph G with n, e & no self loops is matrix x(G)=[X ij ] or order n*e where n vertices are rows & e edges are columns such that, X ij =1, if jth edge e j is incident out i th vertex v i X ij =-1, if jth edge e j is incident into i th vertex v i X ij =0, if jth edge e j not incident on i th vertex v i.

20 20 Null Graph Definition: If the edge set of any graph with n vertices is an empty set, then the graph is known as null graph. It is denoted by N n For Example, N 3 N 4

21 21 Complete Graph Definition: Let G be simple graph on n vertices. If the degree of each vertex is (n-1) then the graph is called as complete graph. Complete graph on n vertices, it is denoted by K n. In complete graph K n, the number of edges are n(n-1)/2 For example, K1K1K1K1 K2K2K2K2 K3K3K3K3 K4K4K4K4 K5K5K5K5

22 22 Regular Graph Definition: If the degree of each vertex is same say ‘r’ in any graph G then the graph is said to be a regular graph of degree r. For example, K3K3K3K3 K4K4K4K4 K5K5K5K5

23 23 Bipartite Graph Definition: The graph is called as bipartite graph, if its vertex set V can be partitioned into two distinct subset say V1 & V2. such that V1 U V2=V & V1  V2 =  & also each edge of G joins a vertex of V1 to vertex of V2. A graph can not have self loop.

24 24 Bipartite Graphs Example I: Is G1 bipartite? v1v1v1v1 v2v2v2v2 v3v3v3v3 No, because there is no way to partition the vertices into two sets so that there are no edges with both endpoints in the same set. Example II: Is G2 bipartite? v5v5v5v5 v1v1v1v1 v2v2v2v2 v3v3v3v3 v4v4v4v4 v6v6v6v6 v1v1v1v1 v6v6v6v6 v2v2v2v2 v5v5v5v5 v3v3v3v3 v4v4v4v4 Yes, because we can display G2 like this:

25 25 Complete Bipartite Graphs Definition: A graph is called as complete bipartite graph if each vertex of V1 is joined to every vertex of V2 by an unique edge. It is denoted by K m,n if no. of vertices in V1 is m & that in V2 in n. K 3,2 K 3,4

26 26 Linked representation of graphs The above adjacency can be represented by, G=[a:b, c, d; b:a, d; c:a, d; d:a, b, c] This is link representation of the graph G. ab c d a, d b c a, b, c d b, c, d a Adjacent Vertices Vertex

27 27Isomorphism Definition: Two graphs are thought of as equivalent (called isomorphic) if they have identical behavior in terms of graph theoretic properties. Two graphs G(V, E) & G’(V’,E’) are said to be isomorphic to each other if there is one-one correspondence between their vertices & between their edges such that incidence relationship in preserved. It is denoted by G1=G2

28 28Isomorphism For Example, 1 2 a b 1 2 a b 4 3 d c 4 3 d c It is immediately apparent by definition of isomorphism that two isomorphic graphs must have, the same number of vertices, the same number of vertices, the same number of edges, and the same number of edges, and the same degrees of vertices. the same degrees of vertices. b2 d3 c4a1

29 29 Sub Graph Definition: A sub graph of a graph G = (V, E) is a graph G’ = (V’, E’) where V’  V and E’  E. For Example: G G1 G2 G G1 G2

30 30 Null Sub Graph Definition: A subgraph is called as null sub graph if its vertex set is same as vertex set of G & its edge set is empty set. i.e. it does not contain any edges. For Example: G Null Subgraph G Null Subgraph

31 31 Spanning Graph Definition: Let G=(V, E) be any graph. Then G’ is said to be the spanning subgraph of the graph G if its vertex set V’ is equal to vertex set V of G. For Example: G G1 G2 G G1 G2

32 32 Complement of a Graph Definition: Let G is a simple graph. Then complement of G denoted by ~G is graph whose vertex set is same as vertex set of G & in which two vertices are adjacent if & only if they are not adjacent in G. For Example: G ~G H ~H G ~G H ~H

33 33 Operations on Graphs Definition: The union of two simple graphs G 1 = (V 1, E 1 ) and G 2 = (V 2, E 2 ) is the simple graph with vertex set V 1  V 2 and edge set E 1  E 2. The union of G 1 and G 2 is denoted by G 1  G 2. G1G1G1G1 G2G2G2G2 G 1  G 2 G 1  G 2

34 34 Operations on Graphs Definition: The Intersection of two simple graphs G 1 =(V 1, E 1 ) and G 2 = (V 2, E 2 ) is the simple graph with vertex set V 1  V 2 and edge set E 1  E 2. The Intersection of G 1 and G 2 is denoted by G 1  G 2. G1G1G1G1 G2G2G2G2 G 1  G 2 G 1  G 2

35 35 Operations on Graphs Definition: The Ring Sum of two graphs G 1 =(V 1, E 1 ) and G 2 = (V 2, E 2 ) is the simple graph with vertex set V 1  V 2 and edges that either in G1 or G2 but not in both. The Ring Sum of G 1 and G 2 is denoted by G 1 ⊕ G 2. G1G1G1G1 G2G2G2G2 G 1 ⊕ G 2 G 1 ⊕ G 2

36 36 Operations on Graphs Definition: The Removal of vertex of graph G =(V, E). Let v ∈ V, then graph (G-v) can be obtained by removing vertex v from the graph. Definition: The Removal of an edge of graph G =(V, E). Let e ∈ E, then graph (G-e) can be obtained by removing edge e from the graph G G-e G-e G-v G-v v e v

37 37Paths Definition: Path in a graph is a sequence of vertices such that from each of its vertices there is an edge to the next vertex in the sequence. Definition: Path P of length n from v 0 to v n is a sequence of vertices & edges of form (v 0,e 1,v 1,e 2,….,e n, v n ) where each e j is an edge between v j-1 & v j. The vertices v 0 & v n are called end points of path & the other vertices v 1 …., v n-1 are called its interior vertices. See the example in next page……

38 38Paths For Example, Path I : v 1 e 2 v 2 e 4 v 4 Path II: v 4 e 4 v 2 e 2 v 1 e 1 v 2 e 3 v 3 Path III: v 3 e 3 v 2 e 2 v 1 e 1 v 2 e 3 v 3

39 39 Types of Paths 1. Simple Path: 1. Simple Path: A path in a graph G is called as simple path if the edges do not repeat in the path. In Fig. path I & path II are simple graph but path III is not. 2. Elementary Path: A path is said to be elementary path if vertices do not repeat in the path. In Fig. path I is an elementary path but path II is not.

40 40Circuits Definition: The path is called as circuit, if end vertices of the path is same. The circuit is denoted by letter ‘C’. For Example, In Fig. C 1 =(v 1, e 1, v 2, e 2, v 1 ) & C 2 =( V 3, e 4, v 1, e 1, v 2, e 3, v 3 ) are the circuits

41 41 Types of Circuits 1. Simple Circuit: A circuit in the graph G is said to be a simple circuit if is does not include the same edge twice. 2. Elementary Circuit: A circuit is said to be elementary circuit if it does not meet same vertex twice ( Except first & last vertex.

42 42 Connected & Disconnected Graphs Definition: A graph is said to be connected graph if there is exists the path between every pair of vertices, otherwise it is disconnected. See the example in next page….

43 43 Connected & Disconnected Graph Example: Are the following graphs connected? dab c e Yes. dabc e No. dab c e Yes. dabc e f No.

44 44Connectivity In this section, we will see how the removal of edges & vertices disconnects the graph. For that we will see the concepts as given below, 1.Edge Connectivity 2.Vertex Connectivity Lets see one by one ……

45 45 Edge Connectivity In Connected graph G, a cut set is a minimal set of edges whose removal disconnects the graph & increases the components of graph by one. The number of edges in a smallest cut set of a connected graph G is called as edge connectivity. It is denoted by λ (G). In other words, λ (G) is a smallest no. of edges in G whose removal disconnects G. See the example in Next Page…..

46 46 Edge Connectivity For Example, For instance, in Fig. {e 1, e 4, e 8 } is a cut set whereas {e 1,e 4, e 8, e 9 } is not a cut set because its subset {e 1, e 4, e 9 } is also a cut set. Other cut sets in graph {e 6, e 7 }, {e 8, e 9 } & {e 1, e 3,e 5 }.

47 47 Edge Connectivity If the cut set of the connected graph contain only one edge then the edge is called as isthmus or bridge. i.e. removal of edge disconnects the graph. λ (G 1 )= 2, λ (G 3 ) =1

48 48 Vertex Connectivity The vertex connectivity of a connected graph G is defined as smallest number of vertices whose removal disconnects the graph. It is denoted by K(G). For Example, If we remove the vertices v 1 & v 4 then graph G 1 will be disconnected as shown in G 2.

49 49 Vertex Connectivity A graph is said to be separable graph if its vertex connectivity is one. Is separable graph, a vertex whose removal disconnects the graph is said to be a cut vertex or cut point. For Example, In this graph, the v is cut point.

50 50 Eulerian Path & Eulerian Circuit A path is called as Eulerian Path if every edge in the graph G appears exactly once in the path. A circuit which contains every edge of the graph G exactly once is called as Eulerian Circuit. A graph which has an Eulerian circuit is called as Eulerian Graph. See the Example in next page…

51 51 Eulerian Path & Eulerian Circuit For Example, G 1 has an Eulerian path e 1 e 2 e 3 e 4 e 5 but G 2 does not have Eulerian path. Similarly, G 3 contains an Eulerian circuit 1 2 3 4 5 1 but G 4 does not.

52 52 Hamiltonian Path & Circuit A path in a connected graph G is called as Hamiltonian Path if it contains every vertex of G exactly once. A circuit in a connected graph G is called Hamiltonian Circuit if it contains every vertex of G exactly once (Except first & last vertex). A graph which has Hamiltonian circuit is called as Hamiltonian Path. See the Example in next page…

53 53 Hamiltonian Path & Circuit For Example, In graph G 1, the Hamiltonian circuit is given by ( 1 2 3 4 1) & G 2 has Hamiltonian path (b a c) but it does not contain any Hamiltonian circuit.

54 54 Shortest Path Problem For Example, Given railway network connecting several cities, it is required to find shortest route between two cities. Mumbai Nasik Nagpur 600 700 200 650 Pune

55 55 Shortest Path Problem We now give an algorithm for solving the shortest path problem. The algorithm was found by Dijkstra in 1959 & is known as Dijkstra’s shortest path problem. This algorithm Gives shortest length of path from vertex ‘a’ to vertex ‘z’.

56 56 Dijkstra’s Algorithm Let G= (V, E) be a simple graph. Let a & z be any two vertices of the graph. Suppose L(x) = Label of vertex x which represents length of the shortest path from vertex ‘a’ to ‘z’. w ij = Weight of the edge e ij =(v i, v j ). ---------------Steps for finding Shortest Path--------------- Step 1: let P=  where P is set of those vertices which have permanent labels & T = {all vertices of graph G}. Set L(a)=0, L(x)=∞,  x  T & x != a. Step 2: Select vertex v in T which has smallest label. This label is called as permanent label of v. Also set P=P  {v} & T=T-{v}. If v=z, then L(z) is length of shortest path from vertex a to z & stop.

57 57 Dijkstra’s Algorithm Step 3: If v!=z, then revise labels of vertices of T. i.e. vertices which do not have permanent labels. The new label of vertex x in T is given by, L(x)= min {old L(x), L(v)+w (v, x)} Where w(v, x) is weight of edge joining vertex v & x. If there is no direct edge joining v & x then take w(v, x)= ∞. Step 4: Repeat steps 2 & 3 until z gets permanent label.

58 58 Travelling Salesman Problem The travelling salesman problem is one of the classical problems in computer science. A travelling salesman wants to visit a number of cities and then return to his starting point. Of course he wants to save time and energy, so he wants to determine the shortest path for his trip. We can represent the cities and the distances between them by a weighted, complete, undirected graph. The problem then is to find the circuit of minimum total weight that visits each vertex exactly one.

59 59 Travelling Salesman Problem Example: What path would the travelling salesman take to visit the following cities? MumbaiPuneNasik Nagpur 600 700 200 650550 700 Solution: The shortest path is Nagpur, Nasik, Mumbai, Pune, Nagpur (2,000 miles).

60 60 Nearest Neighbour Method So efficient method is available to find the solution of travelling salesman problem. So method is Nearest Neighbour method which gives good results by travelling salesman problem. In this method, we start the H. Circuit with any vertex & find vertex which is nearest to it. Containing this way & coming back to starting vertex by travelling through all the vertices exactly once, we get the H. Circuit.

61 61 Nearest Neighbour Method This method is described below, 1.Start with any vertex (say v1) & choose the vertex closest to starting vertex to form an initial path of one edge. Construct this path by selecting different vertices as described in step (2). 2.Let v n denote the latest vertex that was added to the path. Select vertex v n+1 closest to v n from all vertices that are not in the path & add this vertex to the path. 3.Repeat step (2) till all vertices of the graph G are included in the path. 4.Lastly form a circuit by adding the edge connecting the starting vertex & last vertex added.

62 62 Planar Graph A graph is said to be a Planar graph if it can be drawn on the plane with no intersecting edge. i.e. a graph is a planar graph if it drawn on a plane such that no edges cross each other. A graph which is non planar graph in One representation may becomes a Planar graph after redrawing it.

63 63 Planar Graph Regions: A planar graph divides the planes into regions. A region characterized by the set of edges forming its boundary. Types of Regions: 1.Finite Region ( A area is finite) 2.Infinite Region (Area is Infinite) A Planar graph has exactly one infinite region.

64 64 Planar Graph Euler’s Formula: The no. of regions in any planar representation depends upon no. of vertices & no. of edges in graph. The relation between edges, vertices & regions of any graph is given by Euler’s Formula. For any connected graph, v - e + r = 2 Where v, e, r the total no. of vertices, edges & regions in graph resp.

65 65 Planar Graph For Example, Here, v = 12 & e=15 then find r=? Acc. To Euler’s Formula, v-e-+r=2 v-e-+r=2 r= 2-v+e r= 2-12+15 r= 2-12+15 r= 5 r= 5 So the graph G contains 5 Regions

66 66 The End


Download ppt "1 Graphs Theory UNIT IV. 2Contents  Basic terminology,  Multi graphs and weighted graphs  Paths and circuits  Shortest path in weighted graph  Hamiltonian."

Similar presentations


Ads by Google