620 likes | 829 Views
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 Shortest path. 10.2 Eulerian Cycle and the property of graph theory. Example 1 What is Königsberg Bridge problem? Ans.
E N D
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 Shortest path
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)}.
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. Fig.10.2.2The model of Fig. 10.2.1
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.
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-v1-v2-…vi-a be a cycle. Suppose remove edge (a, b) from G. The path b-v1-v2-…-vi-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-v1-v2-…-vi-b. If we replace edge (a, b), we can obtain image G with a cycle a-v1-v2-…-vi-b-a, thus (a, b) is a part of a cycle.
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, yV from G, and it forms a longest Eulerian Chain C1 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.
If there are still edges in G which extend from node uC1 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.
10.3 The important property of graph theory and its representation
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)
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.
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.
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
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.
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 = .
Example 4 What is the representation of adjacency list? Ans. Fig.10.3.3 A little example
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
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
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.
Let Then we obtain
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:=AM B:=BA end It will take by brute force method.
Example8What 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 end The above procedure only need time
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.1four combinations of the shortest path The symbol I denotes the set of inner nodes.
Fig.10.4.2an 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.
Example2How 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.