Discrete Mathematics – Part 4 – Graphs Nguyα» n Thα» Thu Vân - May 12, 2023 Relations Relations Representing relations Equivalence relations Partial orderings Binary relations. Let π΄ and π΅ be sets. A Using Matrices. The relation β can be A relation on a set A is called an A relation β on a set π is called a partial binary relation from π΄ to π΅ is a subset β of represented by the matrix πβ = [πππ ], equivalence relation if it is reflexive, ordering or partial order if it is reflexive, π΄ × π΅: where symmetric, and transitive. transitive, and antisymmetric. β = {πβπ ≡ (π, π)|π ∈ π΄, π ∈ π΅} πππ = { 1 if (ππ , ππ ) ∈ β, Let β be an equivalence relation on a 0 if (ππ , ππ ) ∉ β set π΄. The set of all elements that are Members of S are called elements of the β is symmetric iff πβ = πβπ related to an poset. The elements π and π of a poset Ex. element π of π΄ is called the (π, βΌ) are called comparable if either π βΌ exactly one element of π΅ is related to each equivalence class of π and is denoted π or π βΌ π. element of π΄. by [π]β . Example. π΄ = {0,1,2}; π΅ = {π, π}. Then β = {(0, π), (0, π), (1, π), (2, π)} o A function represents a relation where (π, βΌ) is a well-ordered set if it is a poset Let β be an equivalence relation o A relation on a set π΄ is a relation from π΄ on a set π΄. These statements for to π΄. Properties of relations. nonempty subset of π has a least element. elements π and π of π΄ are π is maximal in the poset (π, βΌ) if there is equivalent: no π ∈ π such that π βΊ π. (i) πβπ; a is minimal if there is no element π ∈ π (ii) [π] = [π]; such that π βΊ π. (iii) [π] ∩ [π] = ∅ A relation on a set A is called such that βΌ is a total ordering and every Maximal and minimal elements are easy to spot using a Hasse diagram. They are the (i) reflexive, i.e. if (π, π) ∈ π for every element π ∈ π΄. “top” and “bottom” elements in the (ii) symmetric, i.e., if (π, π) ∈ π whenever (π, π) ∈ π , for all π, π ∈ π΄. diagram. (iii) transitive, i.e., if whenever (π, π) ∈ π and (π, π) ∈ π , then (π, π) ∈ π , for all π, π, π ∈ Ex. The Hasse diagram of the poset π΄. ({2,4,5,10,12,20,25}, |). So maximal (iv) antisymmetric i.e. if (π, π) ∈ β and (π, π) ∈ β, then π = π. elements are 12, 20, and 25 and minimal π-ary relations. Let π΄1 , π΄2 , … , π΄π be sets. An n-ary relation on these sets is a subset of π΄1 × elements are 2 and 5. π΄2 × β― × π΄π The sets π΄1 , π΄2 , … , π΄π are called the domains of the relation, and π is called its degree. Graphs Graphs Representing of graph Type of graphs Algorithms & Applications A graph πΊ = (π , πΈ) consists of π, a Adjacency matrix Null graph - Trivial graph Breadth first traversal for a graph [BFS] nonempty set of vertices (or nodes) and πΈ, a Adjacency list Simple graph – Not simple graph Depth first traversal for a graph [DFS] set of edges. Each edge has either one or two Undirected graph – Directed graph Shortest-path problems [Dijkstra’s shortest vertices associated with it, called its endpoints. Complete graph path algorithm] An edge is said to connect its endpoints. Connected / Disconnected graph Minimum spanning tree Furthermore, if E consists of of directed edges, Bipartite graph Euler paths [Konigberg bridge problems] (π , πΈ) is called directed graph. Star graph - Weighted graph - Hamilton paths Subgraph Trees Trees Properties of trees A tree is a connected undirected graph with no A tree with π vertices has π − 1 edges. Let πΊ be a simple graph. A spanning Hierarchical structure simple circuits. A full π −ary tree with tree of πΊ is a subgraph of πΊ that is a Searching efficiency tree containing every vertex of πΊ. Sorting A rooted tree is a tree in which one vertex has o π vertices has π = (π − 1)/π internal been designated as the root and every edge is vertices and π = [(π − 1)π + 1]/π directed away from the root. A rooted tree is leaves called an π-ary tree if every internal vertex o π internal vertices has π = ππ + 1 Spanning trees Binary search tree A minimum spanning tree in a connected weighted graph is a has no more than π children. vertices and π = (π − 1)π + 1 spanning tree that has the smallest The tree is called a full π-ary tree if every leaves, possible sum of weights of its edges. internal vertex has exactly m children. o π leaves has π = (ππ − 1)/(π − 1) An π −ary tree with π = 2 is called a binary vertices and π = (π − 1)/(π − 1) tree. internal vertices. Applications of trees