Uploaded by vipboy20031408

Handout (Part 4 - Relations - Graphs)

advertisement
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
Download