Ch7. Graphs and Trees ECE20042 Handong Global University CH. 7. Graphs and Trees (p. 505) Handong Global University 7.1 Graph Theory(p. 506) Origins and Euler: The branch of geometry that deals with magnitudes has been zealously studied throughout the past, but there is another branch that has been almost unknown up until now; Leibniz spoke of it first, calling it the “geometry of position.” (geometria situs). This branch of geometry deals with the relations dependent on position alone; it does not take magnitudes into consideration, nor does it involve calculation of quantities. Handong Global University Space must exist independently of object ? • Space must not exist independently of object ? • Space must exist independently of object ? Handong Global University Graph Theory (p. 506) Handong Global University (p. 506) Handong Global University Proposition 1 (p. 507) In any graph, if there are an odd number of edges connected to a vertex x, then x cannot be an interior vertex( i.e. a vertex other than the starting or stopping point) in an Eulerian trail. Handong Global University Definition (p. 508) • A graph G consists of two sets V and E. The elements of V are called vertices(or nodes), and the elements of E are called edges. Each edge is associated with one or two vertices, called its endpoints. In the diagram we draw the edge as a line segment or curved are joining the endpoints. Handong Global University Definition (p. 508) • If two edges have the same endpoints, they are called multiple edges or parallel edges. • Two nodes that are joined by an edge are said to be adjacent nodes. Handong Global University Definition (p. 508) • A walk in a graph is a sequence v1e1v2e2…vnenvn+1 with n≥ 0 of alternating vertices and edges, which begins and ends with a vertex and where each edge in the list lies between its endpoints. If the beginning vertex is the same as the ending vertex, we say the walk is closed. The length of a walk is the number of edges in the walk. A walk of length 0 is called a trivial walk. Handong Global University Definition (p. 508) • A trail is a walk with no repeated edges, and a path is a walk with no repeated vertices. A circuit is a closed trail, and a trivial circuit is a circuit with one vertex and no edges. A trail or circuit is called Eulerian if it uses every edge in the graph. Handong Global University Definition (p. 508) • A cycle is a nontrivial circuit in which the only repeated node is the first/last one. Handong Global University Handong Global University Graphs in Applications (p. 509) Handong Global University Definition (p. 510) • A simple graph is a graph with no loops and no multiple (parallel) edges. • The unordered list notation [a,b] indicate an edge with endpoints a and b. This notation is ambiguous if the graph has multiple edges, but we will still use it if doing so will not cause confusion. In a simple graph, an edge with endpoints a and b can be represented as the two-element set {a,b} • If the graph is directed, we use (a,b) rather than [a,b] to indicate a directed edge from a to b. This use of the usual ordered pair notation emphasizes that in a directed graph the order of the vertices connected by the edges is significant. Handong Global University (p. 510) Handong Global University Definition (p. 510) • An edge e is said to be incident with a node v if v is an endpoint of e. • The degree of a node v, denoted by deg(v), is the number of times v appears as an endpoint of an edge. That is, deg(v) is the number of edges that are incident with v, except that loops are counted twice. • A graph G is connected if there is a walk between any pair of distinct nodes. Handong Global University Definition (p. 511) • A graph H is a subgraph of a graph G if all nodes and edges in H are also nodes and edges in G. • A connected component of a graph G is a connected subgraph H of G such that no other connected subgraph of G containing H exists. Handong Global University Handong Global University Eulerian Graphs (p. 511) • Definition: A graph G is Eulerian if there is a circuit in G that involves every edge exactly once. Recall that such a circuit is called an Eulerian circuit. • Theorem 2: Let G be a connected graph. The Graph G is Eulerian if and only if every node in G has even degree. Handong Global University Example 4, (p. 512) Handong Global University Handong Global University Example 4 (p. 512) • Let G be the graph given on the left in figure 7-11. – First we find any circuit C, as shown in Figure 711 on the right. – We next form the graph G' by removing from G all the edges in the circuit C. – We can now piece together C, C1, and C2. Specially, in C=1,2,3,7,8,11,14,1, we replace the 3 with C1 and the 8 with C2 to get the Eulerian circuit: Handong Global University Example 4 (p. 512) • 1,2,3,4,5,6,7,11,12,13,6,3,11,13,14,3,7,8,9,10,8,11,14,1 C1 C2 Handong Global University Graphs with Eulerian Trails (p. 513) Handong Global University Graphs with Eulerian Trails (p. 513) • Theorem 3 : In any graph, the sum of the degrees of the vertices is equal to twice the number of edges. In symbols. n degv 2m i 1 i where v1, v2,…vn are the vertices of the graph and m is the number of edges in the graph. Handong Global University Handong Global University (p. 513) • Corollary 4: In any graph G, the number of nodes with odd degree is even. Handong Global University (p. 514) • Theorem 5 : A connected, non-Eulerian graph G has an Eulerian trail if and only if G has exactly two nodes of odd degree. Moreover, the trail must begin and end at these two nodes. (ref. Theorem 2, p. 511) Handong Global University Handong Global University Handong Global University Example 5 (p. 514) • The graph of the “envelop” we saw earlier can thus be modified by adding an edge between its two nodes (3 and 4) of odd degree to get the graph shown in Figure 7-15. The solution method of Example 4 can then be used to find the Eulerian circuit 3,2,1,5,4,6,5,2,6,3,4,3 in this new graph. Dropping the last edge [4,3] from this circuit gives us the Eulerian trail 3,2,1,5,4,6,5,2,6,3, 4 in the original graph. Handong Global University 3,2,1,5,4,6,5,2,6,3,4,3 3 Handong Global University Example 6 (p. 514) • Here is a magic trick based on Eulerian graphs. The explanation is left as an exercise for the reader. You are the magician. Take a standard set of dominoes and discard the double 6, double 5, double 4, double 3, double 2, double 1, and double blank pieces. Have one spectator choose a single domino and give it to you. Turn your back and have a second spectator line up the remaining dominoes using the conventional rules that the faces touching must share the same number. The spectator should only have to make one such line-allow other spectators to help if he or she is having difficulty. Now you reveal (dramatically) the numbers on the ends of the line, and show that they are the same two numbers on the domino originally chosen. Handong Global University Handong Global University Eulerian Path & Circuit Handong Global University Handong Global University Handong Global University Handong Global University