Relations, Properties, Directed Graphs, Composition of Relations

Relations

  • A binary relation between two sets A and B is a subset RR of A×BA \times B.
  • A function ff from a set XX to a set YY, denoted f:XYf : X \rightarrow Y, is a subset of X×YX \times Y, such that for every element xXx \in X there is exactly one element yYy \in Y such that (x,y)f(x, y) \in f.
  • For a relation, the condition that for every element of the domain there should be a single element of the target is dropped.
  • Consider the set of faculty members FF at the university and the set of students SS of that university, and the relation RR between a faculty member fFf \in F and a student sSs \in S that ff teaches a class that is taken by a student.
  • A faculty member would be teaching multiple students.
  • A student taking multiple courses would have multiple instructors.
  • A faculty member might be on sabbatical and not be teaching a class in that semester.

Faculty - Student Example

  • Let F=F ={Alice, John, Mary}andandS = David,Elizabeth,Karen,Richard,Sarah{David, Elizabeth, Karen, Richard, Sarah}.
  • Let R=R ={(A, D), (A, E), (A, R), (A, S), (M, D), (M, E), (M, K)}F \times S
  • Representations:
    • Arrow Diagram
    • Matrix Representation

Relations on Infinite Sets

  • Let A = 2,3{2, 3} and define the relation MM between AA and Z+Z^+ such that aMxa M x iff xx is an integer multiple of aa
    • Examples: 2M2,2M4,2M6,...3M3,M6,...2 M 2, 2 M 4, 2 M 6, . . . 3 M 3, M 6, . . .
  • Define the relation CC between the reals RR and ZZ such that for xRx \in R and yZy \in Z, xy1|x - y| \le 1
    • Some examples: 0.9C1,1.1C1,1.1C20.9 C 1, 1.1 C 1, 1.1 C 2
  • Define the relation R between Z and Z such that xRyx R y iff xyx \le y. This is called a binary relation on a set.

Relations on a Set

  • A binary relation on a set AA is a subset of A×AA \times A.
  • The set AA is called the domain of the binary relation.
  • Let A=A ={a, b, c, d, e}anddefinethebinaryrelationand define the binary relationRononAas:as:R = (a,b),(b,c),(e,c),(c,e),(d,a),(d,d){ (a, b), (b, c), (e, c), (c, e), (d, a), (d, d) }
  • Matrix Representation
  • Arrow Diagram
  • Simple Arrow Diagram

Relation Properties - Reflexive

  • A relation on a set has the property of being reflexive if every element of the set is related to itself. That is, for all xAx \in A, (x,x)R(x, x) \in R.
  • Example: Consider the set A=A ={3, 4, 5, 6, 7, 8}.Definerelation. Define relationRtobethesetofpairsto be the set of pairs(x, y)wherewhere2 | (x - y).Thatis,apairisintherelationifthedifferenceofthetwovaluesiseven.Forall. That is, a pair is in the relation if the difference of the two values is even. For allx \in A,,x - x = 0, i.e. even. So this relation is even.

Relation Properties - Anti-Reflexive

  • A relation on a set is anti-reflexive (irreflexive) if none of the elements is related to itself.
  • Example The relation Sdefinedondefined onA = 3,4,5,6,7,8{3, 4, 5, 6, 7, 8} by (x,y)S(x, y) \in S when xy=2|x - y| = 2 is anti-reflexive, because the difference between an element and itself is never 2.
  • Note: Some relations are neither reflexive nor anti-reflexive.

Relation Properties - Symmetric

  • A relation has the property of being symmetric if when any element of the set is related to another, then the second element is also related to the first. That is, for all xx and yAy \in A, if (x,y)R(x, y) \in R then (y,x)R(y, x) \in R.
  • A symmetric relationship in our graphs looks like a flower petal or a self-loop.

Relation Properties - Anti-Symmetric

  • A relation has the property of being anti-symmetric if when any element of the set is related to another element, then the second element is not related to the first. That is, for all xx and yAy \in A, if (x,y)R(x, y) \in R and xyx ≠ y then (y,x)R(y, x) \notin R.
  • Example: The relation SS defined on A=A ={3, 4, 5, 6, 7, 8}byby(x, y) \in Swhenwhenx - y = 2 is anti-symmetric.
  • Note: Some relations are neither symmetric nor anti-symmetric.

Anti-Symmetric and Reflexive

  • The definition of anti-symmetry does not prevent the relation to be reflexive, because of the condition x ≠ y.
  • Examples:
    • The relation Sdefinedondefined onA = 3,4,5,6,7,8{3, 4, 5, 6, 7, 8} by (x,y)S(x, y) \in S when xyx \le y is anti-symmetric.
    • The relation SS defined on A=A ={3, 4, 5, 6, 7, 8}byby(x, y) \in Swhenwhenx - y \le 1 is anti-symmetric.

Relation Properties - Transitive

  • A relation has the property of being transitive if when any one element of the set is related to another, and that second element is related to a third, then the first element is also related to the third. That is, for all x,,yandandz \in A,if, if(x, y) \in Randand(y, z) \in Rthenthen(x, z) \in R.

Determining the Properties of a Relation

  • The relation ≤onthesetofon the set ofR
    • \forall x \in R, x \le x, hence reflexive.
    • \forall x, y \in Rififx ≠ yandandx \le ythentheny \nleq x, hence anti-symmetric.
    • \forall x, y, z \in Rififx \le yandandy \le zthenthenx \le z, hence transitive.
  • The relation same parity on the set Z; i.e. xPy iff parity(x) = parity(y)
    • \forall x \in Z, parity(x) = parity(x), hence reflexive.
    • \forall x, y \in Z, if parity(x) = parity(y), then parity(y) = parity(x), hence symmetric.
    • \forall x, y, z \in Z, if parity(x) = parity(y) and parity(y) = parity(z), then parity(x) = parity(z), hence transitive.
  • The relation predecessor on the set Z; i.e. xPy iff x = y − 1)
    • \forall x \in R, x ≠ x - 1 hence anti-reflexive.
    • \forall x, y \in R,if, ifx = y - 1,then, theny ≠ x - 1 hence anti-symmetric.
    • \forall x, y, z \in R,if, ifx = y - 1andandy = z - 1,then, thenx ≠ z - 1, hence not transitive.

Directed Graphs

Formal Definition of a Graph

  • A directed graph G consists of two finite sets: a nonempty set V(G) of vertices (plural of vertex ) and a set E(G) of directed edges E(G) ⊆ V(G) \times V(G)
  • Example: V (G) =a,b,c,d,e{a, b, c, d, e}, E(G)=E(G) ={ (a, b), (a, d), (b, c), (c, e), (d, d), (e, c) }
  • Each vertex is represented a dot with a label.
  • Each edge is represented by an arrow from a tail vertex to a head vertex.
  • If the head and the tail of an edge are the same vertex, the edge is called a self-loop
  • The in-degree of a vertex is the number of edges pointing into it. The out-degree of a vertex is the number of edges pointing out of it.

Walk in a Directed Graph

  • A walk from v0totovlinadirectedgraphin a directed graphG is a sequence of alternating vertices and edges that starts and ends with a vertex.
    • < v0, (v0, v1), v1, (v1, v2), v2 . . . vl-1, (vl-1, vl), vl >
  • Each edge in the sequence appears after its tail and before its head.
  • Since the edges in a walk are completely determined by the vertices, a walk can also be denoted by the sequence of vertices:
    • < v0, v1, v2 . . . vl-1, vl >
  • The sequence of vertices is a walk only if (vi-1, vi) \in Eforeachfor eachi = 1, 2, . . . l.
  • The length of a walk is l, the number of edges in the walk.
  • An open walk is a walk in which the first and last vertices are not the same. A closed walk is a walk in which the first and last vertices are the same.
  • < a, b, c, e > is an open walk of length 3
  • < c, e, c > is a closed walk of length 2
  • < a, b, d > is not a walk
  • < d, d, a, b, c, e, c, e > is a walk of length 8

Trails, circuits, paths, and cycles

  • A trail is a walk in which no edge occurs more than once.
  • A path is a walk in which no vertex occurs more than once.
  • A circuit is a closed trail.
  • A cycle is a circuit of length at least 1 in which no vertex occurs more than once, except the first and last vertices which are the same.
  • < a, b, c, b, d > is a trail
  • < a, b, c, e > is path
  • < d, a, b, c, b, d > is a circuit
  • < d, a, b, d > is a cycle
  • Notes:
    • A trail of length 1 is an edge
    • a cycle of length 1 is a self-loop

Composition of Relations

  • The composition of relations R and S on set A is another relation on A, denoted S \circ R.Thepair. The pair(a, b) \in S \circ Rifandonlyifthereisaif and only if there is ab \in Asuchthatsuch that(a, b) \in Randand(b, c) \in S.

Composition of a relation with itself

  • A relation on a set can be composed with itself.
  • For example, consider a relation P on a set of people that expresses parent-child relationships.
    • x P y means x is a parent of y.
  • Consider the relation P \circ P = P^2;;x P \circ P z means there is y such that x is the parent of y and y is the parent of z; i.e. x is the grand-parent of z
  • This can be extended to P \circ P \circ P = P^3, i.e. great-grand-parent, and so on.
  • In the corresponding graph, x P \circ P z means there is a sequence of the edges between x and z.
  • This can be considered the second power of the graph G^2

Graph Powers

  • Note G^4 = G^2,hence, henceG^5 = G^3,,G^6 = G^4 = G^2 and so on.
  • Define G^+ = G^1 \cup G^2 \cup G^3 \cup . . .
  • Although G^+isdefinedasaninfiniteunion,ifis defined as an infinite union, if|V | = nisfinite,weonlyneedtocalculateuptois finite, we only need to calculate up toG^n
  • If G represents the arrow diagram of a relation R on a set A, then G^+isthearrowdiagramoftherelationis the arrow diagram of the relationR^+ called the transitive closure of the relation R

Graph Power Theorem

  • Let G be a directed graph. Let u and v be any two vertices in G.
  • Theorem There is an edge from u to v in G^k if and only if there is a walk of length k from u to v in G.
  • Proof by induction:
    1. Prove that the theorem holds for the base case, i.e. G^1$$
    2. Prove that if the theorem holds for the case k, it must also hold for the case k + 1