0% found this document useful (0 votes)
43 views25 pages

Relations and Graphs Composition and Graph Powers Sections 6.3-6.5

1) The document discusses directed graphs and binary relations, including concepts like walks, paths, circuits, cycles, and graph/relation powers. 2) The transitive closure of a directed graph or binary relation is formed by taking the union of the 1st, 2nd, 3rd, etc. powers of the graph/relation. 3) This ensures that (x,y) is in the transitive closure if there is a walk of any length from x to y in the original graph/relation.

Uploaded by

name
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views25 pages

Relations and Graphs Composition and Graph Powers Sections 6.3-6.5

1) The document discusses directed graphs and binary relations, including concepts like walks, paths, circuits, cycles, and graph/relation powers. 2) The transitive closure of a directed graph or binary relation is formed by taking the union of the 1st, 2nd, 3rd, etc. powers of the graph/relation. 3) This ensures that (x,y) is in the transitive closure if there is a walk of any length from x to y in the original graph/relation.

Uploaded by

name
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Relations and Graphs

Composition and
Graph Powers
Sections 6.3-6.5
Prof. Sandy Irani
Directed Graphs
A directed graph G = (V, E) consists of
V: set of verties
E: set of edges. E ⊆ V x V

Example: V = {a, b, c, d}
E = { (a,b), (b,b), (b,c), (c,b), (c,d) }

a b
A directed graph G=(V,E)
is the same as a relation
d c E on set V
Directed Graph Terminology

The tail of edge (b,d) is b


a The head of edge (b,d) is d
b

The in-degree of v = |{u: (u,v) ∈ E}|


d c The out-degree of v = |{u: (v,u) ∈ E}|

In-degree of c =

Out-degree of b =
A Walk in A Directed Graph
The walk in a directed graph is an alternating
sequence of vertices and edges, starting and ending
with a vertex.
Each edge comes after its tail and before its head.
< b, (b,a), a, (a,b), b, (b,d), d, (d,e), e, (e,c), c, (c,c), c, (c,d), d >

b Including the edges is redundant:

c <b, a, b, d, e, c, c, d>
a
<b, a, e> is not a walk because
d (a, e) is not an edge.
e
A Path in A Directed Graph
The walk in a directed graph is also a path if it has no
repeated vertices.
b
<a, b, d, e, c>
c
a <b, a, d, e>

<c, d, e>
d e
<d, e>
A Circuit in A Directed Graph
The walk in a directed graph is also a circuit if it
starts and ends at the same vertex.
b
<e, c, d, e>
c
a <a, b, a>

<c, c>
d e
<e, c, c, d, e, c, d, e>
A Circuit in A Directed Graph
The circuit in a directed graph is also a cycle if there are
no repeated vertices except for the first and the last.

b
<e, d, c, e>
c
a <a, b, a>

<c, c>
d e
< a, d, e, c, b, a >
Walks

Paths

Circuits

Cycles
Directed Graph Terminology *
Pick the correct description for the sequence

<c, d, a, b, d, e, c>

in the graph below.

b A) A walk but not a path, circuit or cycle

B) A walk and a circuit, but not a path or cycle


c
a
C) A walk, circuit, and cycle but not a path.

D) A walk and a path but not a circuit or cycle


d e
E) Not a walk
The length of a walk
The length of a walk (path, circuit, cycle) is the number
of edges.

b <e, d, c, e>

c <a, b, a>
a
<c, c>
d e <b, a, b, e, d, c, c, e>

<d>
Transitive Closure of a Directed Graph
Is it possible to travel from b to c
b by a walk?

c From c to b?
a
We can build a new graph with
The same vertex set.
d e
The new graph has an edge (x,y)
Whenever Y can be reached from x by a walk.
What is the smallest set of edges we need to add to make edges
in the graph transitive?
….the Transitive Closure.
Composition of Binary Relations
a b a b

d c d c
R S
a b
Add an edge from x to y
If there is a red-blue walk
d c x z y
S◦R Can have x = z or x = y or z = y
Composing a Binary Relation
with Itself
a a b
b

d c
d c
R
R◦R
Add an edge from x to y
if there is a walk of length 2
From x to y in R.

x z y
Can have x = z or x = y or z = y
Composition of Binary Relations *

A)3(R◦R)9
R is a binary relation on ℤ

For any x,y ∈ ℤ, xRy if x2 = y B) 3(R◦R)81

Select the statement that is true: C) 9(R◦R)3

D) 81(R◦R)3
Powers of a Relation
We can compose a relation multiple times with
itself:
R1 = A
R2 = R ◦ R
R3 = R ◦ R◦ R = R2 ◦ R
kth power of R

Rk = R ◦ R◦ R ◦… ◦ R = Rk-1 ◦ R
k times
Graph Powers
Graph G = (V, E)

Graph Gk has the same vertex set as G.


(x,y) is an edge in Gk if and only if there is a walk
of length k in G from x to y.

Theorem: The edges in Gk are the relation Ek


Graph Power Example
G G2
2 3 2 3

1 4 1 4

6 5 6 5
G3
2 3

1 4

6 5
Graph Powers *
What is the out-degree of vertex 2 in G4?

2 3 A) 2

1 4 B) 3

C) 4
6 5
G D) 5
Graph Powers
Graph Gk has the same vertex set as G.
(x,y) is an edge in Gk if and only if there is a walk
of length k in G from x to y.

Theorem: The edges in Gk are the relation Ek

Why?.... If there is a walk of length k from x to y in G:

x z y
walk of length k-1 edge from z to y in G
from x to z in G

(x,z) is an edge in Gk-1


Transitive Closure of a Directed Graph
Transitive closure of G: G+ = G1 ∪ G2 ∪ G3∪ G4…..
(Same vertex set. Take the union of the edges.)

(x,y) is an edge in G+ if and only if there is a walk in G


of any length.

Don’t actually need an infinite union:


If there is a walk from x to y in G, then there is a walk of
length at most n from x to y. (n is the number of vertices in G.)

G+ = G1 ∪ G2 ∪ G3∪ G4 ∪ ….. ∪ Gn
If there is a walk from x to y in G, then there is a walk of length at
most n from x to y. (n is the number of vertices in G.)

Worst Case:
Transitive Closure of a Directed Graph
Transitive closure of G: G+ = G1 ∪ G2 ∪ G3∪ G4…..
(Same vertex set. Take the union of the edges.)

(x,y) is an edge in G+ if and only if there is a walk in G


of any length.

The edge set of G+ is transitive:

Walk from x to y + Walk from y to z  Walk from x to z

y
x z
Transitive Closure of a Directed Graph *
Which pair is not an edge in the transitive closure of G?

2 3 A) (1,1)

1 4 B) (1,4)

C) (5,5)
6 5
G D) (3,6)
Transitive Closure of a Binary Relation
Transitive closure of Binary Relation R:
R+ = R1 ∪ R2 ∪ R3∪ R4…..
(Same domain. Take the union of the pairs.)

R+ is the smallest relation that includes all of R and is


transitive.
Alternative way to find the transitive closure of R:

Repeat until no new pairs are added:


If (x,y) ∈ R and (y,z) ∈ R and (x,z) ∉ R
Add (x,z) to R

2 3

1 4

6 5

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy