Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.
-
Upload
precious-peppin -
Category
Documents
-
view
215 -
download
0
Transcript of Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.
![Page 1: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/1.jpg)
Walks, Paths and CircuitsWalks, Paths and Circuits
Sanjay Jain, Lecturer, Sanjay Jain, Lecturer,
School of ComputingSchool of Computing
![Page 2: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/2.jpg)
Walks Paths and Circuits Notation for Walks Connected Graphs Lemma Euler Circuit Euler Path Connected Component Hamiltonian Circuit
Main Menu Main Menu (Click on the topics below)
![Page 3: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/3.jpg)
WalksWalks
A walk from a vertex u to v (in G) is a sequence of the form
v0 e1 v1 e2 v2 e3……….. ek vk
where u = v0 , v = vk and
for any ei, endpoints(ei) = {vi-1 , vi} Trivial walk from u to u consists of just
u
Length of a walk: number of edges in the walk, where we count different appearance of an edge in the walk separately.
![Page 4: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/4.jpg)
WalksWalks
v1e2v2e3v3e3v2 is a walk from v1 to v2 with length 3.
v1 v2e2
e3
v3
e1
e4
v4
v5
e5 e6
e7
v6
![Page 5: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/5.jpg)
Notation for WalksNotation for Walks
In graphs without parallel edges, we often omit the name of edges from the walk.
This is so, since the edges are uniquely determined by the end points.
Thus, we can reinsert the edges if needed.
![Page 6: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/6.jpg)
END OF SEGMENT
![Page 7: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/7.jpg)
Paths and CircuitsPaths and Circuits
Path from u to v (in G) is a walk from u to v such that no edges are repeated.
A Simple Path from u to v (in G) is a path from u to v in which no vertices are repeated.
A closed walk is a walk which starts and ends at the same vertex.
A circuit is a closed walk in which no edges are repeated.
A simple circuit is a circuit in which no vertices (except for the last vertex, which is the same as first vertex) are repeated.
![Page 8: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/8.jpg)
Paths and CircuitsPaths and Circuits
v1e2v2e3v3e3v2 is walk but not a path. v1e2v2e3v3 is a path from v1to v3
v1e2v2e3v3e3v2e2v1 is a closed walk but not a circuit v1e2v2e3v3e1v1 is a simple circuit
v1 v2e2
e3
v3
e1
e4
v4
v5
e5 e6
e7
v6
![Page 9: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/9.jpg)
END OF SEGMENT
![Page 10: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/10.jpg)
TheoremTheorem
Suppose G is a graph, u and v are vertices in V(G), and there is a walk from u to v (in G).
Then there is a simple path from u to v in G.
![Page 11: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/11.jpg)
ProofProofSince there is a walk from u to v, there must be a shortest
walk from u to v. Let it be
W = v0 e1 v1 e2... vi ei+1…… vj ej+1 ….. ek vk
If it is a simple path, then we are done.
Otherwise suppose vi = vj , ij.
Then, W’ = v0 e1 v1 e2... vi ej+1 ….. ek vk
v0
vi =vj
vk
is also a walk from u to v, with length smaller than W. A contradiction to W being of shortest length. Thus W must be simple path..
![Page 12: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/12.jpg)
END OF SEGMENT
![Page 13: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/13.jpg)
Connected GraphsConnected Graphs
Two vertices u and v in a graph G, are connected iff there is a walk from u to v.
G is connected iff all pair of vertices in G are connected.
![Page 14: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/14.jpg)
ExampleExample
v1 v2e2
e3
v3
e1
e4
![Page 15: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/15.jpg)
ExampleExample
v1 v2e2
e3
v3
e1
e4
v4
v5
e5 e6
e7
v6
![Page 16: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/16.jpg)
END OF SEGMENT
![Page 17: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/17.jpg)
TheoremTheorem
Suppose G is a graph and C is a circuit in G containing vertices u, v. Suppose e is an edge in G.
Let G’ be formed by deleting edge e from the graph G.Then there is still a path from u to v in G’.
![Page 18: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/18.jpg)
ProofProof
Suppose the circuit C in G isw…… u ……v ….. ……w
e can be in only one of the above paths.So at least one path remains intact after removal of e. Thus, in G’, there is a path from u to v.
![Page 19: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/19.jpg)
END OF SEGMENT
![Page 20: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/20.jpg)
LemmaLemma
(a) If G is a connected graph, then any two distinct vertices of G can be connected by a simple path
(b) If two distinct vertices v and w are part of a non-trivial circuit and one edge is removed from the circuit, then there still exists a path from v to w in the new graph so formed.
(c) If G is connected and we remove an edge in a circuit, then G still remains connected.
![Page 21: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/21.jpg)
END OF SEGMENT
![Page 22: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/22.jpg)
Proof of Lemma (a)Proof of Lemma (a)
Suppose v, w are vertices in G.Then since G is connected, there exists a walk from u
to v (in G). Therefore, by a theorem done earlier, there is a
simple path from u to v.
(a) If G is a connected graph, then any two distinct vertices of G can be connected by a simple path
![Page 23: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/23.jpg)
END OF SEGMENT
![Page 24: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/24.jpg)
Proof of Lemma (b)Proof of Lemma (b)
In earlier theorem we showed: Suppose G is a graph and C is a circuit in G
containing vertices u and v. Suppose e is an edge in G.
Let G’ be formed by deleting edge e from the graph G.
Then there is still a path from u to v in G’.
(b) If two distinct vertices v and w are part of a non-trivial circuit and one edge is removed from the circuit, then there still exists a path from v to w in the new graph so formed.
![Page 25: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/25.jpg)
END OF SEGMENT
![Page 26: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/26.jpg)
Proof of Lemma (c)Proof of Lemma (c)
(c) If G is connected and we remove an edge in a circuit, then G still remains connected.
![Page 27: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/27.jpg)
Proof of Lemma (c)Proof of Lemma (c)
Suppose e is the edge in a circuit of G which is removed. Suppose e has endpoints u and v. Suppose G’ be the new graph. By part (b) there is a path, say P, from u to v in G’.
To show: for all u’,v’ in V(G), there exists a walk from u’ to v’ in G’.Consider any u’, v’ in G.G is connected --> there is a walk and thus a path, say Q, from u’
to v’ in G. If Q doesn’t contain e: Q is a path from u’ to v’ in G’.If Q contains e: replace “uev” in Q by P and “veu” in Q by reverse of P.That is, if Q=u’……uev…..v’then consider the walk u’……P…….v’Note that this new walk is a walk in G’ from u’ to v’. Since u’, v’ were arbitrary element of V(G’), we get that G’ is
connected.
![Page 28: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/28.jpg)
END OF SEGMENT
![Page 29: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/29.jpg)
Euler CircuitEuler Circuit
Suppose G is a graph. Euler circuit of G (in G) is a circuit which goes through all the edges (exactly once) and all the vertices of G.
Note that the vertices may be repeated in an Euler circuit.
![Page 30: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/30.jpg)
Euler Circuit - ExampleEuler Circuit - Example
. ... .
.v0 v2 v4
v5v3v1
v0v1v3v2v5v4v2v0 is an Euler circuit of the above graph
![Page 31: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/31.jpg)
Euler Circuit - ExampleEuler Circuit - Example
. ... .
.v0 v2 v4
v5v3v1
![Page 32: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/32.jpg)
END OF SEGMENT
![Page 33: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/33.jpg)
TheoremTheorem
If a graph G has Euler circuit, then (a) G is connected, and (b) every vertex of G has even degree.
Part (a): If G is not-connected then no circuit goes through all the vertices.
![Page 34: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/34.jpg)
Proof (b)Proof (b)Suppose the Euler circuit is:
v0 e1 v1 e2….. ei vi ei+1……ej vj ej+1 ….. ek v0
For any vertex v (except v0):
Coming in, going out occur in pairs. Each coming in and going out are via different edges (no repetition of edges in a circuit). Thus the degree of vertex v in G must be even. Similar reasoning holds for v0 also, except that we consider the first exit and last entry separately.
.come in,
go out, ..…..
go out, ..
come in,
![Page 35: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/35.jpg)
END OF SEGMENT
![Page 36: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/36.jpg)
TheoremTheorem
If G is connected and every vertex of G has even degree, then G has an Euler circuit.
Corollary: G has Euler circuit iff it is connected and every vertex of G has even degree.
![Page 37: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/37.jpg)
Proof
.v
u.C
(b) No edges left: Done. Or: we made a circuit C and v (in C) still has an edge unused in C.
a) From u, walk until you are back at u (don’t repeat an edge).
C’
c) From v build circuit C’ (using only unused edges).
d) Insert C’ in C to form C’’ as follows:
e) Let C =C’’, and go to step b).
C’’
C: …… v…… …..Then C’’: …..C’….. ….. (v is replaced by C’).
C’’ uses all the edges in C and C’ exactly once.
.
![Page 38: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/38.jpg)
END OF SEGMENT
![Page 39: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/39.jpg)
Euler PathEuler Path
Suppose G is a graph. Let u and v be two distinct vertices of G. Then Euler path of G, from u to v, is a path from u to v which goes through all the edges of G (exactly once) and all the vertices of G.
![Page 40: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/40.jpg)
Euler Path - ExampleEuler Path - Example
. ... .
.v0 v2 v4
v5v3v1
v2v0v1v3v5v4v2v3 is an Euler path from v2 to v3
![Page 41: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/41.jpg)
Euler PathEuler Path
Corollary: Suppose G is a connected graph, and u, v are two distinct vertices in G.
Then G has an Euler path from u to v, iff degree of u and v is odd, and the degree of all other vertices in G is even.
![Page 42: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/42.jpg)
END OF SEGMENT
![Page 43: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/43.jpg)
Connected ComponentConnected Component
A Graph H is a connected component of G iff
a) H is a subgraph of Gb) H is connectedc) No connected subgraph H’ of G has H as its proper
subgraph.
![Page 44: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/44.jpg)
Connected ComponentConnected Component
v1 v2e2
e3
v3
e1
e4
v4
v5
e5 e6
e7
v6
![Page 45: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/45.jpg)
END OF SEGMENT
![Page 46: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/46.jpg)
Hamiltonian CircuitHamiltonian Circuit
A Hamiltonian Circuit of G is a simple circuit of G which goes through every vertex of G.
![Page 47: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/47.jpg)
Hamiltonian Circuit - ExampleHamiltonian Circuit - Example
. ... .
.v0 v2 v4
v5v3v1
v0v1v3v5v4v2v0 is an Hamiltonian circuit of the above graph
![Page 48: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/48.jpg)
END OF SEGMENT
![Page 49: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/49.jpg)
Hamiltonian Circuit - TheoremHamiltonian Circuit - Theorem
A non-empty graph G has Hamiltonian Circuit iff
1. G has only one vertexor2. G has at least two vertices and G has a subgraph H
such that
a) H contains every vertex of G
b) H is connected
c) every vertex of H has degree 2
(note that this means H has same number of vertices as edges)
![Page 50: Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.](https://reader030.fdocuments.in/reader030/viewer/2022032516/56649c7b5503460f9492fc75/html5/thumbnails/50.jpg)
END OF SEGMENT