Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 10 Graph Theory. 10.2 Eulerian Cycle and the property of graph theory 10.3 The important property of graph theory and its representation 10.4.

Similar presentations


Presentation on theme: "Chapter 10 Graph Theory. 10.2 Eulerian Cycle and the property of graph theory 10.3 The important property of graph theory and its representation 10.4."— Presentation transcript:

1 Chapter 10 Graph Theory

2 10.2 Eulerian Cycle and the property of graph theory 10.3 The important property of graph theory and its representation 10.4 Shortest path

3 10.2 Eulerian Cycle and the property of graph theory

4 Example 1 What is Königsberg Bridge problem? Ans. Two islands A and B are reduced to nodes. On the side of the river C and D are also reduced to nodes, it can be modeled as a graph and it is shown in Fig. 10.2.1. G=(V,E), V denotes Node Set, and E denotes Edge Set. V={A,B,C,D} and E={(A,C),(A,C),(A,D),(A,D),(A,B),(B,C),(B,D)}.

5 Fig.10.2.1 Königsberg Bridge

6 Fig.10.2.2 The model of Fig. 10.2.1 Edge(A,C) appears two times, it is called Multiple Edges. The degree of node B is 3, it can be denoted by d(B)=3 which means that there are 3 edges incident to the node B.

7 Example 2 From Fig. 10.2.2, Can we find an Eulerian cycle from node A? Ans. Node C will consume two adjacency edges when we cross. Since d(C) is odd, there will remain at last an adjacency edge. The discussion on node C is also suitable for node A, since d(A) is also odd. We are unable to find an Eulerian cycle in Fig.10.2.2.

8 Example 2.1 Let G=(V,E) be a loop-free connected undirected graph, and let (a, b) be an edge of G. Prove that (a, b) is a part of a cycle if and only if remove the vertices a and b does not disconnect G. Ans. (  ) If (a, b) is a part of a cycle and let a-b-v 1 -v 2 -…v i -a be a cycle. Suppose remove edge (a, b) from G. The path b-v 1 -v 2 -…-v i - a connects (a, b), thus G still connect. (  )It is still a connected image when removing the edge (a,b) from G, thus there exists a path a-v 1 -v 2 -…-v i -b. If we replace edge (a, b), we can obtain image G with a cycle a-v 1 -v 2 -…-v i -b-a, thus (a, b) is a part of a cycle.

9 Example 3 Let G=(V,E) be a connected graph. Prove that G has an Eulerian cycle if and only if all degree of nodes in G are even? Ans. (  ) If G has an Eulerian cycle, it means that for all nodes in the cycle, the number of in-edges are equal to out-edges. Thus, for all nodes in G, the degree of them are all even. (  ) Assume that we select two different node x, y  V from G, and it forms a longest Eulerian Chain C 1 from x to y. At this moment, we must select an edge (y, z) not be a part of C1 from G. Then, add an edge (y, z) to C1, we have a longer Eulerian chain. In fact, node z is node x. Assume that C1 has included all the edges in G, we get the proof.

10 If there are still edges in G which extend from node u  C1 but are not a part of C1, let G’ be discarded the edge set of C1 in G. Since G is a connected graph and every degree of node is even, the degree of nodes in G’ are still even. Assume we can find a cycle in G’, we merge this cycle into C1, we have Eulerian cycle larger than C1, this is a contradiction. Discard multiple edges (A,D) and (A,C) in figure 10.2.2, we can also find an Eulerian chain.

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30 10.3 The important property of graph theory and its representation

31

32 Example 1 Given a simple planar graph, are there upper bounds to limit the degree of nodes ? Ans. A face at least includes three edges. Let represents the number of faces that are formed by i edges, then the total number of faces F in G will satisfy Consider an edge shared by two faces, we obtain We have (10.3.1) We prove it by contradiction : there is a degree of node less than 6. Assume every node in V satisfy 6, we obtain (10.3.2)

33 represents the degree of nodes greater than 6. From (10.2.1) we induce that (10.3.3) We have (10.3.4) Merge (10.3.1) and (10.3.4), we have (10.3.1) multiplied by 2 and then merge (10.3.4) again, we obtain (10.3.5) From Euler formula we know (10.3.5) is wrong, since. Thus we prove it is impossible that every degree of nodes is greater than 6 in simple planar graph.

34 Example 2 Prove that there are at most edges in simple planar graph G. Ans. From (10.3.1) we have (10.3.6) Substitute Euler formula into the left pattern of (10.3.6), we have Thus, we prove that there are at most edges.

35 Example 3 Is a simple planar graph? Ans. In, there are 10 edges, there are at most edges in simple planar graph. Thus, is not a simple planar graph. Fig. 10.3.2

36 Example 3.1 For every tree, if, T has at least two pendant vertices. i.e. vertices of degree 1. Ans. (1)If T doesn’t have pendant vertices and T is connected graph, then,, and |E| = |V|  1, we have Induce that, it is a contradiction. (2)If T has one pendant vertices, then Induce that, it is a contradiction. Combine the discussion (1) and (2), thus T has at least two pendant vertices.

37 Example 3.2 Suppose G is an arbitrary digraph with n vertices. What is the largest possible number of distinct subgraphs with k vertices that G may have ? (Isomorphic subgraphs are distinct. Choose G to maximize this number.) Ans. When G is a complete graph which the number of nodes is n, it will have the largest possible number of distinct subgraphs. When the number of nodes is k, there are at most edges, and these edges have two choices : choose or not choose, it will compose all the digraph, there are different digraph. There are choices and we need to consider about which the number of nodes is k, thus the answer =.

38

39 Example 4 What is the representation of adjacency list ? Ans. Fig. 10.3.3 A little example

40

41 Example 5 What is the representation of adjacency matrix ? Ans. The representation of adjacency matrix : From above, the representation of adjacency matrix in figure 10.3.3 is

42 Example 6 What the problem is Warshall algorithm used to solve ? Ans. If, but node i can reach node j through node k, we say that node i can reach node j and write down. As shown in Figure 10.3.5. Fig. 10.3.5

43 represents that node I can reach node j through m edges. Warshall algorithm is the check of reachability between any two nodes in graph G, that is to compute (10.3.7) Here,. We solve the transitive closure problem in graph G.

44 Let Then we obtain

45 Example7 Before introduce Warshall’s algorithm, can you use brute force method to obtain ? Ans. A:=M B:=A for i=2 to (|V|-1) begin A:=A  M B:=B  A end It will take by brute force method.

46 Example8 What is Warshall method? Ans. Warshall’s method is easy, the following is the three for loops included in Warshall’s method : B:=M for k=1 to |V| begin for i=1 to |V| begin for j=1 to |V| B[i, j]=B[i, j]  (B[i, k]  B[k, j]) end The above procedure only need time

47 10.4 Shortest path

48 Example1 How many types does the shortest path have ? Ans. Let the source node in is S, and the target node is T. The four combinations of the shortest path are: Fig. 10.4.1 four combinations of the shortest path The symbol I denotes the set of inner nodes. ST 1S0S0 T0T0 2IT0T0 3S0S0 I 4II

49 Fig. 10.4.2 an example of a direct graph The first type of the shortest path is the problem of walking from node 1 to node 6. Let I=4, then the second type of the shortest path is the problem of walking from node 4 to node 6.

50 Example2 How is Floyd-Warshall algorithm used to solve the fourth type of the all pairs shortest path problem? And what is its time complexity? Ans. The fourth type of shortest path problem Floyd-Warshall algorithm is used to solve all pairs shortest path problem.

51 Let adjacency matrix is W, Floyd-Warshall algorithm can bedesigned as follow : B:=W for k=1 to |V| begin for i=1 to |V| begin for j=1 to |V| W[i, j]=min(W[i, j],W[i, k]+W[k, j]) end Its time complexity is.

52 Example3 Can Floyd-Warshall algorithm solve the all pairs shortest path problem in figure 10.4.2? Ans. From figure 10.4.2, we can get the source adjacency matrix is Here, represents that node 1 and node 4 not connect each other. After running k=1, adjacency matrix not change, that is

53 After running k=2, we obtain

54 After running k=3, will change into

55 Here, pay attention !. When we complete k=4, 5 and 6, finally we obtain Thus, the solve of the all pairs shortest path in figure 10.4.2 hides in. For example : tells us, the shortest path between node 2 and node 6 is 2.

56 Example4 How Dijkstra solve the all pairs shortest path problems? Ans. Given fig. 10.4.3 : Fig. 10.4.3 An example

57 Select node A and place it into Labeled Node Set (LNS), and the other four nodes B 、 C 、 D and E are placed into Unlabeled Node Set (UNS). Find the edge node set which connects LNS and UNS and denote it as (LNS, UNS). In the edge node set (LNS,UNS), we find the smallest weighted edge (A,C) and know its weighted edge value is 2. Fig. 10.4.4 is the present condition. Direct at node C in the figure, we record [A,2]. Fig. 10.4.4 The condition of LNS after include node C

58 Check the edges joined in LNS and UNS, then we discover that (A,B), (A,D), (C,B) and (C,D) is four edges to join LNS and UNS. We can calculate from figure 10.4.4 (10.4.1) Similar, can calculate Choose node B! Then the record on node B of [C,3]. Figure 10.4.5 is a sketch map after adding node B.

59 Fig. 10.4.5 Adding B to LNS

60 And then, we choose node B. Fig. 10.4.6 is a sketch map of LNS adding node D. Finally, we choose edge (B,E ) and node E, then pursued the final result of the Fig. 10.4.7. Fig. 10.4.6 Adding node D into LNS

61 Fig. 10.4.7 Final result By Fig. 10.4.7, we can get the shortest path and the length of shortest path from node A to all other nodes.

62 Example5 What is the time complexity of Dijkstra algorithm in Example4 ? Ans. As to any node in LNS, at least (|V|-k) edges can link to any node in UNS. If consider all extreme point in LNS, then there are at most k(|V|-k) edges link between LNS and UNS. Time complexity is (10.4.2)


Download ppt "Chapter 10 Graph Theory. 10.2 Eulerian Cycle and the property of graph theory 10.3 The important property of graph theory and its representation 10.4."

Similar presentations


Ads by Google