0% found this document useful (0 votes)
9 views

Graph_Lecture2

graph-1-1-1

Uploaded by

raiyun.mushfiq
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Graph_Lecture2

graph-1-1-1

Uploaded by

raiyun.mushfiq
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Graph-2

Mahmuda Naznin
CSE 103
Degree of Vertex
 The degree of a
vertex v, denoted
by (v), is the
number of edges
incident on v
 Example:
– (a) = 4, (b) = 3,
– (c) = 4, (d) = 6,
– (e) = 4, (f) = 4,
– (g) = 3.
Sum of the degrees of
Graph
Theorem : If G is a graph with m edges
and n vertices v1, v2,…, vn, then
n

 (vi) = 2m
i=1

In particular, the sum of the degrees of


all the vertices of a graph is even.
Sum of the degrees of
Let G be a graph. Graph
Case 1: If G is null graph, no vertices, no edges, so degree =0.
Case 2: If G has n vertices v1, v2, v3,...... vn, , n and m edges, m, n >0 and
integer, Each edge of G contributes 2 to the total degree of G.
For example, e is an arbitrarily chosen edge with vi, and vj.
e contributes 1 to the degree of vi and 1 to the degree vj. As shown below,
this is true even if i = j, because an edge that is a loop is counted twice in
computing the degree of the vertex

So, e contributes 2 to the total degree of G. Since e was arbitrarily


chosen, this shows that each edge of G contributes 2 to the total degree
of G. Thus, the total degree of G = 2(the number of edges of G).
Euler Cycle

 An Euler cycle in a graph G


is a simple cycle that passes
through every edge of G only
once.
 The Königsberg bridge
problem:
 Starting and ending at the same point, is it
possible to cross all seven bridges just
once and return to the starting point?
 This problem can be
represented by a graph
 Edges represent bridges and
Cycle
A cycle is a path that begins and ends with same vertex.

a
v
w

cycle: v ···b ···w ···w ···a ···v

also: a ···v ···b ···w ···w ···a


Euler Graphs
 A graph G is an Euler graph if it
has an Euler cycle and it is
connected.
 The connected graph represents
the Konigsberg bridge problem.
 Theorem: G is an Euler graph if
and only if G is connected and
all its vertices have even degree.
 It is not an Euler graph.
 Therefore, the Konigsberg
bridge problem has no solution.
Euler Graphs
Theorem: G is an Euler graph if
and only if G is connected and
all its vertices have even
degree.
Proof:
We assume all edges traverse
through a vertex v.
• So, every edge will be incident
on v only once.
• Entry/exit will contribute 2
for each edge on v.
• Degree will be even
Hamiltonian Cycle
 Traveling salesperson
problem
– To visit every vertex of a
graph G only once by a
simple cycle.
– Such a cycle is called a
Hamiltonian cycle.
– If a connected graph G has
a Hamiltonian cycle, G is
called a Hamiltonian graph.
Hamiltonian Cycle
Example-Traveling
salesperson problem
-To visit every city once with
the minimum distance and
come back to that city
-To visit every vertex of a
graph G once and it is a
Hamiltonian cycle
ABCDA or ADCBA,
min.125km
Isomorphic Graphs
G1 and G2 are isomorphic
 if there exist one-to-one onto functions f: V(G1) → V(G2)
and g: E(G1) → E(G2) such that
 an edge e is adjacent to vertices v, w in G1 if and only if
g(e) is adjacent to f(v) and f(w) in G2
Edge(G1)= Edge (G2)
G1 {a, b}={a′ ,b′}= {f(a) , f(b)}
G2
{a, c}={a′ ,c′}= {f(a) , f(c)}
{a, d}={a′ ,d′}= {f(a) , f(d)}
{a, e}={a′ ,e′}= {f(a) , f(e)}
{e, d}={e′, d′ }= {f(e) , f(d)}
Isomorphic Graphs
Isomorphism and Adjacency Matrices
 Two graphs are
isomorphic if and only if a b c d e
after reordering the a 0 1 1 0 0
vertices their adjacency
b 1 0 0 1 0
matrices are the same
c 1 0 0 0 1
d 0 1 0 0 1
e 0 0 1 1 0
Isomophism Examples

Same graph (different drawings)


122 122
257 145 257
99
306 67

99 67 306 145
Same graph (different labels) Gani
257 122 145 Amina Sifat

306 67 Rahim
Sonya
99 Jesmin
Which is
isomorphic to G1?

ng graph isomorphism is not easy –


own general method to test graph-ismorphism which is
more efficient than checking all possibilities.
Planar Graphs

A graph is planar if
it can be drawn in
the plane without
crossing edges
Applications-Circuit
design, Network
design, VLSI
Design
16
Euler’s Theory for Planar
Graph
 If G is planar graph,
v = number of vertices
e = number of edges
f = number of faces,
including the exterior
face (v=7, e= 13, f=8)
 Then: f=e–v+2

17
Acknowledgement
• Kenneth Rosen
• Susanna Epp (Reading Material)
• Ralph P. Grimaldi, B. V. Ramana
Appendix
Walk : Vertices may repeat.
Edges may repeat (Closed or
Open)
Trail : Vertices may repeat.
Edges cannot repeat (Open)
a
Circuit : Vertices may repeat. v w
Edges cannot repeat (Closed) b
Path : Vertices cannot repeat.
Edges cannot repeat (Open)
Cycle : Vertices cannot repeat.
Closed walk: v ···b ···w ···w ···a
Edges cannot repeat (Closed) ···v
NOTE : For closed sequences Cycle: w..w or
start and end vertices are the w ···a ··· v ···b ···w
only ones that can repeat.
Idea

In general, if we have a “partial” Eulerian cycle C*,


and it intersects with a cycle C on a vertex v,
then we can extend the Eulerian cycle C* to include C.
C* C

First follow C* until we visit v, then follow C until we


go back to v, and then follow C* from v to the end.
Finding Euler Cycle in a
Graph
Firstly, check if the degree of each vertex is even, graph
is connected
C: abcda
We find that C is not an Euler circuit (i)
for the graph (not all edges) and it
intersects the rest of the graph at d (in
(ii)).
Let C' be :deghjid. We patch C' into
(ii)
C to obtain C": abcdeghjida.
Set C = C". Then current C is
represented by the labeled edges in
(iii). (iii)
Finding Euler Cycle in a
Graph
Firstly, check if the degree of each vertex is even, graph
is connected
Let C' be :deghjid. We patch C' into
C to obtain C": abcdeghjida.
Set C = C". Then current C is
represented by the labeled edges in
(iii). (iii)
Still C is not an Euler circuit for the
graph but it intersects the rest of the
graph at e. C': efhe and we patch C'
into C and finally we get C:
abcdefheghjida in (iv) (iv)
Hamiltonian Cycle-Parallel
Computation Model
The n-cube In has 2n processors, n > 1
– Vertices are labeled 0, 1, 2,…, 2n-1
– An edge connects two vertices if the binary representation of their
labels differs in exactly one bit
– The n-cube simulates a ring model with 2n processors if it contains
a simple cycle with 2n vertices which is a Hamiltonian cycle
– The n-cube (n > 2) has a Gray code, therefore it contains a simple
Hamiltonian cycle with 2n vertices, and so it is a model for parallel
computation.
– I1 has only two vertices 0 and 1. It has no cycles.
Parallel Computation Model
– I2 (a square) has 4 vertices
labeled 00, 01, 10 and 11
– A Hamiltonian cycle is (00, 01, 11,
10, 00)
– I3 (a cube) has 8 vertices labeled
000, 001, 010, 011, 100, 101 and
111
– A Hamiltonian cycle is (000, 001,
011, 010, 110, 111, 101, 100,
000)=(0, 1, 3, 2, 6, 7, 5, 4, 0)
The 3Cube Model

The Hamiltonian
cycle (000, 001,
011, 010, 110,
111, 101, 100,
000) joins vertices
that differ by one
bit.
(0, 1, 3, 2, 6, 7, 5, 4, 0)
Hypercube or 4-Cube Model

I4 (the hypercube)
has16 vertices, 32
edges and 20 faces
 Vertex labels:

0000 000100100011
01326754121 0100 010101100111
31514101198
1000 100110101011
1100 11011110 1111

You might also like