What is Closures of Relations?
- A
relation Ron a set, it may or may not have some property P(e.g. relfexive, symmetric, antisymmetric, etc.)
Definition
A relation S, if exists, satisfies the following conditions:
RSShasproperty PSisthe smallest relationcontainingRwithproperty P
We call S is closure of R
Reflexive closure
TIP
We have a diagonal relation
A reflexive relation
Example
Set
The relation not reflexive
We have a diagonal relation
The reflexive closure of R is,
Symmetric closure
TIP
A symmetric relation
Example
Set
The relation not symmetric
We have an inverse relation
The symmetric closure of R is,
Transitive closure
Theorem Path và Relation Power
INFO
Given a relation R on set A
There is a path of length n from a to b, iff
- Intuition
: đi được trong 1 bước : đi được trong 2 bước : đi được trong 3 bước - ...
: đi được trong đúng n bước
Connectivity relation
INFO
- Let
be a relation on a set . - The
connectivity relationconsists of the pairs (a, b) such that there is a path of length at least onefrom a to b in - In other words,
tells us there exists a path from a to b. (Reachable)
TIP
A Transitive relation
Efficient ways to find transitive closure
WARNING
- The
in the previous section is the length of the path and leads to infinity().
Lemma 1
INFO
If there is a path from (a) to (b), then there exists a path whose length is at most n.
Moreover, if at most n - 1
- From Lemma 1, we see that the transitive closure of R is the union of
, , ,
TIP
n is the number of elements in the set
Transitive closure for the zero–one matrix
Theorem 3
- Let
be the zero–one matrixof the relationon a set with elements. Then the zero–one matrix of the transitive closure is
- Note that this is a
Boolean multiplication
Warshall’s Algorithm
Details
Warshall does NOT build paths by length.
Instead, it builds reachability by:
gradually allowing more intermediate vertices.
Interior Vertices
For a path:
the interior vertices are:
TIP
That is: all vertices except the first and last
Definition of
Warshall constructs matrices:
where:
and when:
iff there exists a path from:
such that all interior vertices belong to:
Important Interpretation
At step (k):
we are allowed to use only
as intermediate vertices.
Lemma 2 — The Core Recurrence
- Meaning that, a path from
, exists at step kif:
Case 1 — Existing Path
The path already existed before:
Case 2 — Path Through
There exists:
and:
using only:
as intermediate vertices.
Practical Implementation
for k = 1 to n
for i = 1 to n
for j = 1 to n
W[i][j] =
W[i][j] OR
(W[i][k] AND W[k][j])