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

Euler Path & Circuit

- An Euler path uses every edge in a graph exactly once, starting and ending at different vertices. An Euler circuit does the same but starts and ends at the same vertex. - A graph will have an Euler path if it has exactly two odd vertices. A graph will have an Euler circuit if it has zero odd vertices. - Fleury's algorithm for finding an Euler path or circuit involves starting at an odd vertex if there are two, and following edges while avoiding bridges if possible.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
361 views

Euler Path & Circuit

- An Euler path uses every edge in a graph exactly once, starting and ending at different vertices. An Euler circuit does the same but starts and ends at the same vertex. - A graph will have an Euler path if it has exactly two odd vertices. A graph will have an Euler circuit if it has zero odd vertices. - Fleury's algorithm for finding an Euler path or circuit involves starting at an odd vertex if there are two, and following edges while avoiding bridges if possible.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 66

Euler Paths and Euler Circuits

An Euler path is a path that uses every edge of a graph exactly once. An Euler circuit is a circuit that uses every edge of a graph exactly once.

An Euler path starts and ends at dierent vertices. An Euler circuit starts and ends at the same vertex.

Euler Paths and Euler Circuits

B A C A

An Euler path: BBADCDEBC

Euler Paths and Euler Circuits

B A C A

Another Euler path: CDCBBADEB

Euler Paths and Euler Circuits

B A C A

An Euler circuit: CDCBBADEBC

Euler Paths and Euler Circuits

B A C A

Another Euler circuit: CDEBBADC

Euler Paths and Euler Circuits

Is it possible to determine whether a graph has an Euler path or an Euler circuit, without necessarily having to nd one explicitly?

The Criterion for Euler Paths


Suppose that a graph has an Euler path P .

The Criterion for Euler Paths


Suppose that a graph has an Euler path P . For every vertex v other than the starting and ending vertices, the path P enters v the same number of times that it leaves v (say s times).

The Criterion for Euler Paths


Suppose that a graph has an Euler path P . For every vertex v other than the starting and ending vertices, the path P enters v the same number of times that it leaves v (say s times). Therefore, there are 2s edges having v as an endpoint.

The Criterion for Euler Paths


Suppose that a graph has an Euler path P . For every vertex v other than the starting and ending vertices, the path P enters v the same number of times that it leaves v (say s times). Therefore, there are 2s edges having v as an endpoint. Therefore, all vertices other than the two endpoints of P must be even vertices.

The Criterion for Euler Paths


Suppose the Euler path P starts at vertex x and ends at y .

The Criterion for Euler Paths


Suppose the Euler path P starts at vertex x and ends at y .

Then P leaves x one more time than it enters, and leaves y one fewer time than it enters.

The Criterion for Euler Paths


Suppose the Euler path P starts at vertex x and ends at y .

Then P leaves x one more time than it enters, and leaves y one fewer time than it enters.

Therefore, the two endpoints of P must be odd vertices.

The Criterion for Euler Paths


The inescapable conclusion (based on reason alone!): If a graph G has an Euler path, then it must have exactly two odd vertices. Or, to put it another way, If the number of odd vertices in G is anything other than 2, then G cannot have an Euler path.

The Criterion for Euler Circuits


Suppose that a graph G has an Euler circuit C .

The Criterion for Euler Circuits


Suppose that a graph G has an Euler circuit C . For every vertex v in G , each edge having v as an endpoint shows up exactly once in C .

The Criterion for Euler Circuits


Suppose that a graph G has an Euler circuit C . For every vertex v in G , each edge having v as an endpoint shows up exactly once in C . The circuit C enters v the same number of times that it leaves v (say s times), so v has degree 2s .

The Criterion for Euler Circuits


Suppose that a graph G has an Euler circuit C . For every vertex v in G , each edge having v as an endpoint shows up exactly once in C . The circuit C enters v the same number of times that it leaves v (say s times), so v has degree 2s . That is, v must be an even vertex.

The Criterion for Euler Circuits


The inescapable conclusion (based on reason alone): If a graph G has an Euler circuit, then all of its vertices must be even vertices. Or, to put it another way, If the number of odd vertices in G is anything other than 0, then G cannot have an Euler circuit.

Things You Should Be Wondering


Does every graph with zero odd vertices have an Euler circuit? Does every graph with two odd vertices have an Euler path?

Is it possible for a graph have just one odd vertex?

How Many Odd Vertices?

How Many Odd Vertices?

Odd vertices

How Many Odd Vertices?

6 2

8
Number of odd vertices

6 8

The Handshaking Theorem


The Handshaking Theorem says that In every graph, the sum of the degrees of all vertices equals twice the number of edges. If there are n vertices V1 , . . . , Vn , with degrees d1 , . . . , dn , and there are e edges, then d1 + d2 + + dn1 + dn = 2e Or, equivalently, e= d1 + d2 + + dn1 + dn 2

The Handshaking Theorem


Why Handshaking? If n people shake hands, and the i th person shakes hands di times, then the total number of handshakes that take place is d1 + d2 + + dn1 + dn . 2 (How come? Each handshake involves two people, so the number d1 + d2 + + dn1 + dn counts every handshake twice.)

The Number of Odd Vertices


The number of edges in a graph is d1 + d2 + + dn 2 which must be an integer.

The Number of Odd Vertices


The number of edges in a graph is d1 + d2 + + dn 2 which must be an integer. Therefore, d1 + d2 + + dn must be an even number.

The Number of Odd Vertices


The number of edges in a graph is d1 + d2 + + dn 2 which must be an integer. Therefore, d1 + d2 + + dn must be an even number. Therefore, the numbers d1 , d2 , , dn must include an even number of odd numbers.

The Number of Odd Vertices


The number of edges in a graph is d1 + d2 + + dn 2 which must be an integer. Therefore, d1 + d2 + + dn must be an even number. Therefore, the numbers d1 , d2 , , dn must include an even number of odd numbers. Every graph has an even number of odd vertices!

Back to Euler Paths and Circuits


Heres what we know so far: # odd vertices Euler path? Euler circuit? 0 2 4, 6, 8, . . . 1, 3, 5, . . . No Maybe No Maybe No No

No such graphs exist!

Can we give a better answer than maybe?

Euler Paths and Circuits The Last Word


Here is the answer Euler gave: # odd vertices Euler path? Euler circuit? 0 2 4, 6, 8, . . . 1, 3, 5, No Yes* No Yes* No No

No such graphs exist

* Provided the graph is connected.

Euler Paths and Circuits The Last Word


Here is the answer Euler gave: # odd vertices Euler path? Euler circuit? 0 2 4, 6, 8, . . . 1, 3, 5, No Yes* No Yes* No No

No such graphs exist

* Provided the graph is connected. Next question: If an Euler path or circuit exists, how do you nd it?

Bridges

Removing a single edge from a connected graph can make it disconnected. Such an edge is called a bridge.

Bridges
Removing a single edge from a connected graph can make it disconnected. Such an edge is called a bridge.

Bridges
Removing a single edge from a connected graph can make it disconnected. Such an edge is called a bridge.

Bridges
Loops cannot be bridges, because removing a loop from a graph cannot make it disconnected.

e delete loop e

Bridges
If two or more edges share both endpoints, then removing any one of them cannot make the graph disconnected. Therefore, none of those edges is a bridge.

A B

delete multiple edges

Bridges
If two or more edges share both endpoints, then removing any one of them cannot make the graph disconnected. Therefore, none of those edges is a bridge.

A B

delete multiple edges

Finding Euler Circuits and Paths

Dont burn your bridges.

Finding Euler Circuits and Paths


Problem: Find an Euler circuit in the graph below.

B A C E

D F

Finding Euler Circuits and Paths


There are two odd vertices, A and F. Lets start at F.

B A C E

D F

Finding Euler Circuits and Paths


Start walking at F. When you use an edge, delete it.

B A C E

D F

Finding Euler Circuits and Paths


Path so far: FE

B A C E

D F

Finding Euler Circuits and Paths


Path so far: FEA

B A C E

D F

Finding Euler Circuits and Paths


Path so far: FEAC

B A C E

D F

Finding Euler Circuits and Paths


Path so far: FEACB

B A C E

D F

Finding Euler Circuits and Paths

Up until this point, the choices didnt matter.

Finding Euler Circuits and Paths

Up until this point, the choices didnt matter.

But now, crossing the edge BA would be a mistake, because we would be stuck there.

Finding Euler Circuits and Paths

Up until this point, the choices didnt matter.

But now, crossing the edge BA would be a mistake, because we would be stuck there.

The reason is that BA is a bridge. We dont want to cross (burn?) a bridge unless it is the only edge available.

Finding Euler Circuits and Paths


Path so far: FEACB

B A C E

D F

Finding Euler Circuits and Paths


Path so far: FEACBD.

B A C E

D F

Finding Euler Circuits and Paths


Path so far: FEACBD. Dont cross the bridge!

B A C E

D F

Finding Euler Circuits and Paths


Path so far: FEACBDC

B A C E

D F

Finding Euler Circuits and Paths


Path so far: FEACBDC Now we have to cross the bridge CF.

B A C E

D F

Finding Euler Circuits and Paths


Path so far: FEACBDCF

B A C E

D F

Finding Euler Circuits and Paths


Path so far: FEACBDCFD

B A C E

D F

Finding Euler Circuits and Paths


Path so far: FEACBDCFDB

B A C E

D F

Finding Euler Circuits and Paths


Euler Path: FEACBDCFDBA

B A C E

D F

Finding Euler Circuits and Paths


Euler Path: FEACBDCFDBA

B A C E

D F

Fleurys Algorithm
To nd an Euler path or an Euler circuit:

Fleurys Algorithm
To nd an Euler path or an Euler circuit: 1. Make sure the graph has either 0 or 2 odd vertices.

Fleurys Algorithm
To nd an Euler path or an Euler circuit: 1. Make sure the graph has either 0 or 2 odd vertices. 2. If there are 0 odd vertices, start anywhere. If there are 2 odd vertices, start at one of them.

Fleurys Algorithm
To nd an Euler path or an Euler circuit: 1. Make sure the graph has either 0 or 2 odd vertices. 2. If there are 0 odd vertices, start anywhere. If there are 2 odd vertices, start at one of them. 3. Follow edges one at a time. If you have a choice between a bridge and a non-bridge, always choose the non-bridge.

Fleurys Algorithm
To nd an Euler path or an Euler circuit: 1. Make sure the graph has either 0 or 2 odd vertices. 2. If there are 0 odd vertices, start anywhere. If there are 2 odd vertices, start at one of them. 3. Follow edges one at a time. If you have a choice between a bridge and a non-bridge, always choose the non-bridge. 4. Stop when you run out of edges.

Fleurys Algorithm
To nd an Euler path or an Euler circuit: 1. Make sure the graph has either 0 or 2 odd vertices. 2. If there are 0 odd vertices, start anywhere. If there are 2 odd vertices, start at one of them. 3. Follow edges one at a time. If you have a choice between a bridge and a non-bridge, always choose the non-bridge. 4. Stop when you run out of edges. This is called Fleurys algorithm, and it always works!

Fleurys Algorithm: Another Example


A E J N K O P D H M Q

B F

C G L

You might also like