CS103
HO#24
Slides--Functions
April 21, 2010
1
Closure
The
closure
of a relation R on a set A with respect to a property P
is the smallest relation containing R that has property P.
R = {( , ), ( , ), .
..( ,)}
A
×
A = {( , ), ( , ), .
..( ,),
(
, ), ( , ), .
..( ,),
(
, ), ( , ), .
..( ,)}
Reflexive closure
: add enough pairs to make the result reflexive
The reflexive closure of R is the relation S = R
∪
{(x, x) | x
∈
A}
Symmetric closure
: add enough pairs to make the result symmetric
The symmetric closure of R is the relation S = R
∪
R
-1
= R
∪
{(y, x) | (x, y)
∈
R}
Closure
Transitive closure
: add enough pairs to make the result transitive
S = {(a, b)
∈
A
×
A | there is a path of any length from a to b in R}
Closure
Transitive closure
: add enough pairs to make the result transitive
S = {(a, b)
∈
A
×
A | there is a path of any length from a to b in R}
S = R
1
∪
R
2
∪
R
3
∪
R
4
∪
...
∪
R
n
where n is the number of elements in A
Closure
Transitive closure
: add enough pairs to make the result transitive
R* = {(a, b)
∈
A
×
A | there is a path of any length from a to b in R}
R* = R
1
∪
R
2
∪
R
3
∪
R
4
∪
...
∪
R
n
where n is the number of elements in A
We don't need to go farther than R
n
.
Since there are n elements in A,
a path longer than n would contain a loop, which could be deleted.
n + 1 hops
Since there are only n elements in A, there must be a
duplication, and a shorter path has already been found.
SEA
SFO
DEN
ORD
IDC
JFK
ATL
LA
BOS
SEA
SFO
DEN
ORD
IDC
JFK
ATL
LA
BOS
R
1
∪
R
2