Module 2
Module 2
Module 2
Rijin IK
Assistant Professor
Department of Computer Science and Engineering
Vimal Jyothi Engineering College
Chemperi
1 Euler graph
2 Operations on Graph
3 Hamiltonian Graph
5 Directed Graph
6 Fleury’s Algorithm
Euler graph
A connected graph G is called an Euler graph, if there is a closed
trail/walk which includes every edge of the graph G exactly once.
OR
An Euler line: A closed walk that contains all the edges of the graph
exactly once
Closed - starting and ending at same vertex (S&E)
Walk - no edge repetition, vertex may repeat (NER)
Euler - all edges traversed exactly once (AET)
Euler Path
An Euler path is a path that uses every edge of a graph exactly once.
An Euler path starts and ends at different vertices.
B→C →D→B→A→D
Non-Euler Graph
Euler’s Theorem
Suppose we have a connected graph.
If the graph has an Euler circuit, then each vertex of the graph has
even degree.
If each vertex of the graph has even degree, then the graph has an
Euler circuit.
Theorem
A connected graph G is Euler if and only if all of its vertices are of even
degree
Proof
Suppose G is an Euler graph and connected
Then G contains an Euler line, which is a closed walk, containing all
the edges of G exactly once
Then, as we trace the walk, we find that the walk meets a vertex v
along one edge and leaves that vertex along another edge
This is true for all vertices of the walk, including the terminal vertex
Hence we can say that every vertex has to be of even degree
Proof Cont..
Conversely:
Suppose that all vertices of G are of even degree and G is
connected
Then start a walk from an arbitrary vertex v and go through the
edges of G, one by one, without repetition and finally come back to
the vertex v
It is possible as every vertex is of even degree
And since G is connected, we can trace through all the edges of G
Then G is an Euler graph
Hence the theorem
The graph representing the Konigsberg bridge problem has got all its
vertices with odd degree
Hence it is not an Euler graph
As a result we cannot trace a closed walk in it
That is how Euler proved that it is not possible to walk over each of
the seven bridges exactly once and return to the starting point
Rijin IK (VJEC) MAT 206 M2 March 18, 2023 10 / 105
Unicursal Graph
Unicursal Graph
An open walk(or traces) that includes (or traces) all edges of a graph
without retracing any edge is called a unicursal line or open Euler line. A
connected graph that has a unicursal line is called a unicursal graph.
It is the same as an Euler line except that the starting and the ending
vertex is not the same or it is an Open Euler Line
Starting and ending on different vertices (S&E)
No edge repetition, vertex may repeat (NER)
All edges traversed exactly once (AET)
Theorem
In a connected graph G with exactly 2k odd vertices, there exists k edge
disjoint subgraphs such that they together contain all edges of G and that,
each is a unicursal graph
Proof:
Let the odd vertices of the given graph be named
x1 , x2 , x3 , ..........xk , w1 , w2 , w3 , .........wk in some arbitrary order
Add k edges to G between the vertex pairs,
(x1 , w1 )(x2 , w2 )..............(xk , wk ) to form a new graph G’
Now since every vertex of G’ is of even degree, G’ consists of an Euler
line p
Proof Cont..:
Now if we remove from p the k edges we just added then it will split
the graph into k walks, each of which is a unicursal line
The first removal will result in a single unicursal line, the second
removal will split that into 2 unicursal lines, and each successive
removal will split a unicursal lines into 2 unicursal lines, until there
are k of them
Thus the theorem.
Example
Example Cont..
Trace an euler Line P
1 Union
2 Intersection
3 Ring Sum
4 Decomposition
5 Deletion
6 Fusion
Example
Intersection
Let G1(V1,E1) and G2(V2,E2) be two graphs, then the intersection of G1
and G2 is a graph G3
Where G 3 = G 1 ∩ G 2
Vertex set V 3 = V 1 ∩ V 2
Edge Set E 3 = E 1 ∩ E 2
Example
Example
Ring sum
If G1 & G2 are edge disjoint graphs, (no common edge) then G3 will
be G 1 ∪ G 2
For any graph G,G ⊕ G is a null graph (only vertices, no edges)
For any subgraph g of G, G ⊕ g is G − g ; the compliment of g in G
Example
Decomposition
A graph G is said to have decomposed into two graphs g1 and g2 if
g1 ∪ g2 = G
g 1 ∩ g 2 = G = null graph
All edges of G must be present either in g1 or g2 but no edge can be
common for g1 and g2.
Vertices may however be common, but has to be there either in g1
and g2
A graph containing ‘m’ edges can be decomposed in 2m − 1 ways into
pairs of sub graphs
Decomposition Example
Therom
A connected graph G is an Euler graph if and only if it can be decomposed
into circuit
Proof:
Suppose G can be decomposed into circuits
Then G is a union of edge disjoint circuits
We know that in any circuit, the degree of each vertex is 2
Then, when we join all these circuits together to form graph G, G will
have all its vertices with even degree
Since G has all even degree vertices, G is an Euler graph
Usually in an Euler graph, we can get an Euler line starting from any
vertex irrespective of the order in which we traverse the vertices
In some Euler graphs, we may not get an Euler line if we start from a
certain vertex, due to the order in which we choose the intermediate
vertices
Such graphs are known as Arbitrarily Traceable Graphs
Proof:
Suppose G is an Euler graph that is arbitrarily traceable from
vertex v
Assume that there is a cycle C not passing through v
Remove the cycle C from G to get H i.e, H = G-C
Since a cycle has all its vertices with degree 2, taking out a cycle from
an Euler graph leaves the remaining graph, Euler
Now in H trace an Euler line p starting & ending at v; obviously p
contains all edges of H
Bring back the removed cycle C to H and try to extend the v to v
walk so as to include all edges of C
It would not be possible without repeating at least one edge,
contradicting that G is an ATG from v (starting a walk from v we
should always get an Euler line)
Rijin IK (VJEC) MAT 206 M2 March 18, 2023 37 / 105
Arbitrarily traceable graphs
Proof Cont...:
Conversely
Let every circuit of G contain v
Assume on the contrary that G is not arbitrarily traceable from v
Then there must be a v to v closed walk, W in G that contains all
edges of G. Let one such edge be incident at a vertex u on W
So, every vertex of H=G-W is of even degree & v is an isolated vertex
of H & u is not
Then, component of H containing u is therefore Eulerian sub graph of
G not passing through v contradicting the assumption
Hence the proof
Hamiltonian Graph
A graph that contains a Hamiltonian circuit
A Hamiltonian circuit: A circuit in a connected graph that traverses
all its vertices exactly once
More Ham-circuits of G
(n − 1)!
2
Maximum number of edge disjoint Ham-circuits is
(n − 1)
if ′ n′ is odd
2
(n − 2)
if ′ n′ is even
2
THEOREM
In a complete graph with n vertices there are (n−1)
2 edge-disjoint
Hamiltonian circuits,if n is an odd number ≥ 3
Proof:
n(n−1)
A complete graph with n vertices has 2 edges
Any Ham-circuit will have n edges
(n−1)
Therefore, the no. of edge disjoint Ham-circuits cannot exceed 2
(n−1)
That means the maximum no. of edge disjoint Ham-circuits is 2
Proof cont..:
Obtaining the edge disjoint Ham-circuits
The subgraph given below is a Ham-circuit of a complete graph with
n vertices
Starting from vertex 1 and tracing along the solid lines, we get the
first circuit which is 1,2,3,4............ (n-1), n,1
Proof cont..:
Now, imagine the vertices (except 1) to be lying on the circumference
of a circle
360 0 2x360 0 3x360 0
Rotate the circle by ( n−1 ) , ( n−1 ) , ( n−1 ) ....( n−3 x360 0
2 n−1 )
Each rotation produces a new Ham-circuit that has no edge in
common with the previous ones
There for the number of edge disjoint Ham-circuits= n−3
2 +1=
n−1
2
The 1st solution is obtained in the default position, without any
rotation
Hence the theorm
Dirac’s theorem
Let G = (V, E) be a graph with n vertices (n ≥ 3) in which each vertex
has degree at least n2 . Then G has a Hamiltonian cycle.
Example:
Here n is 4 ie ≥ 3
d(a) = d(b) = d(c) =
d(d) = 2 ie ≥ n2
So the graph is
Hamiltonian
Number of solutions
If each of the cities has a road to every other city, we get a complete
weighted graph
The graph has numerous Ham-circuits; the salesman has to choose
the one with the smallest sum of distances
The no. of Ham-circuits in a complete graph with n vertices = (n−1)!
2
At the starting vertex, we have (n-1) edges to choose from
At the next vertex, we have (n-2) edges to choose from and so on
At the second last vertex we will have (n-(n-2)) = 2 edges to choose
from
Finally at the last vertex we will have just 1 edge to move on
Hence we have (n-1)! possible no. of choices
However this has to be divided by 2 as each Ham-circuit has been
counted twice
ie = (n−1)!
2 Ham-circuit
Example:
Example:
Q : Trace a travelling salesman tour on the graph given below
G = (V, E)
V = {V1,V2,V3}
E = {a, b, c}
Self loop
An edge having the same vertex as its initial vertex and terminal
vertex is called a self loop
Parallel edges
Two edges of a digraph are said to be parallel edges if they have the
same initial vertex and terminal vertex; i.e, they have the same
direction
Symmetric edges
Two edges of a digraph are said to be symmetric edges if the initial
vertex of one edge is the terminal vertex of the other and the terminal
vertex of the former is the initial vertex of the latter & hence they will
be opposite in direction
Isolated vertex
A vertex having no incident edge is called an isolated vertex
The indegree & outdegree of an isolated vertex is zero
Pendant vertex
A vertex that has only 1 incident edge is called a pendant vertex;
direction can be either ‘into the vertex’ or ‘away from the vertex’
The total degree of a pendant vertex is 1
vertex V4 is an isolated
vertex
V5 is a pendant vertex;
d − (V5 ) = 0 & d + (V5 ) = 1
Symmetric digraphs
A digraph that has a symmetric pair for all its edges
Simple symmetric digraph
A digraph that has a symmetric pair for all its edges as well as free of
self loops and parallel edges
Asymmetric digraph
A digraph that do not have a symmetric pair for any of its edges(can
have self loop)
Simple asymmetric digraph
A digraph that do not have a symmetric pair for any of its edges as
well as free of self loops and parallel edges
Regular digraph
A digraph in which all vertices have the same degree (total degree)
Eg: G is a regular digraph since
d(V1) = d(V2) = d(V3) = d(V4) = 2
Theorem
In any digraph, sum of all indegrees = sum of all outdegrees = no. of
edges
i.e ni=1 d + (vi ) = ni=1 d − (vi ) = e
P P
Proof:
Since each directed edge of any digraph, contributes ’1’ towards the
total indegree & ’1’ towards the total outdegree of the graph,
no. of edges must give the total indegree, which is the same as the
total outdegree of the graph
Isomorphic digraphs
Example
In a directed walk
No edge can appear more than once
All edges must be orienting in one direction
Vertex may appear more than once
Starts and ends at different vertices
In a directed semi-walk
No edge can appear more than once
Edges may have any direction
Vertex may appear more than once
Starts and ends at different vertices
when the direction is taken off, walk and semi-walk is the same
Directed path
An Open directed walk in which no vertex appears more than once is
called a directed path.
No vertex or edge repetition
Starting and ending at different vertices
All edges orienting towards same direction
Directed semi-path
An Open directed walk in which
No vertex or edge repetition
Starting and ending at different vertices
Edges may have any direction
Directed circuit
Closed directed walk in which
No vertex or edge repetition
Starting and ending at the same vertex
All edges orienting towards same direction
Directed semi-circuit
Closed directed walk in which
No vertex or edge repetition
Starting and ending at the same vertex
Edges may have any direction
Accessibility / Reachability
In a digraph G, a vertex vj is said to be accessible from vi if there is a
directed path from vi to vj
Disconnected digraph
A digraph is disconnected if its corresponding undirected version is
disconnected
Each component of the disconnected digraph is a digraph itself
Condensation
The condensation GC of a digraph G is obtained by replacing each strongly
connected fragment by a single vertex & all directed edges from one
fragment to another are replaced by a single directed edge
Condensation of a strongly connected digraph is a single vertex
Condensation of a digraph has no directed circuit
Every Euler digraph would be a strongly connected digraph; However the reverse
may not be true
Theorem
A digraph G is an Euler digraph if & only if G is connected & every vertex
of G is balanced
Proof:
Suppose G is an Euler digraph
Then G must contain a directed Euler line - a closed directed walk, W
W must contain all the edges of G
So as to visit a vertex, we need to traverse an edge directed towards
the vertex & one that is directed away from that vertex
Hence for each visit, a vertex needs an in degree and a corresponding
out degree
This is true for all the vertices of W, including the initial vertex as the
walk finally ends there
Hence every vertex need to be balanced
Rijin IK (VJEC) MAT 206 M2 March 18, 2023 86 / 105
Directed Graph
Proof Cont..
Suppose every vertex of G is balanced
Start a walk W from an arbitrary vertex v. Visit all possible vertices.
At each vertex we are able to leave along another edge, not yet
traversed, as indegree = outdegree. Continue the process until back
at v. If W contains all edges of G, then G is an Euler digraph
If not, remove all edges of W from G
The remaining graph G’ has again, all its vertices, balanced. Now,
since G is connected, there would be a vertex u, common to W & G‘.
Starting from u, start a walk W’ in G’. If W’ covers all the edges of G’
then then G is an Euler digraph
If not, remove all edges of W’ from G’
Call the remaining graph as G”.Continue the process, until we get a
closed walk, that traverse all edges of G exactly once
Hence G is an Euler digraph
Rijin IK (VJEC) MAT 206 M2 March 18, 2023 87 / 105
Directed Graph
Digraphs and binary relation
A binary relation on a finite set can also be represented using a
directed graph (a digraph for short).
If a binary relation R is defined on a set A then the elements of the
set A are represented by vertices, and the ordered pairs of the relation
R are represented by the directed edges.
Suppose we are given a set A and a binary relation R
A = {1, 2, 3, 4, 5}
A = {(1, 1), (1, 2), (1, 3), (3, 3), (3, 5), (4, 1), (4, 5), (5, 4)}
The relation R on A is represented by its digraph as follows:
Reflexive relation:
A relation R on a set X that satisfies xi Rxi for every xi ∈ X is called a
reflexive relation.
The digraph of a reflexive relation will have a self loop at every vertex.
Such a digraph representing a reflexive binary relation on its vertex
set may be called a reflexive digraph
Example: A = {1, 2, 3} and R is the relation
R = {(1, 1), (1, 2), (2, 2), (3, 3)}. This is a reflexive relation, and the
associated diagram is
FLEURY’S ALGORITHM
It is an algorithm used to find an Euler path or circuit in a graph, provided
it exists.
FLEURY’S ALGORITHM
It is an algorithm used to find an Euler path or circuit in a graph, provided
it exists.
1 Preliminaries:Make sure that the graph is connected and either
Case (1) has no odd vertices (circuit)
Case (2) has just two odd vertices (path).
2 Start:Choose a starting vertex.
In case (1) this can be any vertex;
case (2) It must be one of the two odd vertices.
3 Intermediate steps:At each step, if you have a choice, don’t choose
a bridge of the yet-to-be-traveled part of the graph.However, if you
have only one choice, take it.
4 End:When you can’t travel any more, the circuit (path) is complete.
In case (1) you will be back at the starting vertex; in case (2) you will
end at the other odd vertex.
Rijin IK (VJEC) MAT 206 M2 March 18, 2023 95 / 105
FLEURY’S ALGORITHM
Example
To find an Euler circuit in the graph shown, we will start with two
copies of the graph.
Copy 1 is to keep track of the “future”
Copy 2 is to keep track of the “past.”
Every time you travel along an edge, erase that edge from copy 1, but
mark it (say in red) and label it with the appropriate number on copy2
As you move forward copy 1 disappears and copy 2 gets redder,
showing the actual Euler path or circuit.
Example Cont...
Example Cont...
Example Cont...
Example Cont...
Example Cont...
Example Cont...
Example Cont...