Академический Документы
Профессиональный Документы
Культура Документы
Algorithms
When the graph has an Euler circuit or
path, how do we find it? For small graphs,
simple trial-and-error usually works fine, but
real-life applications sometimes involve
graphs with hundreds, or even thousands,
of vertices. In these cases a trial-and-error
approach is out of the question, and what is
needed is a systematic strategy that tells us
how to create an Euler circuit or path. In
other words, we need an algorithm.
Copyright 2010 Pearson Education, Inc.
Algorithms
There are many types of problems that can
be solved by simply following a set of
procedural rulesvery specific rules like
when you get to this point, do this, ... after
you finish this, do that, and so on. Given a
specific problem X, an algorithm for solving
X is a set of procedural rules that, when
followed, always lead to some sort of
solution to X. X need not be a
mathematics problemalgorithms are used,
sometimes unwittingly, in all walks of life:
Copyright 2010 Pearson Education, Inc.
Algorithms
directions to find someones house, the
instructions for assembling a new bike, or a
recipe for baking an apple pie are all
examples of real-life algorithms. A useful
analogy is to think of the problem as a dish
we want to prepare and the algorithm as a
recipe for preparing that dish. In
mathematics, algorithms are either formula
driven (you just apply the formula or
formulas to the appropriate inputs) or
directive driven (you must follow a specific
set of directives).
Copyright 2010 Pearson Education, Inc.
Fleurys Algorithm
We will now turn our attention to an
algorithm that finds an Euler circuit or an
Euler path in a connected graph.
Technically speaking, these are two
separate algorithms, but in essence they
are identical, so they can be described as
one.
The idea behind Fleurys algorithm can be
paraphrased by that old piece of folk
wisdom: Dont burn your bridges behind
you.
Copyright 2010 Pearson Education, Inc.
Fleurys Algorithm
In graph theory the word bridge has a very specific
meaningit is the only edge connecting two
separate sections (call them
A and B)
of a
graph, as
illustrated
in Fig.
5-18.
Copyright 2010 Pearson Education, Inc.
Fleurys Algorithm
Thus, Fleurys algorithm is based on a
simple principle: To find an Euler circuit or
an Euler path, bridges are the last edges
you want to cross. Our concerns lie only on
how we are going to get around the yet-tobe-traveled part of the graph. Thus, when
we talk about bridges that we want to leave
as a last resort,we are really referring to
bridges of the to-be-traveled part of the
graph.
Copyright 2010 Pearson Education, Inc.