- 81 Views
- Uploaded on
- Presentation posted in: General

CSCI 115

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

CSCI 115

Chapter 4

Relations and Digraphs

CSCI 115

§4.1

Product Sets and Partitions

- Product Set
- Ordered pair
- Cartesian Product

- Theorem 4.1.1
- For any 2 finite non-empty sets A and B, |A x B| = |A||B|

- Partitions
- A partition (quotient set) of A is a set P of nonempty subsets of A such that:
- Each element of A belongs to a set in P
- If A1 and A2 are elements of P, then A1A2 = {}

- Each element of P is called a cell or a block

- A partition (quotient set) of A is a set P of nonempty subsets of A such that:

CSCI 115

§4.2

Relations and Digraphs

- Relations
- Relation from A to B
- Subset of A x B

- Relation on A
- Subset of A x A

- Relation from A to B

- Sets arising from relations
- Domains
- Domain of relation

- Ranges
- Range of relation
- Range of an element
- Range of a subset

- Domains

- Theorem 4.2.1
- Let R be a relation from A to B, and let A1 and A2 be subsets of A. Then:
- If A1 A2, then R(A1) R(A2)
- R(A1 A2) = R(A1) R(A2)
- R(A1 A2) R(A1) R(A2)

- Let R be a relation from A to B, and let A1 and A2 be subsets of A. Then:
- Theorem 4.2.2
- Let R and S be Relations from A to B. If R(a) = S(a) a A, then R = S.

- The matrix of a relation
- If A = {a1, a2, …, am} and B = {b1, b2, …, bn}, then a relation R from A to B can be represented by an m x n boolean matrix (MR) constructed as follows: mij = {

1 if (ai, bj) R0 if (ai, bj) R

- The Digraph of a relation
- Let R be a relation on A. The Digraph of R is constructed as follows:
- Draw a circle for each element in A, and label the circles accordingly (these are called vertices)
- Draw an arrow from ai to ajiffaiRaj(these are called edges)

- In-degrees and out-degrees

- Let R be a relation on A. The Digraph of R is constructed as follows:

- Relation Restriction
- Let R be a relation on a set A, with B A. The restriction of R to B is R (B x B).

CSCI 115

§4.3

Paths in Relations and Digraphs

- Path of length n from a to b:
- aRx1, x1Rx2, x2Rx3, …, xn-1Rb
- Geometric path in digraph

- Cycle: A path that begins and ends at the same vertex

- New relations from paths
- Rn: xRny iff there is a path of length n from x to y
- R: xRy iff there is any path from x to y
- Connectivity Relation

- R*: xR*y iff there is a path from x to y, or x = y
- Reachability Relation

- Theorem 4.3.1
- If R is a relation on A = {a1, a2, …, an}, then MR2 = MR MR = ((MR))2

- Theorem 4.3.2
- For n 2 and R a relation on a finite set A, we have MRn = MR MR... MR (n factors)

- Path composition
- is used as a variable for paths
- Assume we have:
- 1: a, x1, x2, …, xn-1, b
- 2: b, y1, y2, …, ym-1, c

- Then, we can compose 1 and 2 as follows:
- 21: a, x1, x2, …, xn-1, b, y1, y2, …, ym-1, c
- 21 is a path of length n + m

- 12 does not make sense

CSCI 115

§4.4

Properties of Relations

- A relation R on a set A is:
- Reflexive iff (a,a) Ra A
- Irreflexive iff (a,a) R a A
- Symmetric iff (a,b) R (b,a) R
- Asymmetric iff (a,b) R (b,a) R
- Antisymmetric iff (a,b) R and (b,a) R a = b
- Transitive iff (a,b) R and (b,c) R (a,c) R

- Theorem 4.4.1
- A relation R is transitive iff it satisfies the following property: If there is a path of length greater than 1 from vertex a to vertex b, there is a path of length 1 from a to b (i.e. aRb). In other words, R is transitive iff Rn R n > 1.

- Theorem 4.4.2
- Let R be a relation on a set A. Then:
- Reflexivity of R means a R(a) a A
- Symmetry of R means a R(b) iff b R(a)
- Transitivity of R means b R(a) and c R(b) implies c R(a)

- Let R be a relation on a set A. Then:

- Other properties:
- The digraph of a reflexive relation has a cycle of length 1 at every vertex
- The digraph of an irreflexive relation has no cycles of length 1
- If R is reflexive then the Domain(R) = Range(R) = A
- The matrix of a reflexive relation has all 1s on the diagonal
- The matrix of an irreflexive relation has all 0s on the diagonal
- The matrix of a symmetric relation has mij = mjii,j (MR = MRT)
- The matrix of an asymmetric relation meets the following 2 criteria:
- mij = 1 mji = 0 AND the diagonal must be all 0s

- The matrix of an antisymmetric relation meets the following criteria:
- If ij, then mij = 0 or mji = 0

- The Matrix of a transitive relation meets the following criteria:
- MR must have a 1 everywhere ((MR))2 has a 1

- Graph of a symmetric relation
- Undirected edge
- Adjacent vertices

- Connected graphs
- Disconnected graphs

CSCI 115

§4.5

Equivalence Relations

- Equivalence Relation
- A relation R on a set A is an equivalence relation if it is reflexive, symmetric, and transitive

- Theorem 4.5.1
- Let P be a partition of a set A such that P = {A1, A2, …, An}. Define a relation R on A as follows:aRb iff aAi and bAi (i {1, 2, …, n}). Then R is an equivalence relation on A.
- Here R is called the equivalence relation determined by P.

- Lemma 4.5.1
- Let R be an equivalence relation on A. Let a, b A. Then aRb iff R(a) = R(b).

- Theorem 4.5.2
- Let R be an equivalence relation on A, and let P be the collection of all distinct relative sets R(a) for a in A. Then P is a partition of A, and R is the equivalence relation determined by P.

- Note: When R is an equivalence relation on A, the sets R(a) are called equivalence classes. The partition constructed in Theorem 4.5.2 is denoted A/R.

Procedure to determine A/R (A finite or countable):

- Choose any aA and find R(a).
- If R(a) A, choose bA, bR(a) and find R(b).
- If A is not the union of the computed equivalence classes, choose xA such that x is not in any of the equivalence classes, and find R(x).
- Repeat step 3 until A is accounted for, or a pattern emerges which describes the equivalence classes.
- A/R is the partition formed by using each equivalence class as a cell.

CSCI 115

§4.6

Data Structures for Relations and Digraphs

- Linked list data structure
- Storage cell
- Data
- Pointer

- Storage cell
- Implementations
- Structures
- Arrays
- We will use the array implementation

- Implementation 1 – Start, Tail, Head, Next
- Fill in tail and head arrays
- Fill in start variable
- Fill in next array
- The tail, head and next arrays have as many elements as the digraph has edges
- Start is a simple variable (not an array)

- Implementation 2 – Vert, Tail, Head, Next
- Fill in tail and head arrays
- Fill in next array (within vertex)
- Fill in vert array. The data in vert is the first subscript in tail that corresponds to the current vertex
- The tail, head and next arrays have as many elements as the digraph has edges
- The vert array has as many elements as the digraph has vertices