GRAPHS
The seven bridges of
Konigsberg
Problem 1: The City of Konigsberg (in the early
eighteenth century) comprises the river banks A
and D and the islands B and C. These four land
areas are connected by seven bridges. Could a
Konigsbergian take a walk through the city passing
over each bridge exactly once and return home?
In 1736, Euler, while at St. Petersburg Academy,
published a solution to the problem: No such walk
is possible. (Figure 1.)
The seven bridges of
Konigsberg
Figure 1.
1
2
3 4
5
6
7
The utilities problem
Problem 2: An old problem concerns three
houses А, В, С which are to be joined to each
of the three utilities: gas (G), water (W) and
electricity (E) without any two connections
crossing each other.
In other words, can the diagram of Figure 2 be
redrawn so that no two lines cross?
The utilities problem
Figure 2.
Computer programming
flowchart
Example 1: Computer programming flowchart
(is
a strict digraph): Each vertex represents some
programmed operation or decision, and each arc
represents the flow of control to the next
operation
or decision.
A food web
Example 2: A food web is a strict digraph in
which nodes represent species and in which
there
is an arc from U to V if species U eats species V.
Undirected Graphs
Definition 1: A pseudograph (or undirected
graph) G is the ordered pair G=(V,E) of two sets:
a nonempty finite set V, which elements called
vertices (or nodes) and a set E, which elements
called edges (or arcs). In case of pseudograph,
set E is the domain of any function F from E to
the set of unordered pairs:
 
 
, | ,
u v u v V

Undirected Graphs
An edge is a loop if .
The edges are multiple (or parallel)
edges if 
Geometrically, vertices are represented by
points and the edges by lines (not necessarily
straight) joining pairs of points.
   
,
F e u u

e E

1 2
e and e
   
1 2
F e F e

Undirected Graphs
Example of pseudograph:
Loop
Parallel edges
Parallel edges
Undirected Graphs
Definition 2: A multigraph is a pseudograph
without loops 
Example of multigraph:
Parallel edges
Parallel edges
Undirected Graphs
Definition 3: A simple graph is a pseudograph
without loops and multiple edges 
Example of simple graph:
Directed Graphs
Definition 4: A directed multigraph G is the
ordered pair G=(V,E) of two sets: a nonempty
finite set V, which elements called vertices (or
nodes) and a set E, which elements called
directed edges (or arcs). In case of directed
multigraph, set E is the domain of any function
F from E to the set of ordered pairs:

 
 
, | ,
u v u v V

Directed Graphs
Example of directed multigraph :
Loop
Parallel edges
Parallel edges
Directed Graphs
Definition 4: A directed graph (digraph) is a
directed multigraph without multiple edges 
Example of digraph:
Loop
Examples
Graph Terminology
Type Edges Multiple
Edges
allowed?
Loops
allowed?
Pseudograp
Multigraph
Simple Graph
Directed
multigraph
Digraph
Undirected
Undirected
Undirected
Directed
Directed
Yes
Yes
No
Yes
No
Yes
No
No
Yes
Yes
Adjacent vertices
Definition 5: Two vertices u and v in a
undirected graph are adjacent if an edge (e)
runs between them:
If a loop (e) occurs at u, then u is adjacent to
itself:
An isolated vertex is not adjacent to any vertex 
 
: ,
F e u v

 
: ,
F e u u

Incidents and Degree of a
vertex
Definition 6: If a vertex v (in a undirected graph)
is an endpoint of the edge e, then e is incident with
a vertex v 
Definition 7: The degree of a vertex v (denoted
by deg(v)) in a undirected graph is the number of
edges incident with v.
If a vertex v is isolated, then deg (v) = 0.
A loop at a vertex contributes twice to the
degree of that vertex 
The following Theorem establishes a relationship
between the sum of the degrees of the vertices of
a graph and the number of edges in it.
Theorem 1: Let “e” denote the number of edges
of an undirected graph with n vertices
Then:

Corollary:
Corollary: The sum of the degrees in an
undirected graph is always an even integer 
 
1 2
, ,... n
u u u
 
1
deg 2
n
i
i
u e



Example 3: Is a graph with four vertices
a,b,c,d, with deg(a) = 4, deg(b)=deg(d)=5,
and deg(c)= 2 possible? The same problem,
bat deg(b)=6?
Theorem 2: The number of odd degree vertices
in an undirected graph is an even integer 
For example, the Konigsberg model in Figure
1
contains four vertices of odd degree.
Degree of a vertex
(directed graph)
Definition 8: The indegree of a vertex v
(denoted by indeg(v)) in a directed multigraph
is the number of directed edges terminating at v.
The outdegree of a vertex v (denoted by
outdeg(v)) in a directed multigraph is the
number of directed edges leaving v.
The degree of v, or deg(v), is the sum of its
indegree and outdegree:

     
deg deg deg
v in v out v
 
Degree of a vertex
(directed graph)
Example 4:
1
2
3
4
1 2 3 4 5
Indegree 1 4 2 1 0
Outdegre
e
1 2 2 2 1
Degree 2 6 4 3 1
5
 
1 2
, ,... n
u u u
Theorem 3: Let “e” denote the number of
edges of a directed multigraph with “n”
vertices , Then:

   
1 1
deg deg
n n
i i
i i
in u out u e
 
 
 
Degree of a vertex
(directed graph)
 
1
deg 2
n
i
i
u e



Subgraph
Definition 9: A subgraph of a graph G = (V,E) is
a graph , where 
Example 5:
 
1 1 1
,
G V E
 1 1
V V and E E
 
Graph G
Subgraph G1 Subgraph G2
1 2
,
G G G G
 
Union of Simple Graphs
Definition 10: The union of two simple graphs
is the simple graph , where:
it is denoted by

   
1 1 1 2 2 2
, ,
G V E and G V E
 
 
,
G V E

1 2 1 2
V V V and E E E
   
1 2
G G G
 
Union of Simple Graphs
The Star of David G in Example 4 is the union of
the graphs G1 and G2 .
Example 6:
 
Complement of simple
graph
Definition 11: The complement of simple
graph
G is a simple graph G' containing all vertices in
G;
two vertices are adjacent in G' if they are not
adjacent in G 
Example 6:
A A
B B
C C
D
D
G  G
Adjacency matrix
Definition 12: The adjacency matrix of a
undirected graph with n vertices
is an matrix , where
= number of edges from 
Because every edge in a graph is undirected, for
every i and j: , so the adjacency matrix
of every undirected graph is symmetric.
 
1 2
, ,... n
u u u
n n
  
,
i j
A a
 ,
i j
a
i j
u to u
, ,
i j j i
a a

Adjacency matrix
Example 7: Adjacency matrix of the Konigsberg
bridge model in Figure 1 is
 
 
 
 
deg'
0 2 1 0 deg 3
2 0 1 2 deg 5
1 1 0 1 deg 3
0 2 1 0 deg 3
A B C D s
A A
B B
C C
D D




Adjacency matrix
Example 8: Adjacency matrix of the Utilities
problem
in Figure 2 is
0 0 0 1 1 1
0 0 0 1 1 1
0 0 0 1 1 1
1 1 1 0 0 0
1 1 1 0 0 0
1 1 1 0 0 0
A B C G W E
A
B
C
G
W
E
Adjacency matrix
(directed graph)
Definition 13: The adjacency matrix of a
directed multigraph with n vertices
is an matrix , where =
= number of edges runs from 
Example 9:
 
1 2
, ,... n
u u u
n n
  
,
i j
A a
 ,
i j
a
i j
u to u
U1
U2
U3
1 2 3
1
2
3
row sums
( deg)
0 0 1 1
2 0 0 2
0 1 1 2
column sums
2 1 2
( deg)
U U U
out
U
U
U
in
Incidence matrix
Definition 14: The incidence matrix of an
undirected graph with “n” vertices:
and “m” adges: is an
matrix , where

 
1 2
, ,..., n
u u u
 
1 2
, ,..., m
e e e n m

 
,
i j
M m

,
1
0
j i
i j
if edge e is incident with v
m
otherwise



Incidence matrix
Example 10: Incidence matrix of the
Konigsberg
bridge model in Figure 1 is
1 2 3 4 5 6 7
1 1 0 0 0 1 0
1 1 1 1 1 0 0
0 0 0 0 1 1 1
0 0 1 1 0 0 1
A
B
C
D
Incidence matrix
Example 11:
V1
V2
V3
V4
E1
E3
E2
E4
E5
1 2 3 4 5
1
2
3
4
1 0 0 1 0
1 1 1 0 0
0 0 1 0 0
0 1 0 1 1
E E E E E
V
V
V
V
Isomorphic Graphs
Definition 15: Two simple graphs, G1 = (V1,E1)
and G2 = (V2,E2) are isomorphic if a bijection
exists such that {a, b} is an edge in E1 if and only
if {f(a),f(b)} is an edge in E2, for any two elements
a and b in V1. The function “f” is an isomorphism
between G1 and G1 
1 2
:
f V V

Isomorphic Graphs
Isomorphism invariants:
1)
2)
3) deg(a)=deg(f(a)) for any “a” in V1
4) if {a,b} is an edge in E1 , then {f(a),f(b)} must
be an edge in E2, and vice versa
1 2
V V

1 2
E E

Isomorphic Graphs
Example 11: Determine whether the graphs G
and H are isomorphic.
A
B
C
D
U
V
W
Z
G H
Isomorphic Graphs
Example 12: Determine whether the graphs G
and H are isomorphic.
A
B C
D
E
U
V
W
Z
K
G H
Path in undirected graph
Definition 16: Let V0 and Vn be two vertices in
an undirected graph. A path of length “n”
from V0 to Vn is a sequence of vertices and edges
of the form:
{V0, e1, V1, e2, V2,…, Vn-1, en, Vn},
where each edge ei is incident with the vertices Vi-1
and Vi for i=1,2,…,n. If the graph is simple, the
path is uniquely determined by the vertices along
the path: {V0, V1, V2,…, Vn-1, Vn}.
Path in undirected graph
A path is simple, if it does not contain the same
edge more then once.
A path is circuit, if it begins and ends at the
same
vertex 
eee
V1
V0 V2
V3
V2
V1
V0
V3
e1 e2
e3
e4
e5
e7
e6
e8
Paths and isomorphism
Theorem 4: A simple circuit of length “k” (k>2)
is an isomorphic invariant 
Path in directed multigraph
Definition 17: Let V0 and Vn be two vertices in
a directed multigraph. A path of length “n”
from V0 to Vn is a sequence of vertices and
edges of the form:
{V0, e1, V1, e2, V2,…, Vn-1, en, Vn},
where each directed edge ei goes from the
vertex
Vi-1 to the vertex Vi for i=1,2,…,n. If the graph is
digraph, the path is uniquely determined by its
vertex sequence: {V0, V1, V2,…, Vn-1, Vn}.
Path in directed multigraph
A path is simple, if it does not contain the same
edge more then once.
A path is circuit, if it begins and ends at the
same
vertex 
V0
V1
V2
V3
1 2
3
4
Connectedness
Definition 18: An undirected graph is
connected if there is a path between every two
distinct vertices of the graph; otherwise, it is
disconnected 
Theorem 5: There is a simple path between any
two distinct vertices in a connected graph 
Connectedness
Definition 18: A directed graph is strongly
connected if there is a path between every two
distinct vertices of the graph.
A directed graph is weakly connected if there
is connected the underlying undirected graph

A
B
C
D
E
Number of paths of length
“k”
Theorem 6: Let A be the adjacency matrix of an
arbitrary graph with “n” vertices V1, V2,…,Vn , and
“k” a positive integer <n. The number of paths
of length k from Vi to Vj equals -the (i,j)
entry of 
( )
,
k
i j
a
k
A
a
b c
d
0 1 1 0
1 0 2 0
1 2 0 1
0 0 1 0
a b c d
a
A b
c
d

Figure 3.
Number of paths of length
“k”
2
2 2 2 1
2 5 1 2
2 1 6 0
1 2 0 1
A
 
 
 

 
 
 
3
4 6 7 2
6 4 14 1
7 14 4 6
2 1 6 0
A
 
 
 

 
 
 
Number of paths of length
“k”
Theorem 7: Let A be the adjacency matrix of a
graph with n vertices and k a positive integer < n.
The (i,j)-th entry of the matrix
gives the number of paths of length k from
vertex Vi to vertex Vj 
2
... k
A A A
  

Number of paths of length
“k”
As an example, for the graph in Figure 3:
2 3
6 9 10 3
9 9 17 3
10 17 10 7
3 3 7 1
a b c d
a
A A A b
c
d
  
Number of paths of length “k”
How Theorem 6 can be used:
1) To determine whether a graph is
connected?
2) To find the length of the shortest path
between two vertices?
Eulerian graph
Definition 19: An Eulerian path in a graph G is a
simple path, containing every edge of G.
An Eulerian circuit in a graph G is a simple circuit,
containing every edge of G.
A graph with an Eulerian circuit is an Eulerian
graph 
Theorem 8: A multygraph without isolated vertices
has an Eularian circuit if and only if it is connected
and each of its vertices has even degree 
Eulerian graph
Example 13: Determine whether the graphs are
Eulerian:
A
C
D
B
A
B
C D
A B
C D
G K H
Eulerian graph
Example 14: Mohammed’s scimitars
Eulerian graph
Theorem 8: A multygraph without isolated
vertices has an Eularian path if and only if it is
connected and has exactly two vertices of odd
degree 
A B
C
D
A B
C
D A
B C
D
Hamiltonian graph
Definition 20: A Hamiltonian path in a graph
G is a simple path, containing every vertex of G
exactly once.
A Hamiltonian circuit in a graph G is a simple
circuit, containing every vertex of G exactly once.
A graph with a Hamiltonian circuit is a
Hamiltonian graph 
Hamiltonian graph
Corollary:
Corollary: The complete graph Kn is a
Hamiltonian 
Necessary conditions:
1) A Hamiltonian graph is connected.
2) If G has a Hamiltonian cycle, then for all vertex v
of G: .
3) If deg(v) > 2, then as we try to build a Hamilton
cycle, once we pass through vertex v, any unused
edges incident with v are deleted from further
consideration 
 
deg 2
v 
Hamiltonian graph
Sufficient conditions:
Theorem 9: (Ore’s Theorem,1960) Let G be a
multygraph with n vertices and
for all nonadjacent vertices u and v of G, then G
contains a Hamiltonian cycle 
   
deg deg
u v n
 
Hamiltonian graph
Theorem 10: (Dirac's Theorem) Let G be a
multygraph with n vertices and
for every vertex v in G, then graph G contains a
Hamiltonian cycle 
 
deg
2
n
v 
Hamiltonian graph
Theorem 11: Let G be a multygraph with n
vertices and
for all vertices u and v of G: , then G
contains a Hamiltonian path 
   
deg deg 1
u v n
  
u v

Traveling
Salesperson Problem
Here a traveling salesperson leaves his or her home
and must visit certain locations before returning. The
objective is to find an order in which to visit the
Locations that is most efficient (perhaps in terms of
total distance traveled or total cost). The problem
can be modeled with a labeled (edges have distances
or costs associated with them) graph where the most
efficient Hamiltonian cycle is sought.
The nearest neighbor's
algorithm
Examples
A B
C
A1 B1
C1
Hypercube (or n-cube)
Examples: find an Eulerian
(Hamiltonian) cycle, if one exists
Examples: find an Eulerian
(Hamiltonian) cycle, if one exists
Examples: find an Eulerian
(Hamiltonian) cycle, if one exists
Examples: find an Eulerian
(Hamiltonian) cycle, if one exists
Planar graphs
Definition 21: A simple graph G is called planar
if exists a graph G’ (called a planar representa-
tion of G) such that its edges intersecting only at
vertices, and graphs G and G’ are isomorphic 
K4 Planar representations of K4
Planar graphs
G Planar representation of G
Q5 Planar representation of Q5
Planar graphs
?
K5 K3,3 (The utilities problem)
Euler’s formula
Definition 22: A region in a planar
representation
G’ is a part of the plane, bounded by a circuit in G’

Planar representations of K4
R1
R2
R3
R4 R4
R1
R2
R3
Euler’s formula
Theorem 12: Let G be a connected planar graph
with “e” edges and “v” vertices. Let “r” be the
number of regions formed by a planar
representation of G. Then r = e - v + 2 
Corollary 1:
Corollary 1: If G is a connected, planar graph
that contains “e” (>1) edges and “v” vertices, then



3 6
e v
 
Corollary 2:
Corollary 2: If G is a connected, planar graph
that contains “e” (>2) edges, “v” vertices and no
circuits of length 3, then 
2 4
e v
 
Euler’s formula
Euler’s formula
Corollary 1 for the K
Corollary 1 for the K5
5:
: e=10, v=5;
Corollary 1 for the K
Corollary 1 for the K3,3
3,3:
: e=9, v=6;
Corollary 2 for the K
Corollary 2 for the K3,3
3,3:
: e=9, v=6;
K
K5
5 and K
and K3,3
3,3 are nonplanar
are nonplanar
 
10 3 5 6 9 ?
   
 
9 3 6 6 12 !
   
 
9 2 6 4 8 ?
   

Homeomorphic Graphs
Definition 23: 1) Let {u,w} be an edge in a graph.
Make a vertex “v” of degree two by deleting the edge
{u,w} and adding two edges {u,v} and {v,w} incident
with “v”.
2) Now, delete v and replace the two edges with an
edge {u, w}.
Such inserting and deleting of vertices of degree two
are elementary operations on a graph.Two graphs
are homeomorphic if one can be obtained from the
other by a sequence of elementary operations 
Homeomorphic Graphs
Theorem 12: (Kuratowski's theorem) A graph is planar if
and only if it does not contain a subgraph homeomorphic
to K5 or K3,3. Equivalently, a graph is nonplanar if and
only if it contains a subgraph homeomorphic to K5 or
K3,3 
v
u
w
z
u
z
w
u
v
w
z
Elementary operations. Homeomorphic graphs
The Petersen Graph
Petersen graph Graph homeomorphic to K3,3
Homeomorphic Graphs
f
g
h
k
m
Graph homeomorphic to K5 K5
Trees
Definition 24: A tree is a connected undirected
graph with no simple circuits 
Trees
Corollary:
Corollary: A tree cannot contain multiple edges
or loops. Therefore any tree must be a simple
Graph 
Theorem 13: An undirected graph is a tree if and
only if there is a unique, simple path between any
two vertices 
Theorem 14: An undirected graph T=(V,E) with
|V|=n verticesis is a tree if and only if it has exactly
n –1 edges (|E|=n-1) 
Rooted Trees
Definition 25: If T is a directed graph, then T is
called a directed tree if the underlying ndirected
graph is a tree.
When T is a directed tree, T is called a rooted
tree if there is a unique vertex “r”, called the
root in T, with the , and for all other
vertices “v”, the

 
deg 0
in r 
 
deg 1
in v 
Rooted Trees
Definition 26: In a rooted tree, a vertex “v” with
is called a leaf (or terminal vertex).
All other vertices are called internal vertices.
The level of a vertex “v” in a rooted tree is the length
of the unique directed path from the root to v.
The height of a rooted tree is the maximum of the
levels of vertices. A rooted tree T of height “h” is said
to be balanced if the level number of every leaf in T
is h-1 or h.
Let “u” and “v” are two vertices in a rooted tree T, “u”
is a parent of “v” (v is a child of u) if there is a
directed edge (u,v) from u to v in T.
The ancestors of v are the vertices in the path from
the root to v (excluding v and including the root).
 
deg 0
out v 
Rooted Trees
The descendants of a vertex v are those vertices
that have v as an ancestor.
Two vertices with a common parent are referred to
as siblings 
Definition 27: Let T=(V, E) be a rooted tree, and
let “m” is any natural number. We call T an m-ary
tree if
When m = 2, the tree is called a binary tree.
 
deg
out v m for all v V
 
Rooted Trees
If
then T is called a full (complete) m-ary tree. The
special case of m = 2 results in a full binary tree.
In a full m-ary tree, each internal vertex has
exactly
m children; each leaf of this tree still has no
children 
   
deg 0 deg
out v or out v m for all v V
  
Rooted Trees
Theorem 15: Let T = (V, E) be a full m-ary tree
with |V| = n. If T has “l” leaves and “i” internal
vertices, then

Example 15: The Wimbledon tennis championship is a
single-elimination tournament wherein a player is eliminated
after a single loss. If 32 women compete in the singles
championship, how many matches must be played to
determine the number-one female player? How many
matches must be played by the champion?
1
n i m and n i l
    
The Wimbledon tennis championship
l=32, m=2,
i-? h-?
i=(l-1)/(m-
1)=
=26,
2
log
log 32 5
m
h l
 
 
Rooted Trees
Example 16: A classroom contains 25
microcomputers that must be connected to a
wall
socket that has four outlets. Connections are
made
by using extension cords that have four outlets
each. What is the least number of cords needed
to
get these computers set up for class use?
l=25, m=4, i-?
i=(l-1)/(m-1)=8,
answer=i-1=7.

GRAPHS data analysis GRAPHS data analysi

  • 1.
  • 2.
    The seven bridgesof Konigsberg Problem 1: The City of Konigsberg (in the early eighteenth century) comprises the river banks A and D and the islands B and C. These four land areas are connected by seven bridges. Could a Konigsbergian take a walk through the city passing over each bridge exactly once and return home? In 1736, Euler, while at St. Petersburg Academy, published a solution to the problem: No such walk is possible. (Figure 1.)
  • 3.
    The seven bridgesof Konigsberg Figure 1. 1 2 3 4 5 6 7
  • 4.
    The utilities problem Problem2: An old problem concerns three houses А, В, С which are to be joined to each of the three utilities: gas (G), water (W) and electricity (E) without any two connections crossing each other. In other words, can the diagram of Figure 2 be redrawn so that no two lines cross?
  • 5.
  • 6.
    Computer programming flowchart Example 1:Computer programming flowchart (is a strict digraph): Each vertex represents some programmed operation or decision, and each arc represents the flow of control to the next operation or decision.
  • 7.
    A food web Example2: A food web is a strict digraph in which nodes represent species and in which there is an arc from U to V if species U eats species V.
  • 8.
    Undirected Graphs Definition 1:A pseudograph (or undirected graph) G is the ordered pair G=(V,E) of two sets: a nonempty finite set V, which elements called vertices (or nodes) and a set E, which elements called edges (or arcs). In case of pseudograph, set E is the domain of any function F from E to the set of unordered pairs:     , | , u v u v V 
  • 9.
    Undirected Graphs An edgeis a loop if . The edges are multiple (or parallel) edges if  Geometrically, vertices are represented by points and the edges by lines (not necessarily straight) joining pairs of points.     , F e u u  e E  1 2 e and e     1 2 F e F e 
  • 10.
    Undirected Graphs Example ofpseudograph: Loop Parallel edges Parallel edges
  • 11.
    Undirected Graphs Definition 2:A multigraph is a pseudograph without loops  Example of multigraph: Parallel edges Parallel edges
  • 12.
    Undirected Graphs Definition 3:A simple graph is a pseudograph without loops and multiple edges  Example of simple graph:
  • 13.
    Directed Graphs Definition 4:A directed multigraph G is the ordered pair G=(V,E) of two sets: a nonempty finite set V, which elements called vertices (or nodes) and a set E, which elements called directed edges (or arcs). In case of directed multigraph, set E is the domain of any function F from E to the set of ordered pairs:      , | , u v u v V 
  • 14.
    Directed Graphs Example ofdirected multigraph : Loop Parallel edges Parallel edges
  • 15.
    Directed Graphs Definition 4:A directed graph (digraph) is a directed multigraph without multiple edges  Example of digraph: Loop
  • 16.
  • 17.
    Graph Terminology Type EdgesMultiple Edges allowed? Loops allowed? Pseudograp Multigraph Simple Graph Directed multigraph Digraph Undirected Undirected Undirected Directed Directed Yes Yes No Yes No Yes No No Yes Yes
  • 18.
    Adjacent vertices Definition 5:Two vertices u and v in a undirected graph are adjacent if an edge (e) runs between them: If a loop (e) occurs at u, then u is adjacent to itself: An isolated vertex is not adjacent to any vertex    : , F e u v    : , F e u u 
  • 19.
    Incidents and Degreeof a vertex Definition 6: If a vertex v (in a undirected graph) is an endpoint of the edge e, then e is incident with a vertex v  Definition 7: The degree of a vertex v (denoted by deg(v)) in a undirected graph is the number of edges incident with v. If a vertex v is isolated, then deg (v) = 0. A loop at a vertex contributes twice to the degree of that vertex 
  • 20.
    The following Theoremestablishes a relationship between the sum of the degrees of the vertices of a graph and the number of edges in it. Theorem 1: Let “e” denote the number of edges of an undirected graph with n vertices Then:  Corollary: Corollary: The sum of the degrees in an undirected graph is always an even integer    1 2 , ,... n u u u   1 deg 2 n i i u e   
  • 21.
    Example 3: Isa graph with four vertices a,b,c,d, with deg(a) = 4, deg(b)=deg(d)=5, and deg(c)= 2 possible? The same problem, bat deg(b)=6? Theorem 2: The number of odd degree vertices in an undirected graph is an even integer  For example, the Konigsberg model in Figure 1 contains four vertices of odd degree.
  • 22.
    Degree of avertex (directed graph) Definition 8: The indegree of a vertex v (denoted by indeg(v)) in a directed multigraph is the number of directed edges terminating at v. The outdegree of a vertex v (denoted by outdeg(v)) in a directed multigraph is the number of directed edges leaving v. The degree of v, or deg(v), is the sum of its indegree and outdegree:        deg deg deg v in v out v  
  • 23.
    Degree of avertex (directed graph) Example 4: 1 2 3 4 1 2 3 4 5 Indegree 1 4 2 1 0 Outdegre e 1 2 2 2 1 Degree 2 6 4 3 1 5
  • 24.
      1 2 ,,... n u u u Theorem 3: Let “e” denote the number of edges of a directed multigraph with “n” vertices , Then:      1 1 deg deg n n i i i i in u out u e       Degree of a vertex (directed graph)   1 deg 2 n i i u e   
  • 25.
    Subgraph Definition 9: Asubgraph of a graph G = (V,E) is a graph , where  Example 5:   1 1 1 , G V E  1 1 V V and E E   Graph G Subgraph G1 Subgraph G2 1 2 , G G G G  
  • 26.
    Union of SimpleGraphs Definition 10: The union of two simple graphs is the simple graph , where: it is denoted by      1 1 1 2 2 2 , , G V E and G V E     , G V E  1 2 1 2 V V V and E E E     1 2 G G G  
  • 27.
    Union of SimpleGraphs The Star of David G in Example 4 is the union of the graphs G1 and G2 . Example 6:  
  • 28.
    Complement of simple graph Definition11: The complement of simple graph G is a simple graph G' containing all vertices in G; two vertices are adjacent in G' if they are not adjacent in G  Example 6: A A B B C C D D G  G
  • 29.
    Adjacency matrix Definition 12:The adjacency matrix of a undirected graph with n vertices is an matrix , where = number of edges from  Because every edge in a graph is undirected, for every i and j: , so the adjacency matrix of every undirected graph is symmetric.   1 2 , ,... n u u u n n    , i j A a  , i j a i j u to u , , i j j i a a 
  • 30.
    Adjacency matrix Example 7:Adjacency matrix of the Konigsberg bridge model in Figure 1 is         deg' 0 2 1 0 deg 3 2 0 1 2 deg 5 1 1 0 1 deg 3 0 2 1 0 deg 3 A B C D s A A B B C C D D    
  • 31.
    Adjacency matrix Example 8:Adjacency matrix of the Utilities problem in Figure 2 is 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 A B C G W E A B C G W E
  • 32.
    Adjacency matrix (directed graph) Definition13: The adjacency matrix of a directed multigraph with n vertices is an matrix , where = = number of edges runs from  Example 9:   1 2 , ,... n u u u n n    , i j A a  , i j a i j u to u U1 U2 U3 1 2 3 1 2 3 row sums ( deg) 0 0 1 1 2 0 0 2 0 1 1 2 column sums 2 1 2 ( deg) U U U out U U U in
  • 33.
    Incidence matrix Definition 14:The incidence matrix of an undirected graph with “n” vertices: and “m” adges: is an matrix , where    1 2 , ,..., n u u u   1 2 , ,..., m e e e n m    , i j M m  , 1 0 j i i j if edge e is incident with v m otherwise   
  • 34.
    Incidence matrix Example 10:Incidence matrix of the Konigsberg bridge model in Figure 1 is 1 2 3 4 5 6 7 1 1 0 0 0 1 0 1 1 1 1 1 0 0 0 0 0 0 1 1 1 0 0 1 1 0 0 1 A B C D
  • 35.
    Incidence matrix Example 11: V1 V2 V3 V4 E1 E3 E2 E4 E5 12 3 4 5 1 2 3 4 1 0 0 1 0 1 1 1 0 0 0 0 1 0 0 0 1 0 1 1 E E E E E V V V V
  • 36.
    Isomorphic Graphs Definition 15:Two simple graphs, G1 = (V1,E1) and G2 = (V2,E2) are isomorphic if a bijection exists such that {a, b} is an edge in E1 if and only if {f(a),f(b)} is an edge in E2, for any two elements a and b in V1. The function “f” is an isomorphism between G1 and G1  1 2 : f V V 
  • 37.
    Isomorphic Graphs Isomorphism invariants: 1) 2) 3)deg(a)=deg(f(a)) for any “a” in V1 4) if {a,b} is an edge in E1 , then {f(a),f(b)} must be an edge in E2, and vice versa 1 2 V V  1 2 E E 
  • 38.
    Isomorphic Graphs Example 11:Determine whether the graphs G and H are isomorphic. A B C D U V W Z G H
  • 39.
    Isomorphic Graphs Example 12:Determine whether the graphs G and H are isomorphic. A B C D E U V W Z K G H
  • 40.
    Path in undirectedgraph Definition 16: Let V0 and Vn be two vertices in an undirected graph. A path of length “n” from V0 to Vn is a sequence of vertices and edges of the form: {V0, e1, V1, e2, V2,…, Vn-1, en, Vn}, where each edge ei is incident with the vertices Vi-1 and Vi for i=1,2,…,n. If the graph is simple, the path is uniquely determined by the vertices along the path: {V0, V1, V2,…, Vn-1, Vn}.
  • 41.
    Path in undirectedgraph A path is simple, if it does not contain the same edge more then once. A path is circuit, if it begins and ends at the same vertex  eee V1 V0 V2 V3 V2 V1 V0 V3 e1 e2 e3 e4 e5 e7 e6 e8
  • 42.
    Paths and isomorphism Theorem4: A simple circuit of length “k” (k>2) is an isomorphic invariant 
  • 43.
    Path in directedmultigraph Definition 17: Let V0 and Vn be two vertices in a directed multigraph. A path of length “n” from V0 to Vn is a sequence of vertices and edges of the form: {V0, e1, V1, e2, V2,…, Vn-1, en, Vn}, where each directed edge ei goes from the vertex Vi-1 to the vertex Vi for i=1,2,…,n. If the graph is digraph, the path is uniquely determined by its vertex sequence: {V0, V1, V2,…, Vn-1, Vn}.
  • 44.
    Path in directedmultigraph A path is simple, if it does not contain the same edge more then once. A path is circuit, if it begins and ends at the same vertex  V0 V1 V2 V3 1 2 3 4
  • 45.
    Connectedness Definition 18: Anundirected graph is connected if there is a path between every two distinct vertices of the graph; otherwise, it is disconnected  Theorem 5: There is a simple path between any two distinct vertices in a connected graph 
  • 46.
    Connectedness Definition 18: Adirected graph is strongly connected if there is a path between every two distinct vertices of the graph. A directed graph is weakly connected if there is connected the underlying undirected graph  A B C D E
  • 47.
    Number of pathsof length “k” Theorem 6: Let A be the adjacency matrix of an arbitrary graph with “n” vertices V1, V2,…,Vn , and “k” a positive integer <n. The number of paths of length k from Vi to Vj equals -the (i,j) entry of  ( ) , k i j a k A a b c d 0 1 1 0 1 0 2 0 1 2 0 1 0 0 1 0 a b c d a A b c d  Figure 3.
  • 48.
    Number of pathsof length “k” 2 2 2 2 1 2 5 1 2 2 1 6 0 1 2 0 1 A              3 4 6 7 2 6 4 14 1 7 14 4 6 2 1 6 0 A             
  • 49.
    Number of pathsof length “k” Theorem 7: Let A be the adjacency matrix of a graph with n vertices and k a positive integer < n. The (i,j)-th entry of the matrix gives the number of paths of length k from vertex Vi to vertex Vj  2 ... k A A A    
  • 50.
    Number of pathsof length “k” As an example, for the graph in Figure 3: 2 3 6 9 10 3 9 9 17 3 10 17 10 7 3 3 7 1 a b c d a A A A b c d   
  • 51.
    Number of pathsof length “k” How Theorem 6 can be used: 1) To determine whether a graph is connected? 2) To find the length of the shortest path between two vertices?
  • 52.
    Eulerian graph Definition 19:An Eulerian path in a graph G is a simple path, containing every edge of G. An Eulerian circuit in a graph G is a simple circuit, containing every edge of G. A graph with an Eulerian circuit is an Eulerian graph  Theorem 8: A multygraph without isolated vertices has an Eularian circuit if and only if it is connected and each of its vertices has even degree 
  • 53.
    Eulerian graph Example 13:Determine whether the graphs are Eulerian: A C D B A B C D A B C D G K H
  • 54.
    Eulerian graph Example 14:Mohammed’s scimitars
  • 55.
    Eulerian graph Theorem 8:A multygraph without isolated vertices has an Eularian path if and only if it is connected and has exactly two vertices of odd degree  A B C D A B C D A B C D
  • 56.
    Hamiltonian graph Definition 20:A Hamiltonian path in a graph G is a simple path, containing every vertex of G exactly once. A Hamiltonian circuit in a graph G is a simple circuit, containing every vertex of G exactly once. A graph with a Hamiltonian circuit is a Hamiltonian graph 
  • 57.
    Hamiltonian graph Corollary: Corollary: Thecomplete graph Kn is a Hamiltonian  Necessary conditions: 1) A Hamiltonian graph is connected. 2) If G has a Hamiltonian cycle, then for all vertex v of G: . 3) If deg(v) > 2, then as we try to build a Hamilton cycle, once we pass through vertex v, any unused edges incident with v are deleted from further consideration    deg 2 v 
  • 58.
    Hamiltonian graph Sufficient conditions: Theorem9: (Ore’s Theorem,1960) Let G be a multygraph with n vertices and for all nonadjacent vertices u and v of G, then G contains a Hamiltonian cycle      deg deg u v n  
  • 59.
    Hamiltonian graph Theorem 10:(Dirac's Theorem) Let G be a multygraph with n vertices and for every vertex v in G, then graph G contains a Hamiltonian cycle    deg 2 n v 
  • 60.
    Hamiltonian graph Theorem 11:Let G be a multygraph with n vertices and for all vertices u and v of G: , then G contains a Hamiltonian path      deg deg 1 u v n    u v 
  • 61.
    Traveling Salesperson Problem Here atraveling salesperson leaves his or her home and must visit certain locations before returning. The objective is to find an order in which to visit the Locations that is most efficient (perhaps in terms of total distance traveled or total cost). The problem can be modeled with a labeled (edges have distances or costs associated with them) graph where the most efficient Hamiltonian cycle is sought.
  • 62.
  • 63.
  • 64.
  • 65.
    Examples: find anEulerian (Hamiltonian) cycle, if one exists
  • 66.
    Examples: find anEulerian (Hamiltonian) cycle, if one exists
  • 67.
    Examples: find anEulerian (Hamiltonian) cycle, if one exists
  • 68.
    Examples: find anEulerian (Hamiltonian) cycle, if one exists
  • 69.
    Planar graphs Definition 21:A simple graph G is called planar if exists a graph G’ (called a planar representa- tion of G) such that its edges intersecting only at vertices, and graphs G and G’ are isomorphic  K4 Planar representations of K4
  • 70.
    Planar graphs G Planarrepresentation of G Q5 Planar representation of Q5
  • 71.
    Planar graphs ? K5 K3,3(The utilities problem)
  • 72.
    Euler’s formula Definition 22:A region in a planar representation G’ is a part of the plane, bounded by a circuit in G’  Planar representations of K4 R1 R2 R3 R4 R4 R1 R2 R3
  • 73.
    Euler’s formula Theorem 12:Let G be a connected planar graph with “e” edges and “v” vertices. Let “r” be the number of regions formed by a planar representation of G. Then r = e - v + 2  Corollary 1: Corollary 1: If G is a connected, planar graph that contains “e” (>1) edges and “v” vertices, then    3 6 e v  
  • 74.
    Corollary 2: Corollary 2:If G is a connected, planar graph that contains “e” (>2) edges, “v” vertices and no circuits of length 3, then  2 4 e v   Euler’s formula
  • 75.
    Euler’s formula Corollary 1for the K Corollary 1 for the K5 5: : e=10, v=5; Corollary 1 for the K Corollary 1 for the K3,3 3,3: : e=9, v=6; Corollary 2 for the K Corollary 2 for the K3,3 3,3: : e=9, v=6; K K5 5 and K and K3,3 3,3 are nonplanar are nonplanar   10 3 5 6 9 ?       9 3 6 6 12 !       9 2 6 4 8 ?     
  • 76.
    Homeomorphic Graphs Definition 23:1) Let {u,w} be an edge in a graph. Make a vertex “v” of degree two by deleting the edge {u,w} and adding two edges {u,v} and {v,w} incident with “v”. 2) Now, delete v and replace the two edges with an edge {u, w}. Such inserting and deleting of vertices of degree two are elementary operations on a graph.Two graphs are homeomorphic if one can be obtained from the other by a sequence of elementary operations 
  • 77.
    Homeomorphic Graphs Theorem 12:(Kuratowski's theorem) A graph is planar if and only if it does not contain a subgraph homeomorphic to K5 or K3,3. Equivalently, a graph is nonplanar if and only if it contains a subgraph homeomorphic to K5 or K3,3  v u w z u z w u v w z Elementary operations. Homeomorphic graphs
  • 78.
    The Petersen Graph Petersengraph Graph homeomorphic to K3,3
  • 79.
  • 80.
    Trees Definition 24: Atree is a connected undirected graph with no simple circuits 
  • 81.
    Trees Corollary: Corollary: A treecannot contain multiple edges or loops. Therefore any tree must be a simple Graph  Theorem 13: An undirected graph is a tree if and only if there is a unique, simple path between any two vertices  Theorem 14: An undirected graph T=(V,E) with |V|=n verticesis is a tree if and only if it has exactly n –1 edges (|E|=n-1) 
  • 82.
    Rooted Trees Definition 25:If T is a directed graph, then T is called a directed tree if the underlying ndirected graph is a tree. When T is a directed tree, T is called a rooted tree if there is a unique vertex “r”, called the root in T, with the , and for all other vertices “v”, the    deg 0 in r    deg 1 in v 
  • 83.
  • 84.
    Definition 26: Ina rooted tree, a vertex “v” with is called a leaf (or terminal vertex). All other vertices are called internal vertices. The level of a vertex “v” in a rooted tree is the length of the unique directed path from the root to v. The height of a rooted tree is the maximum of the levels of vertices. A rooted tree T of height “h” is said to be balanced if the level number of every leaf in T is h-1 or h. Let “u” and “v” are two vertices in a rooted tree T, “u” is a parent of “v” (v is a child of u) if there is a directed edge (u,v) from u to v in T. The ancestors of v are the vertices in the path from the root to v (excluding v and including the root).   deg 0 out v 
  • 85.
    Rooted Trees The descendantsof a vertex v are those vertices that have v as an ancestor. Two vertices with a common parent are referred to as siblings  Definition 27: Let T=(V, E) be a rooted tree, and let “m” is any natural number. We call T an m-ary tree if When m = 2, the tree is called a binary tree.   deg out v m for all v V  
  • 86.
    Rooted Trees If then Tis called a full (complete) m-ary tree. The special case of m = 2 results in a full binary tree. In a full m-ary tree, each internal vertex has exactly m children; each leaf of this tree still has no children      deg 0 deg out v or out v m for all v V   
  • 87.
    Rooted Trees Theorem 15:Let T = (V, E) be a full m-ary tree with |V| = n. If T has “l” leaves and “i” internal vertices, then  Example 15: The Wimbledon tennis championship is a single-elimination tournament wherein a player is eliminated after a single loss. If 32 women compete in the singles championship, how many matches must be played to determine the number-one female player? How many matches must be played by the champion? 1 n i m and n i l     
  • 88.
    The Wimbledon tennischampionship l=32, m=2, i-? h-? i=(l-1)/(m- 1)= =26, 2 log log 32 5 m h l    
  • 89.
    Rooted Trees Example 16:A classroom contains 25 microcomputers that must be connected to a wall socket that has four outlets. Connections are made by using extension cords that have four outlets each. What is the least number of cords needed to get these computers set up for class use? l=25, m=4, i-? i=(l-1)/(m-1)=8, answer=i-1=7.