






















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Review for final exam. Included past lecture notes.
Typology: Study notes
1 / 30
This page cannot be seen from the preview
Don't miss anything!
CSC 2259 STUDY GUIDE FOR FINAL EXAM with LINTA ISLAM 9.1 Relations and Their Properties
- Transitive Relations: when there is a (a,c) and (c,b) pair, their must be a (a,b) pair EXAMPLE: Consider the following relations on {1, 2, 3, 4}: R1 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)}, R2 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)}, R3 = {(3, 4)}. R4 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}, NOT Transitive R5 = {(1, 1), (1, 2), (2, 1)}, NOT Transitive R6 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)}, NOT Transitive R1, R2, and R3 are transitive. Ex. In R1 (3,2) and (2,1) are the (a,c) and (c,b) pair, so there must be an (a,b) pair in the array which is (3,1) - Combining Relations: Given two relations R1 and R2, we can combine them using basic set operations to form new relations such as R1 ∪ R2, R1 ∩ R2, R1 - R2, and R2 - R1. Ex. R1 = {(1,1), (2,2), (3,3)} and R2 = {(1,1), (1,2), (1,3), (1,4)} R1 ∪ R2 = {(1,1), (1,2), (1,3), (1,4), (2,2), (3,3)} - Combine R1 and R R1 ∩R2 = {(1,1)} – Common element is left R1 - R2 = {(2,2), (3,3)} – remainder of R1 that is not a common element with R R2 - R1 = {(1,2), (1,3), (1,4)} – remainder of R2 that is not a common element of R
Degrees and Neighborhoods of Vertices: Adjacent/Neighbors – neighbor of the vertex (lines connected to the vertex). The edges Undirected graphs degree – a graph without arrows, also when finding the degree, it will be the number of edges it has Directed Graph Outdegree – arrow pointing outward, each arrow pointing outward of the vertex is consider 1 outdegree Directed Graph Indegree – arrow pointing inward, arrow pointing toward the vertex is considered 1 indegree Example: What are the degrees and neighborhoods of the vertices in the graphs G and H? Solution: G: deg(a) = 2, deg(b) = deg(c) = deg(f ) = 4, deg(d ) = 1, deg(e) = 3, deg(g) = 0. N(a) = {b, f }, N(b) = {a, c, e, f }, N(c) = {b, d, e, f }, N(d) = {c}, N(e) = {b, c , f }, N(f) = {a, b, c, e}, N(g) = NULL H: deg(a) = 4, deg(b) = deg(e) = 6, deg(c) = 1, deg(d) = 5. N(a) = {b, d, e}, N(b) = {a, b, c, d, e}, N(c) = {b}, N(d) = {a, b, e}, N(e) = {a, b ,d}. (N is for neighbors)
Degrees of Vertices Theorem 1 (Handshaking Theorem): If G = (V,E) is an undirected graph with m edges, then
Proof: Each edge contributes twice to the degree count of all vertices. Hence, both the left- hand and right-hand sides of this equation equal twice the number of edges. Think about the graph where vertices represent the people at a party and an edge connects two people who have shaken hands. Example 1: How many edges are there in a graph with 10 vertices of degree 6? Solution: Because the sum of the degrees of the vertices is 6 10 = 60, the handshaking theorem tells us that 2m = 60. So the number of edges m = 30. Example 2: If a graph has 5 vertices, can each vertex have degree 3? Solution: This is not possible by the handshaking theorem, because the sum of the degrees of the vertices 3 5 = 15 is odd. Theorem 2: An undirected graph has an even number of vertices of odd degree. Proof: Let V1 be the vertices of even degree and V2 be the vertices of odd degree in an undirected graph G = (V, E) with m edges. Then
Explanation: deg(v) must be even, since deg(v) is even for each v V1, and V2. This sum must be even because 2m is even and the sum of the degrees of the vertices of even degrees is also even. Because this is the sum of the degrees of all vertices of odd degree in the graph, there must be an even number of such vertices. Directed Graphs:
Bipartitie Graphs Definition: no edges which connect two vertices in V₁ or in V₂. It is not hard to show that an equivalent definition of a bipartite graph is a graph where it is possible to color the vertices red or blue so that no two adjacent vertices are the same color. G is bipartite, (a is not connected to another red like b or d) H is not bipartite since if we color a red, then the adjacent vertices f and b must both be blue. Example: Show that C₆ is bipartite. Solution: We can partition the vertex set into V₁ = {v₁, v₃, v₅} and V₂ = {v₂, v₄, v₆} so that every edge of C₆ connects a vertex in V₁ and V₂. Example: Show that C₃ is not bipartite. Solution: If we divide the vertex set of C₃ into two nonempty sets, one of the two must contain two vertices. But in C₃ every vertex is connected to every other vertex. Therefore, the two vertices in the same partition are connected. Hence, C₃ is not bipartite.
Complete Bipartite Graphs Definition: A complete bipartite graph Km,n is a graph that has its vertex set partitioned into two subsets V₁ of size m and V₂ of size n such that there is an edge from every vertex in V₁ to every vertex in V₂. Example: We display four complete bipartite graphs here. 10.3 Representing Graphs and Graph Isomorphism Adjacency List: An adjacency list can be used to represent a graph with no multiple edges by specifying the vertices that are adjacent to each vertex of the graph. Example: Example: TABLE 1: An Adjacency List for a Simple Graph. Vertex Adjacent Vertices a b, c, e b a c a, d, e d e, c e a, c, d TABLE 2: An Adjacency List for a Directed Graph. Vertex Terminal Vertices a b, c, d, e b b, d c a, c, e d e b, c, d
Adjacency Matrices: Adjacency matrices can also be used to represent graphs with loops and multiple edges. When multiple edges connect the same pair of vertices vᵢ and vⱼ (or if multiple loops are present at the same vertex), the (i, j)-th entry equals the number of edges connecting the pair of vertices. Example: We give the adjacency matrix of the pseudograph shown here using the ordering of vertices a, b, c, d. (Basically each column and row is a,b,c,d) Adjacency matrices can also be used to represent directed graphs. Incidence Matrices: Let G = (V, E) be an undirected graph with vertices where v₁, v₂, ..., vₙ and edges e₁, e₂, ..., eₘ. The incidence matrix with respect to the ordering of V and E is the n × m matrix M = [mᵢⱼ], where mᵢⱼ = 1 when edge eⱼ is incident with vᵢ 0 otherwise.
Isomorphism of Graphs : The simple graphs G₁ = (V₁, E₁) and G₂ = (V₂, E₂) are isomorphic if there is a one-to-one and onto function f from V₁ to V₂ with the property that a and b are adjacent in G₁ if and only if f(a) and f(b) are adjacent in G₂, for all a and b in V₁. Such a function f is called an isomorphism. Two simple graphs that are not isomorphic are called nonisomorphic. General Rules for Solving Isomorphism Problems : For two graphs to be isomorphic the must meet the following requirements
Example: Determine whether these two graphs are isomorphic. Solution: IT is Isomorphic Both graphs have six vertices and seven edges. They also both have four vertices of degree two and two of degree three. We define an injection f from the vertices of G to the vertices of H that preserves the degree of vertices. We will determine whether it is an isomorphism. The function f with f(u₁) = v₆, f(u₂) = v₃, f(u₃) = v₄, and f(u₄) = v₅, f(u₅) = v₁, and f(u₆) = v₂ is a one-to-one correspondence between G and H. Showing that this correspondence preserves edges is straightforward, so we will omit the details here. Because f is an isomorphism, it follows that G and H are isomorphic graphs.
10.5 Euler Graph, Euler Paths and Circuits Euler Paths (all vertex degrees = odd) and Circuits (all vertex degrees = even) Definition: Euler circuit: in a graph G is a simple circuit reaching every edge just once and must start and end at the same vertex. All vertices in the graph must have am even degree Euler Path : visit every edge once but does not have to end with the same vertex. Exactly two vertices in the graph must have an odd degree Example: Which of the undirected graphs G₁, G₂, and G₃ has an Euler circuit? Of those that do not, which has an Euler path? Solution: G₁ has an Euler circuit (Find the degree of every vertices, if all vertices is even then it is a Euler circuit) G2 is neither circuit nor path because the vertices are not even, and for path there need to be only 2 vertices that is an odd degree, in here a,b,d,c which are ore then 2 odd vertices degree G₃ has an Euler path (a,b are the only vertices that has an odd degree and the rest is even which cause this graph to be a path). Theorem: A graph will have a Euler path if it contains at most 2 vertices of odd degree. A graph will have a Euler circuit if all vertices have an even degree. Example: Two of the vertices in the multigraph model of the Kӧnigsberg bridge problem have odd degree. Hence, there is no Euler circuit in this multigraph and it is impossible to start at a given point, cross each bridge exactly once, and return to the starting point.
Forest: A forest is a graph that has no simple circuit, but is not connected. Each of the connected components in a forest is a tree. Theorem: An undirected graph is a tree if and only if there is a unique simple path between any two of its vertices. Proof: Assume that T is a tree. Then T is connected with no simple circuits. Hence, if x and y are distinct vertices of T, there is a simple path between them (by Theorem 1 of Section 10.4). This path must be unique - for if there were a second path, there would be a simple circuit in T (by Exercise 59 of Section 10.4). Hence, there is a unique simple path between any two vertices of a tree. Now assume that there is a unique simple path between any two vertices of a graph T. Then T is connected because there is a path between any two of its vertices. Furthermore, T can have no simple circuits since if there were a simple circuit, there would be two paths between some two vertices. Hence, a graph with a unique simple path between any two vertices is a tree. Rooted Trees: A rooted tree is a tree in which one vertex is dubbed the “root” and every edge is directed away from the root. An unrooted tree is converted into different rooted trees when different vertices are chosen as the root.
Terminologies:
Solution: I. The left child of d is f and the right child is g. II. The left and right subtrees of c are displayed in (b) and (c). Properties of Trees Theorem 2: A tree with n vertices has n −1 edges. Proof (by mathematical induction): Don’t think this will be on test
Counting Vertices in Full m-Ary Trees Theorem 3: A full m-ary tree with i internal vertices has n = mi + 1 vertices. Proof: Every vertex, except the root, is the child of an internal vertex. Because each of the i internal vertices has m children, there are mi vertices in the tree other than the root. Hence, the tree contains n = mi + 1 vertices. Theorem 4: A full m-ary tree with I. n vertices has i = (n − 1)/m internal vertices and l = [(m −1)n + 1]/m leaves, II. i internal vertices has n = mi + 1 vertices and l = (m −1)i + 1 leaves, III. l leaves has n = (ml − 1)/(m − 1) vertices and i = (l − 1)/ (m −1) internal vertices. Proof (of part I): Solving for i in n = mi + 1 (from Theorem 3) gives i = (n −1)/m. Since each vertex is l either a leaf or an internal vertex, n = l + i. By solving for l and using the formula for i, we see that l = n - i = n - (n - 1)/m = [(m - 1)n + 1]/m. (part II, III proofs left as practice) Level of Vertices and Height of Trees When working with trees, we often want to have rooted trees where the subtrees at each vertex contain paths of approximately the same length. To make this idea precise, we need some definitions: