Relations and Digraphs

Sources:

  1. Bernard Kolman, Robert C. Busby & Sharon Cutler Ros. (2014). Relations and Digraph. Discrete Mathematical Structures (6th ed., pp. 139-204). Pearson.

Orderd pair and list

  • List:
    • Suppose 𝑛 is a nonnegative integer. A list of length 𝑛 is an ordered collection of 𝑛 elements (which might be numbers, other lists, or more abstract objects).
      • Note: A list has finite length since n is an integer.
    • Two lists are equal if and only if they have the same length and the same elements in the same order.
  • Ordered pair:
    • An ordered pair (a,b) is a listing of the objects a and b in a prescribed order, with a appearing first and b appearing second.
    • Thus an ordered pair is merely a sequence of length 2.

Product Sets

If A and B are two nonempty sets, we define the product set or Cartesian product A×B as the set of all ordered pairs (a,b) with a∈A and b∈B. Thus A×B={(a,b)|aA  and  bB}


Theorem:

For any two finite, nonempty sets A and B, |A×B|=|A||B|.

Proof:

Suppose that |A| = m and |B| = n. To form an ordered pair (a,b), a ∈ A and b ∈ B, 需要分别从A, B中选一个元素, 分别有m, n中可能, 因此|A×B|=m·n=|A|·|B|.


Example:

If A=B=R, the set of all real numbers, then R×R, also denoted by R2, is the set of all points in the plane. The ordered pair (a,b) gives the coordinates of a point in the plane.

Partitions

A partition(划分) or quotient set(商集) of a nonempty set A is a set P of nonempty subsets of A such that:

  1. Each element of A belongs to one of the sets in P.
  2. If A1 and A2 are distinct elements of P, then A1A2=.

即: 集合A的划分 PA的子集的集合.

The sets in P are called the blocks or cells of the partition. Below figure shows a partition P=A1,A2,A3,A4,A5,A6,A7 of A into seven blocks:

Partitions Example
  • Since the members of a partition of a set A are subsets of A, we see that the partition is a subset of P(A), the power set of A. That is, partitions can be considered as particular kinds of subsets of P(A). 集合A的划分是A的幂集的一个子集.

Example:

Let A=a,b,c,d,e,f,g,h. Consider the following subsets of A: A1=a,b,c,dA2=a,c,e,f,g,hA3=a,c,e,gA4=b,dA5=f,h

Then A1,A2 is not a partition since A1A2.

Also, {A1,A5} is not a partition since eA1 and eA5.

The collection P=A3,A4,A5 is a partition of A.


Example:

Let

Z=set of all integers,A1=set of all even integers, andA2=set of all odd integers.

Then {A1,A2} is a partition of Z.

Relations

Let A and B be nonempty sets. A relation R from A to B is a subset of A×B.

If RA×B and (a,b)R, we say that a is related to b by R, and we also write a R b.

If a is not related to b by R, we write a  b.

Frequently, A and B are equal. In this case, we often say that RA×A is a relation on A, instead of a relation from A to A.


Example:

Let A=1,2,3 and B=r,s. Then R={(1,r),(2,s),(3,r)} is a relation from A to B.


Example:

实数域的"等于"

Let A and B be sets of real numbers. We define the following relation R (equals) from A to B: a R b  if and only if a=b.


Example:

实数域的"小于"

Let A=1,2,3,4,5. Define the following relation R (less than) on A: a R b  if and only if a<b. Then

R = {(1,2),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)}.

Sets Arising from Relations

Domain and Range

  • The domain of R, denoted by Dom(R), is the set of elements in A that are related to some element in B.

    In other words, Dom(R), a subset of A, is the set of all first elements in the pairs that make up R.

  • The range, or codomain of R, denoted by Ran(R), is the set of elements in B that are second elements of pairs in R, that is, all elements in B that are paired with some element in A.

  • Elements of A that are not in Dom(R) are not involved in the relation R in any way. This is also true for elements of B that are not in Ran(R).

R-relative Set

  • R-relative set(R相关集): If R is a relation from A to B and xA, we define R(x), the R-relative set of x, to be the set of all y in B with the property that x is R-related to y. Thus, in symbols, R(x)={yB| x R y}.

  • Similarly, if A1A, then R(A1), the R-relative set of A1, is the set of all y in B with the property that x is R-related to y for some x in A1. That is, R(A1)={yB | x R y for some x \ in A1}

  • Note that R(x) can also be written as R({x}), but we choose the simpler notation.

  • 我们定义 R(A1) is the union of the sets R(x), where xA1.

    • 当参数为元素x时, R(x)表示xR相关集. 当参数为集合A时, R(A)表示A中每一个元素xR相关集的union(并集).

THEOREM1

Let R be a relation from A to B, and let A1 and A2 be subsets of A. Then:

  1. If A1A2, then R(A1)R(A2).
  2. R(A1A2)=R(A1)R(A2).
  3. R(A1A2)R(A1)R(A2).

Proof

  1. If yR(A1),then x R y for some xA1. Since A1A2, xA2. 因此在A2中存在若干个x满足 x R y, 即存在(x,y), xA2. Thus, yR(A2), 因此证明了(1).

  2. If yR(A1A2),then by definition x R y for some x in A1A2. If x is in A1, then, since x R y, we must have yR(A1).

    By the same argument, if x is in A2, then yR(A2). In either case, yR(A1)R(A2). Thus we have shown that R(A1A2)R(A1)R(A2).

    Conversely, since A1(A1A2), part (1) tells us that R(A1)R(A1A2). Similarly, R(A2)R(A1A2). Thus R(A_1) ∪ R(A2)R(A1A2), and therefore part (2) is true.

  3. If yR(A1A2), then, for some x in A1A2, x R y. Since x is in both A1 and A2, it follows that y is in both R(A1) and R(A2); that is, yR(A1)R(A2). Thus part (3) holds.

THEOREM2

Let R and S be relations from A to. B. If R(a)=S(a) for all a in A, then R=S.

Proof

If a R b, then bR(a). Therefore, bS(a) and a S b. A completely similar argument shows that, if a S b, then a R b.

由于每个a R b都有a S b, 所以RS; 反之得到SA, 因此有R=S.

The Matrix of a Relation

We can represent a relation between two finite sets with a matrix as follows. If A=a1,a2,...,am and B=b1,b2,...,bn are finite sets containing m and n elements, respectively, and R is a relation from A to B, we represent R by the m×n matrix MR=[mij] , which is defined by mij={1 if (ai,bj)R0 if (ai,bj)R.

The matrix MR is called the matrix of R. Often MR provides an easy way to check whether R has a given property.

The Digraph of a Relation

Digraphs are nothing but geometrical representations of relations.

If A is a finite set(有限集合) and R is a relation on A, we can also represent R pictorially as follows:

  • A中的每个元素都是一个点(vertex)
  • aiaj存在一条边(edge) iff ai R aj.

The resulting pictorial representation of R is called a directed graph or digraph of R.

可以看到, RA上的关系. 也就是说digrapg中的R是从A映射到A的, 这也说明了图上的点只能连接到图上的其他点, 不能连接到别的奇奇怪怪的地方.

Example:

Let A={1,2,3,4}R={(1,1),(1,2),(2,1),(2,2),(2,3),(2,4),(3,4),(4,1)}.

Then the digraph of R is as shown in below:

Digraph Example

In-degree & Out-degree

If R is a relation on a set A and a ∈ A, then

  • The in-degree(入度) of a (relative to the relation R) is the number of bA such that (b,a)R.
  • The out-degree(出度) of a is the number of bA such that (a,b)R.

在图像上, 一个vertex的in-degree代表指向该vertex的edge, 而out-degree代表从该vertex出发的edge.

  • Note that the out-degree of a is |R(a)|.

Paths in Relations and Digraphs

A path is most easily visualized with the aid of the digraph of the relation. It appears as a geometric path or succession of edges in such a digraph.

Suppose that R is a relation on a set A.

A path of length n in R from a to b is a finite sequence π:a,x1,x2,...,xn1,b, beginning with a and ending with b, such that a R x1, x1 R x2, , xn1 R b.

Note that a path of length n involves n+1 elements of A, although they are not necessarily distinct.


  • cycle(环): A path that begins and ends at the same vertex is called a cycle(环).

  • It is clear that the paths of length 1 can be identified with the ordered pairs (x,y) that belong to R.

  • Rn: If n is a fixed positive integer, we define a relation Rn on A as follows: x Rn y means that there is a path of length n from x to y in R. 即存在一条x -> y的长度为n的路径.

    • Rn(x) consists of all vertices that can be reached from x by means of a path in R of length n.
  • R: The connectivity(连通性) relation R of a relation R on a set A mean that if by letting xRy, there is some path in R from x to y. R 也被称为connectivity(连通性). 即存在一条x -> y的长度未知的路径.

    • The set R(x) consists of all vertices that can be reached from x by some path in R.
  • R: The reachability(可达性) relation R of a relation R on a set A that has n elements is defined asfollows:

    x R y means that x=y or x R y. The idea is that y is reachable from x if either y is x or there is some path from x to y. y到x是可达的 = 要么y就是x, 要么存在一条x -> y的长度未知的路径.

    • It is easily seen that MR=MRIn, where In is the n×n identity matrix.
  • 路径的组合:

    Let π1:a,x1,x2,,xn1,b be a path in a relation R of length n from a to b, and let π2:b,y1,y2,...,ym1,c be a path in R of length m from b to c.

    Then the composition of π1 and π2 π2 the path a,x1,x2,...,b,y1,y2,...,ym1,c of length n+m, which is denoted by π2π1. This is a path from a to c.

    即: 如果有一条长度为m的路径π1: a -> ... -> b, 长度为n的路径π2: b -> ... -> c. 则存在从a到c的路径a -> ... -> b -> ... -> c, 它是π1π2的组合, 长度为m+n.


Theorem:

If R is a relation on A={a1,a2,...,an}, then MR2=MRMR

Proof:
Let MR=mij and MR2=nij . By definition, the i,jth element of is MRMR equal to 1 if and only if row i of MR and column j of MR have a 1 in the same relative position, say position k. This means that mik=1 and mkj=1 for some k,1kn.

By definition of the matrix MR, the preceding conditions mean that ai R ak and ak R aj. Thus ai R2 aj, and so nij=1. We have therefore shown that position i,j of MRMR is equal to 1 if and only if nij=1. This means that MRMR=MR2 .

翻译:

如果MRMR 的i,j元素为1, 当且仅当 MR 的第i行和MR 的第k列的对应位置(记为k)存在一个1, 即mik=1 and mkj=1 for some k,1kn. 根据MR 的定义, 这意味着 ai R ak and ak R aj, 因此存在长度为2的路径i->k->j, 因此有 ai R2 aj, 所以有nij=1.

这意味着: MRMR 的i,j元素为1 iff nij=1. 也就是MRMR=MR2 .

  • For brevity, we will usually denote MRMR . simply as (MR)2 (the symbol reminds us that this is not the usual matrix product).

Theorem:

之前的结论可以推导到n>=2:

For n2 and R a relation on a finite set A, we have MRn=MRMRMR (n factors). 证明略.

联系之前R的定义, 可得: MR=InMR(MR)2(MR)3.

Equivalence Relations

  • equivalence relation(等价关系): A relation R on a set A is called an equivalence relation if it is reflexive, symmetric, and transitive. 即同时满足自反性, 对称性和传递性.

Example:

Let A be the set of all triangles in the plane and let R be the relation on A defined as follows: R={(a,b)A×Aa is congruent to b}. It is easy to see that R is an equivalence relation.


Example:

Let A={1,2,3,4} and let R={(1,1),(1,2),(2,1),(2,2),(3,4),(4,3),(3,3),(4,4)} It is easy to verify that R is an equivalence relation.

Equivalence Relations and Partitions

THEOREM 1: Equivalence Relation -> Partition

如果 P​ 是集合 A​ 上的一个划分(partition), 那么可以用P​来构建一个等价关系.

Let P be a partition of a set A. Recall that the sets in P are called the blocks of P. Define the relation R on A as follows: a R bif and only ifa and b are members of the same block.

Then R is an equivalence relation on A.

Proof:

  1. If aA, then clearly a is in the same block as itself; so aRa. 自反性.
  2. If aRb, then a and b are in the same block; so bRa. 如果aRb, 则a, b在同一个block内, 因此必定有bRa, 证明了对称性.
  3. If aRb and bRc, then a,b, and c must all lie in the same block of P. Thus aRc. 如果aRb, 则a, b在同一个block内, 同理b, c也在同一个block内, 因此a, b, c都在同一个block内, 因此有aRc. 证明了传递性.

因此 R 是自反, 对称且传递的.

R will be called the equivalence relation determined by P.

Since R is reflexive, symmetric, and transitive, R is an equivalence relation.

THEOREM 2: Partition -> Equivalence Relation

反过来, 也可以用等价关系R 来构建划分P.

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.

Proof: According to the definition of a partition, we must show the following two properties:

  1. Every element of A belongs to some relative set(some R(a)).
  2. If R(a) and R(b) are not identical, then R(a)R(b)=.

由于 R 具有自反性, 我们有aR(a) , 因此证明了性质1.

接着证明性质2的逆否命题: IfR(a)R(b), then R(a)=R(b).

To prove this, we assume that cR(a)R(b). Then aRc and bRc.

Since R is symmetric, we have cRb.

Then aRc and cRb, so, by transitivity of R, aRb.

Lemma1已经证明了a R bR(a)=R(b). 证明结束.

We have now proved that P is a partition. By Lemma 1 we see that aRb if and only if a and b belong to the same block of P. Thus P determines R, and the theorem is proved. Note the use of the contrapositive in this proof. If R is an equivalence relation on A, then the sets R(a) are traditionally called equivalence classes of R. Some authors denote the class R(a) by [a]. The partition P constructed in Theorem 2 therefore consists of all equivalence classes of R, and this partition will be denoted by A/R. Recall that partitions of A are also called quotient sets of A, and the notation A/R reminds us that P is the quotient set of A that is constructed from and determines R.

Lemma1

Let R be an equivalence relation on a set A, and let aA and bA. Then a R bR(a)=R(b)

Proof

充分性: 假设R(a)=R(b), 由于R是自反的, 因此有 bR(b), 因此有b R(a), 因此有aRb.

必要性:

假设 a R b. Then note that

  1. 由于 R 是对称的, 所以有b R a.
  2. xR(b), 有bRx. 由于 R 是传递的, 并且已经有a R b, 所以有a R c, 也就是说: xR(b), xR(a). 证明了 R(b)R(a).
  3. 反过来, yR(a), 有aRy. 由于 R 是传递的, 并且已经有b R a, 所以有b R y, 也就是说: yR(a), xR(a). 证明了 R(a)R(b).
  4. 综上所述, R(a)=R(b).

Equivalence Class

equivalence class(等价类): If R is an equivalence relation on A, then the sets R(a) are traditionally called equivalence classes of R.

  • 这里的R(a)指的是THEOREM2中的distinct relative set R(a) for a in A. 每个不同(distinct)的R(a)就是一个等价类.
  • 划分 P 就是R的等价类构成的集合. P 被表示为A/R.
  • 由于P也被称为A的商集(quotient set), the notation A/R reminds us that P is the quotient set of A that is constructed from and determines R.
  • Some authors denote the equivalence class R(a) by [a].

Transitive Closure and Warshall's Algorithm

Transitive Closure

In this section we consider a construction that has several interpretations and many important applications. Suppose that R is a relation on a set A and that R is not transitive. We will show that the transitive closure of R (see Section 7) is just the connectivity relation R, defined in Section 3.