Lecture 14 Graph-3

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 37

Discrete Structures

MUHAMMAD JAFFAR KHAN (MS Electrical Engineering)


MASTER IN COMPUTER SCIENCE-1
FEDERAL URDU UNIVERSITY, ISLAMABAD (Campus).
10.4 BASIC CONCEPTS
at Page# 678
Let U and W be vertices of a graph G.
• A walk from U to W is an alternating sequence of
vertices and edges of G, beginning with the vertex U and
ending in the vertex W, with the property that each edge
is incident with the vertex immediately preceding it and
the vertex immediately following it in the sequence.
• A walk that begins and ends at the same vertex is called
a closed walk. On the other hand, a walk that begins
and ends at two different vertices is called an open
walk.
BASIC CONCEPTS

• The complete graph of order n, denoted by Kn is the


graph that has n vertices and exactly one edge
connecting each of the possible pairs of distinct vertices.
• A graph H is called a subgraph of a graph G if every
vertex of H is also a vertex of G and every edge of H is
also an edge of G.
• A path in a graph is a sequence: v1, v2, v3, . . . vk, such
that it is possible to travel from v1 to vk without using
the same edge twice .
• A circuit is a path that begins and ends at the same
vertex.
Complete Graph
SUBGRAPH
Graph

Subgraphs:
EXAMPLE 1 at Page# 679
• In the simple graph shown in Figure.

 a, d, c, f , e is a simple path of length 4,


 because {a, d}, {d, c}, {c, f }, and {f, e} are all edges.
 d, e, c, a is not a path, because {e, c} is not an edge.
• The path a, b, e, d, a, b, which is of length 5, is not simple because
it contains the edge {a, b} twice.
• Note that
 b, c, f , e, b is a circuit of length 4
 because {b, c}, {c, f }, {f, e}, and {e, b} are edges, and this path
begins and ends at b.
8
Euler Graph (pronounced oilier)
An Eulerian path in a graph is a path that travels
along every edge of the graph exactly once. An
Eulerian path might pass through individual
vertices of the graph more than once.

A Euler path is a snowplow


problem where a snow
plow needs to plow every
street once.

Start and finish

Euler circuits is a path that ends at the same vertex it started


QUIZ (1/4)
1. Two edges are said to be adjacent if they share a
common________.
2. The ________of a vertex U is number of times an edge
meets U.
3. The graph that has n vertices and exactly one edge
connecting each of the possible pairs of distinct vertices.
4. A walk that begins and ends at the same vertex is called
a/an__________.
5. Two or more distinct edges with the same set of
endpoints are called _______.
THEORIES ABOUT EULER CIRCUITS

• A connected multigraph with at least two


vertices has an Euler circuit if and only if
each of its vertices has even degree.
THEORIES ABOUT EULER PATHS

• A connected multigraph has an Euler path


but not an Euler circuit if and only if it has
exactly two vertices of odd degree.
Draw the Vertex/edge graph and answer the following questions.

A B
1) How many vertices are there? 6

C 2) How many edges are there? 9


F

E D 3)How many vertices have a degree of 2? 3

4) How many vertices have a degree of 4? 3

Euler circuit: BCDEFABDFB


Draw a Euler circuit starting at the vertex with a white dot.

Remember: A circuit travels along every path exactly once and


may pass through vertices multiple times before ending at the
starting vertex.

Euler Path: does not exist (because exactly 2 vertices have not
odd degree).
Use this chart to see if a Euler path or circuit may be drawn

# of ODD Vertices Implication (for a connected graph)


There is at least
0
one Euler Circuit.
1 THIS IS IMPOSSIBLE! Can’t be drawn
There is no Euler Circuit
2
but at least 1 Euler Path.
There are no Euler Circuits
more than 2
or Euler Paths.
Problem: Find an Euler path in the graph
below.
B
A

C
D

E
F
Answer
There are two odd vertices, A and F.
B
A

C
D

E
F

Has Euler path , because 2 vertices have odd degree.

Has not Euler circuit , because all vertices have not even degree .
Which of the following have an Euler
circuit, an Euler path but not a Euler
circuit, or neither?

NOT EC, because all vertices have


not even degree

Neither: NO EP, NO EC EP BUT NOT EC


NO EC, bec: All vertex has not even degree. EP, (only 2 vertices have odd degree ).
NO EP, because, Exact 2 vertices have not odd degree .
Which of the following have an Euler
circuit, an Euler path but not a Euler
circuit, or neither?

NO EP, BUT EC

Euler Circuit, because , each of its vertices has even degree.


NO EP, because , it has not exactly two vertices of odd degree.
Quiz Example# 1
at Page# 694

1. 2. 3.

Which of the undirected graphs in Figure 3 have an Euler


circuit? Of those that do not, which have an Euler path?
Quiz Example# 1
at Page# 694 (Conti…)

Which of the undirected graphs in Figure 3 have an Euler


circuit? Of those that do not, which have an Euler path?

1. 2. 3.

G1 has an Euler circuit, for example, a, e, c, d, e, b, a. Bec: all vertices have even degree.
Neither of the graphs G2 or G3 has an Euler circuit , Bec: all vertices have not even degree.

G3 has an Euler path, namely, a, c, d, e, b, d, a, b. Bec: it has exact 2 vertices of odd degree.
G2 does not have an Euler path, Bec: it has 4 vertices of odd degree. (needs only has exact 2)
G1 has not Euler path, Bec: exact 2 vertices have not odd degree.
Example# 2 at Page# 694

4. 5. 6.

Which of the directed graphs in Figure 4 have


an Euler circuit? Of those that do not, which
have an Euler path?
Example# 2 at Page# 694 (Cont…)

4. 5. 6.

H2 has an Euler circuit, for example, a, g, c, b, g, e, d, f, a.


 Neither H1 nor H3 has an Euler circuit.

• H3 has an Euler path, namely, c, a, b, c, d, b, but H1 does not


Example# 4 at Page# 697
Which graphs shown in Figure have an Euler path?

G1 contains exactly two vertices of odd degree, namely, b and d. Hence, it has an Euler
path that must have b and d as its endpoints. One such Euler path is d, a, b, c, d, b.

Similarly,G2 has exactly two vertices of odd degree, namely, b and d. So it has an Euler
path that must have b and d as endpoints. One such Euler path is b, a, g, f, e, d, c, g, b, c,
f, d.

G3 has no Euler path because it has six vertices of odd degree. (not has exact 2 vertices
of odd degree)
Sir William Rowan Hamilton

• In the 19th century, an Irishman named Sir


William Rowan Hamilton (1805-1865) invented
a game called the Icosian game.
• The game consisted of a graph in which the
vertices represented major cities in Europe.
Hamiltonian Circuit/Paths:

A Hamiltonian path in a graph is a path that


passes through every vertex in the graph exactly
once. A Hamiltonian path does not necessarily pass
through all the edges of the graph, however.
A Hamiltonian path which ends in the same place in
which it began is called a Hamiltonian circuit.
Example 5 at Page# 699
• Which of the simple graphs have a Hamilton circuit or, if not, a
Hamilton path, or neither?

Solution:
G1 Hamilton circuit: a, b, c, d, e, a.
G2 There is no Hamilton circuit, but G2 does have a Hamilton path, namely,
a, b, c, d.
G3 has neither a Hamilton circuit nor a Hamilton path, because any path
containing all vertices must contain one of the edges {a, b}, {e, f}, and
{c, d} more than once.
Examples

Hamiltonian circuit:
A, D, C, B, A
Hamiltonian
path: a, b, c, d, e
Trace a Hamiltonian path

Only a path, not a circuit. The path did not end at


the same vertex it started.

The path does not need to go over every edge but it can only go over an edge once and
must pass through every vertex exactly once.

Hamiltonian Circuits are


often called the mail man
circuit because the mailman
goes to every mailbox but
does not need to go over
every street.
Example# 6 at Page# 700
Show that neither graph displayed in Figure 11
has a Hamilton circuit.

No, Hamilton circuit


Example# 6 at Page# 700
Show that neither graph displayed in Figure 11
has a Hamilton circuit.

No, Hamilton circuit


1. Determine if the following graph has a Hamiltonian
circuit, a Hamiltonian path but no Hamiltonian circuit,
or neither.

a, b, c, d, e, a is a Hamilton circuit
2. Does the graph have a Hamilton path? If so, find such a
path. If it does not, give an argument to show why no
such path exists.

a, b, c, f, d, e is a Hamilton path
3. Does the graph in Exercise 32 have a Hamilton
path? If so, find such a path. If it does not, give an
argument to show why no such path exists.

f, e, d, a, b, c is a Hamilton path.
Review:

Euler Graphs Passes over edge exactly once. May pass through a vertex more than once.

Hamiltonian
Passes through every vertex exactly once but not necessarily over every edge.
Graphs

Circuits The path ends at the same vertex it started.


Quiz Answer

1. VERTEX
2. DEGREE
3. COMPLETE GRAPH
4. CLOSE WALK
5. PARALLEL
Quiz Answer

Solution:

1. G1 has an Euler circuit, a, e, c, d, e, b, a.


2. G2 Neither
3. G3 has an Euler path, namely, a, c, d, e, b, d, a, b.
4. H1 Neither
5. H2 has an Euler circuit, a, g, c, b, g, e, d, f, a
6. H3 has an Euler path, namely, c, a, b, c, d, b
END

37

You might also like