Math Note
Math Note
Not
Simple Graphs
Visual Representation
of a Simple Graph
Simple Graphs
Visual Representation
of a Simple Graph
Definition:
A simple graph G=(V,E)
consists of:
a set V of vertices or nodes (V corresponds to the
universe of the relation R), and
a set E of edges / arcs / links: unordered pairs of
[distinct?] elements u,v V, such that uRv.
TN
MS
AL
NC
SC
GA
LA
FL
Multigraphs
Definition:
A multigraph G=(V, E, f ) consists of a set V of vertices, a
set E of edges (as primitive objects), and a function
f:E{{u,v}|u,vV uv}.
Parallel
edges
Example:
nodes are cities and
edges are segments of major highways.
Discrete Mathematics, Spring 2009
Pseudographs
Definition:
A pseudograph G=(V, E, f ) where
f:E{{u,v}|u,vV}. Edge eE is a loop if loop
f(e)={u,u}={u}.
Example:
nodes are campsites
in a state park and edges are
hiking trails through the woods.
Discrete Mathematics, Spring 2009
Directed Graphs
Definition:
A directed graph (V, E) consists of a set of vertices
V and a binary relation E on V.
Example:
V = people, E={(x,y) | x loves y}
Definition:
Directed Multigraphs
Definition:
A directed multigraph G=(V, E, f ) consists of a set V of
vertices, a set E of edges, and a function f:EVV.
Example:
The WWW is a directed multigraph.
V=web pages, E=hyperlinks.
T er m
S im p le g rap h
M u ltig rap h
P seu d o g rap h
D irected g rap h
D irected m u ltig rap h
E dge
ty p e
U n d ir.
U n d ir.
U n d ir.
D irected
D irected
M u ltip le
ed g es o k?
No
Y es
Y es
No
Y es
S elflo o p s o k?
No
No
Y es
Y es
Y es
Graph Terminology
Adjacency
Let G be an undirected graph with edge set E. Let
eE be (or map to) the pair {u,v}. Then we say:
u, v are adjacent / neighbors / connected.
Edge e is incident with vertices u and v.
Edge e connects u and v.
Vertices u and v are endpoints of edge e.
Degree of a Vertex
Handshaking Theorem
Theorem:
deg(v) = 2 E
vV
Corollary:
Directed Adjacency
Directed Degree
Definition:
Let G be a directed graph, v a vertex of G.
The in-degree of v, deg(v), is the number of
edges going to v.
The out-degree of v, deg+(v), is the number of
edges coming from v.
The degree of v, deg(v)deg(v)+deg+(v), is the
sum of vs in-degree and out-degree.
Theorem:
1
deg (v) = deg (v) = deg(v) = E
2 vV
vV
vV
Complete Graphs
Definition:
K1
K2
K3
K4
n 1
K5
K6
Cycles
Definition:
C3
C4
C5
C6
C7
C8
Wheels
Definition:
W3
W4
W5
W6
W7
W8
n-Cubes (hypercubes)
Definition:
A graph that has vertices representing the 2n bit
strings of length n
For any nN, the hypercube Qn is a simple
graph consisting of two copies of Qn-1 connected
together at corresponding nodes. Q0 has 1 node.
Q0
Q1
Q2
Q3
Q4
n-Cubes (hypercubes)
Definition:
For any nN, the hypercube Qn can be defined
recursively as follows:
Bipartite Graphs
Definition:
V1
V2
a bipartite
Definition:
Let m, n be positive integers. The complete
bipartite graph Km,n is the graph whose vertices
can be partitioned V = V1 V2 such that
1.
2.
3.
4.
|V1| = m
|V2| = n
For all x V1 and for all y V2, there is an
edge between x and y
No edge has both its endpoints in V1 or both its
endpoints in V2
V1
V2
K2,3
V1
V2
K3,4
Discrete Mathematics, Spring 2009
Subgraphs
Definition:
H
Discrete Mathematics, Spring 2009
Graph Unions
Definition:
Graph representations:
Adjacency lists.
Adjacency matrices.
Incidence matrices.
Graph isomorphism:
Adjacency Lists
a
c
e
f
a
b
c
d
e
f
b, c
a, c, e, f
a, b, f
b
c, b
Adjacency Matrices
Adjacency Matrices
Graph Isomorphism
Definition:
Simple graphs G1=(V1, E1) and G2=(V2, E2) are isomorphic
iff a bijection f:V1V2 such that a,bV1, a and b are
adjacent in G1 iff f(a) and f(b) are adjacent in G2.
Graph Invariant
a property preserved by isomorphism of graphs
Necessary but not sufficient conditions for G1=(V1,
E1) to be isomorphic to G2=(V2, E2):
|V1|=|V2|, |E1|=|E2|.
The number of vertices with degree n is the same
in both graphs.
For every proper subgraph g of one graph, there
is a proper subgraph of the other graph that is
isomorphic to g.
Isomorphism Example
b
a
e
e
c
f
* Same # of vertices
* Same # of edges
* Different # of verts of
degree 2! (1 vs 3)
d
c
Connectedness
Definition:
A path of length n from u to v in G is
a sequence of n edges e1, e2, , en such that e1 is
associated with {x0, x1}, e2 is associated with {x1, x2}, and
so on, with en associated with {xn-1,xn}, where x0=u and
xn=v;
Connectedness
Definition:
Theorem:
Directed Connectedness
Definition:
A directed graph is strongly connected iff there is
a directed path from a to b for any two vertices a
and b.
It is weakly connected iff the underlying undirected
graph (i.e., with edge directions removed) is
connected.
Definition:
An Euler circuit in a graph G is a simple circuit
containing every edge of G.
An Euler path in G is a simple path containing every
edge of G.
Examples:
e
d
a, e, c, d, e, b, a
a, c, d, e, b, d, a, b
Euler circuit
Euler path
Definition:
A Hamilton circuit is a simple circuit that traverses
each vertex in G exactly once.
A Hamilton path is a simple path that traverses each
vertex in G exactly once.
Examples:
a
c
d
a, b, c, d, e, a
a, b, c, d
Hamilton circuit
Hamilton path
Discrete Mathematics, Spring 2009
Trees
Definition:
Theorem:
Trees
Example: Are the following graphs trees?
Yes.
No.
Yes.
Discrete Mathematics, Spring 2009
No.
Tree Terminology
Definition:
Definition:
Tree Terminology
Definition:
Trees
Example 1: Family tree
James
Christine
Frank
Joyce
Discrete Mathematics, Spring 2009
Bob
Petra
Trees (cont.)
Example 2: File system
usr
bin
bin
spool
ls
temp
Trees (cont.)
Example 3: Arithmetic expressions
y
This
m-ary tree
Definition:
Theorem:
Definition:
An ordered rooted tree is a rooted tree where
the children of each internal vertex are ordered.
Right child of
the Vertex a
b
f
d
i
h
k
l
Discrete Mathematics, Spring 2009
Right subtree of
the Vertex b
Tree Traversal
Preorder traversal
Definition:
Let T be an ordered rooted
tree with root r.
If T consists only of r, then r is
the preorder traversal of T.
Otherwise, suppose that T1,
T2, , Tn are the subtrees at r
from left to right in T. The
T1
preorder traversal begins by
visiting r. It continues by
traversing T1 in preorder,
Step 2
then T2 in preorder, and so on, Visit T1 in
preorder
until Tn is traversed in
preorder.
Discrete Mathematics, Spring 2009
T2
step 1
Visit r
...
Tn
step 3
Step n+1
Visit T2 in
preorder
Visit Tn in
preorder
Inorder traversal
Definition:
Let T be an ordered rooted
tree with root r.
If T consists only of r, then r is
the inorder traversal of T.
Otherwise, suppose that T1,
T2, , Tn are the subtrees at r
from left to right. The inorder
T1
traversal begins by traversing
visiting T1 in inorder, then
visiting r. It continues by
Step 1
traversing T2 in inorder, then Visit T1 in
inorder
T3 in inorder, , and finally
Tn in inorder
Discrete Mathematics, Spring 2009
T2
step 2
Visit r
...
Tn
step 3
Step n+1
Visit T2 in
inorder
Visit Tn in
inorder
Postorder traversal
Definition:
Let T be an ordered rooted
tree with root r.
If T consists only of r, then r is
the postorder traversal of T.
Otherwise, suppose that T1, T2,
, Tn are the subtrees at r
from left to right. The postorder
T1
traversal begins by traversing
T1 in postorder, then T2 in
postorder, , then Tn in
Step 1
postorder, and ends by
Visit T1 in
postorder
visiting r.
T2
step n+1
Visit r
...
Tn
step 2
Step n
Visit T2 in
postorder
Visit Tn in
postorder
Traversal Example
a
e
f
Preorder : a, b, e, j, k, n, o,
p, f, c, d, g, l, m, h, I
Inorder : j, e, n, k, o, p, b, f,
a, c, l, g, m, d, h, i
Postorder : j, n, o, p, k, e, f,
b, c, l, m, g, h, i, d, a