walks, paths and circuits walks, paths and circuits sanjay jain, lecturer, school of computing

Post on 14-Dec-2015

217 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Walks, Paths and CircuitsWalks, Paths and Circuits

Sanjay Jain, Lecturer, Sanjay Jain, Lecturer,

School of ComputingSchool of Computing

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)

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.

WalksWalks

v1e2v2e3v3e3v2 is a walk from v1 to v2 with length 3.

v1 v2e2

e3

v3

e1

e4

v4

v5

e5 e6

e7

v6

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.

END OF SEGMENT

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.

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

END OF SEGMENT

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.

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..

END OF SEGMENT

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.

ExampleExample

v1 v2e2

e3

v3

e1

e4

ExampleExample

v1 v2e2

e3

v3

e1

e4

v4

v5

e5 e6

e7

v6

END OF SEGMENT

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’.

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.

END OF SEGMENT

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.

END OF SEGMENT

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

END OF SEGMENT

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.

END OF SEGMENT

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.

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.

END OF SEGMENT

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.

Euler Circuit - ExampleEuler Circuit - Example

. ... .

.v0 v2 v4

v5v3v1

v0v1v3v2v5v4v2v0 is an Euler circuit of the above graph

Euler Circuit - ExampleEuler Circuit - Example

. ... .

.v0 v2 v4

v5v3v1

END OF SEGMENT

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.

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,

END OF SEGMENT

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.

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.

.

END OF SEGMENT

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.

Euler Path - ExampleEuler Path - Example

. ... .

.v0 v2 v4

v5v3v1

v2v0v1v3v5v4v2v3 is an Euler path from v2 to v3

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.

END OF SEGMENT

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.

Connected ComponentConnected Component

v1 v2e2

e3

v3

e1

e4

v4

v5

e5 e6

e7

v6

END OF SEGMENT

Hamiltonian CircuitHamiltonian Circuit

A Hamiltonian Circuit of G is a simple circuit of G which goes through every vertex of G.

Hamiltonian Circuit - ExampleHamiltonian Circuit - Example

. ... .

.v0 v2 v4

v5v3v1

v0v1v3v5v4v2v0 is an Hamiltonian circuit of the above graph

END OF SEGMENT

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)

END OF SEGMENT

top related