Professional Documents
Culture Documents
13 - Graph
13 - Graph
CSCI1303
Mathematics for Computing I
CSCI1303 - Mathematics for Computing I Graph
Definition: Graph
A graph
𝐺 = 𝑉, 𝐸, 𝛾
consists of
a finite set 𝑉 of objects called vertices,
a finite set 𝐸 of objects called edges, and
a function 𝛾 that assigns to each edge a subset 𝑣, 𝑤 ,
where 𝑣 and 𝑤 are vertices (and may be the same).
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
Example: Graph
Let
Then the graph 𝑮 = 𝑽, 𝑬, 𝜸 can be
𝑉 = 1,2,3,4 represented as the following structures
𝐸 = 𝑒1 , 𝑒2 , 𝑒3 , 𝑒4 , 𝑒5
𝛾 𝑒1 = 𝛾 𝑒5 = 1,2 1 2 1 2
𝛾 𝑒2 = 4,3
3 4 4 3
𝛾 𝑒3 = 1,3
𝛾(𝑒4 ) = 2,4 𝑮 = { 𝟏, 𝟐 , 𝟒, 𝟑 , 𝟏, 𝟑 , 𝟐, 𝟒 }
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
Definition: degree
Degree
number of edges having the specified vertex
as an end point
A B deg(A) = 3
deg(B) = 3
E C deg(C) = 1
deg(D) = 3
D deg(E) = 2
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
Definition: loop
Loop
an edge from a vertex to itself
A B
E C
D
loop
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
Definition: Path
A path 𝑝 in a graph 𝐺 consists of a pair 𝑉𝑝 , 𝐸𝑝 :
• 𝑉𝑝 ∶ 𝑣1 , 𝑣2 , … , 𝑣𝑘 is a vertex sequence
• 𝐸𝑝 ∶ 𝑒1 , 𝑒2 , … , 𝑒𝑘−1 is an edge sequence
where
1. Each successive pair 𝑣𝑖 , 𝑣𝑖+1 of vertices is adjacent in
𝐺,
2. and edge 𝑒𝑖 has 𝑣𝑖 and 𝑣𝑖+1 as end points for 𝑖 =
1, 2, … , 𝑘 − 1;
3. No edge occurs more than once in the edge sequence.
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
Simple
a path which has no vertex appears more than
once in the vertex sequence, except possibly if
𝑣1 = 𝑣𝑘
In this case, the path is called a simple circuit
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
connected
Component
• Subgraphs in a C
disconnected graph
are considered as D
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
Types of Graph
Discrete graph
A discrete graph on 𝑛 vertices, denoted by 𝑼𝒏 , is a
graph with 𝒏 vertices {𝑣1 , 𝑣2 , …, 𝑣𝑛 } and no edges
𝑼𝟐 𝑼𝟓
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
Types of Graph
Linear graph
A linear graph on 𝑛 vertices, denoted by 𝑳𝒏 , is a
graph with 𝒏 vertices 𝑣1 , 𝑣2 , … , 𝑣𝑛 and edges
𝑣𝑖 , 𝑣𝑖+1 for 𝑖 = 1,2, … , 𝑛
𝑼𝟐 𝑼𝟓
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
Types of Graph
Complete graph
A complete graph on 𝑛 vertices, denoted by
𝐾𝑛 , is a graph with 𝑛 vertices 𝑣1 , 𝑣2 , … , 𝑣𝑛
and with an edge for every 𝑖 and 𝑗
Example of Complete Graph
𝐾3 𝐾4 𝐾5
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
Euler path
is a path (in a graph, 𝐺) that contains every
edge (of graph 𝐺) exactly once
Euler circuit
is a circuit (in a graph, 𝐺) containing every
edge (of graph 𝐺) exactly once
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
1
A 2
Has Euler path:
E = {A, B, D, C} one of possible
paths
B C
Has Euler circuit:
3
D
4 E = {A, B, D, C} one of possible Euler
paths
G = {{1, 2}, {1, 4}, {2, 3}, {3, 4}}
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
1
A 2
No Euler path:
No path containing each edge exactly
E F once
B C
No Euler circuit:
3
D
4 No Euler path
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
Hamilton circuit
is a circuit (in a graph, 𝐺) that contains every
vertex (of graph 𝐺) exactly once except for the
first vertex
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
A C No Hamiltonian circuit:
Hamiltonian path is not a circuit
B
G = {{E, D}, {D, A}, {A, B}, {B, C}, {C, D}}
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
hyaacob@iium.edu.my
CSCI1303 - Mathematics for Computing I Graph
a b
No Hamiltonian path:
Disconnected graph
c
d No Hamiltonian circuit:
Disconnected graph
f e
hyaacob@iium.edu.my