Graph Terminology•A path that starts and ends at the same vertex is called a circuit.. Example 6: The graph on the left has no Euler paths, but the one on the right has several... B
Trang 1§5.2 - 5.3 Graphs and
Graph Terminology
“Liesez Euler, Liesez
maître à tous.”
- Pierre Laplace
Trang 2Graphs consist of
points called
vertices
lines called edges
1 Edges connect two
is a graph List its vertices and
Trang 3Example 2:
Flexo Bender Leela
Fry Amy
This is also a graph The vertices just
happen to have people’s names
Such a graph could represent friendships
(or any kind of relationship).
QuickTime™ and a
TIFF (LZW) decompressor
are needed to see this picture.
QuickTime™ and a TIFF (LZW) decompressor are needed to see this picture.
Farnsworth Zoidberg
Trang 4Flexo Bender
Amy Farnsworth
Now check out the graph below.
What can we say about it in comparison to
the previous figure?
QuickTime™ and a
TIFF (LZW) decompressor
are needed to see this picture.
QuickTime™ and a TIFF (LZW) decompressor are needed to see this picture.
Zoidberg
Trang 5• One graph may be drawn in
(infinitely) many ways, but it
always provides us with the same information.
• Graphs are a structure for
describing relationships between objects.
(The vertices denote the objects and the edges represent the relationship.)
Moral of the Story
Trang 6Graph Terminology
Trang 7Graph Terminology
(ie - all the math-y jargon one could ask for)
Adjacent Vertices are
two vertices that are
joined by an edge.
Adjacent Edges are
two edges that
intersect at a vertex.
The degree of a
vertex is the number of
Trang 8Graph Terminology
A loop counts twice
toward the degree.
An odd vertex is a vertex of odd degree.
An even vertex is a vertex of even degree.
Trang 10Graph Terminology
A path is a sequence
of vertices such that
each vertex is adjacent
to the next In a
path, each edge can be
traveled only once
•The length of a path
is the number of edges
in that path.
Trang 11Graph Terminology
•A path that starts
and ends at the same
vertex is called a
circuit .
•A graph is connected
if any two vertices
can be joined by a
path If this is not possible then the
disconnected
Trang 12disconnected.
Trang 13B H
S J
W K
Example 4:
1) Find a path from B to
K passing through W but not S.
2) Find a path from H to
Trang 14Graph Terminology
path that travels
through every edge of the graph (once and
circuit that travels
through every edge of
a graph.
Trang 15Example 6: The graph on the
left has no Euler paths, but
the one on the right has
several.
Trang 16§5.4 - 5.5 Graph Models and Euler’s
Theorems
“Now I will have less
distraction.”
- Leonhard Euler
after losing sight
in his right eye.
Trang 17Königsberg’s Bridges II
(The rare sequel that is not entirely
gratuitous.)
Recall from Tuesday the
puzzle that the residents
of Königsburg had been
unable to solve until
Euler’s arrival:
• Is there a way to cross
all seven bridges exactly
once and return to your
starting point?
• Is there even a way to
cross all seven bridges
L
D
Trang 18What Euler realized was that most of the information
on the maps had no impact on the answers to the two questions
By thinking of each bank and island as a vertex and each
bridge as an edge joining them Euler was able to model
the situation using the graph on the right Hence, the
K ö nigsberg puzzle is the same as asking if the graph has
Trang 19Example: Slay-
Slay-age
• The Scooby Gang needs to patrol the following section of
town starting at Sunnydale High (labeled G) Draw a
graph that models this situation, assuming that each
side of the street must be checked except for those
along the park (Map is from p 206)
Trang 20Example 2: (Exercise 21, pg 207) The
map to the right of downtown Kingsburg,
shows the Kings River running through
the downtown area and the three islands
(A, B, and C) connected to each other
and both banks by seven bridges The
Chamber of Commerce wants to design a
walking tour that crosses all the bridges
Draw a graph that models the layout of
Kingsburg
Trang 21Example 3:
The Kevin Bacon Game (http://www.cs.virginia.edu/oracle/)
Trang 22Euler’s Theorems
• Euler’s Theorem 1
(a) If a graph has any odd vertices, then
it cannot have an Euler circuit.
(b) If a graph is connected and every
vertex is even, then it has at least one Euler circuit.
Trang 23• Euler’s Theorem 2
(a) If a graph has more than two odd
vertices, then it cannot have an Euler
path.
(b) If a connected graph has exactly two
odd vertices then it has at least one
Euler path starting at one odd vertex
and ending at another odd vertex.
Trang 24Example 4: Königsburg’s Bridges IIIKönigsburg’s Bridges III (The Search For More Money The Search For More Money)
Let us consider again the Königsburg Brdige puzzle as represented by the graph below:
R
A
L
D
We have already seen that the puzzle boils down to whether this graph has
an Euler path and/or an Euler circuit Does this graph have either?
Trang 25Example 5: (Exercise 60, pg 214) Refer to Example 2 Is it possible to take a walk such that you cross each bridge exactly once? Explain why or why not.
N
S
Trang 26Example 6: Unicursal Tracings
Recall the routing problems presented on Tuesday:
•“Do these drawings have unicursal tracings? If so, are they open or closed?”
How might we answer these queries? Well, if we add vertices to the corners of the
tracings we can reduce the questions to asking whether the following graphs have Euler paths (open tracing) and/or Euler circuits (closed tracing)
Trang 27• Euler’s Theorem 3
(a) The sum of the degrees of all the
vertices of a graph equals twice the
number of edges.
(b) A graph always has an even number
of odd vertices.
Trang 28A quick summary Number of odd vertices
Conclusion
circuit(s)
path(s) but no Euler circuit
4, 6, 8, Graph has no Euler
path and no Euler circuit
1, 3, 5, Impossible!
Trang 29§5.6 Fleury’s
Algorithm
Trang 30• Euler’s Theorems give us a simple way
to see whether an Euler circuit or an
Euler path exists in a given graph, but how do we find the actual circuit or
path?
• We could use a “guess-and-check”
method, but for a large graph this could lead to many wasted hours and not
wasted in a particularly fun way!
Trang 31An algorithm is a set of procedures/rules that,
when followed, will always lead to a solution*
to a given problem.
• Some algorithms are formula driven they
arrive at answers by taking data and
‘plugging-in’ to some equation or function.
• Other algorithms are directive driven they arrive at answers by following a given set of directions.
Trang 32Fleury’s Algorithm
• The Idea:
“ Don’t burn your bridges behind you ”
(“bridges”: graph-theory bridges, not real world)
• When trying to find an Euler path or an Euler circuit, bridges are the last edges we should travel
• Subtle point: Once we have traversed an
edge we no longer care about it so by
“bridges” we mean the bridges of the part of the graph that we haven’t traveled yet
Trang 33Example 1: Does this graph have an Euler circuit? If so,
Trang 34Fleury’s Algorithm
1) Ensure the graph is connected and all the
vertices are even*.
2) Pick any vertex as the starting point.
3) When you have a choice, always travel along
an edge that is not a bridge of the
yet-to-be-traveled part of the graph.
4) Label the edges in the order which you travel 5) When you can’t travel anymore, stop.
* - This works when we have an Euler
circuit If we only have a path, we must start at one of (two) the odd
vertices
Trang 35Example 2: Do the following drawings have unicursal tracings? If
so, label the edges 1, 2, 3, In the order in which they can be
traced.
Trang 36Example 3: (Exercise 60, pg 214) The
map to the right of downtown Kingsburg,
shows the Kings River running through
the downtown area and the three islands
(A, B, and C) connected to each other
and both banks by seven bridges The
Chamber of Commerce wants to design a
walking tour that crosses all the bridges
Draw a graph that models the layout of
Kingsburg
It was shown yesterday that it was
possible to take a walk in such that you
cross each bridge exactly once Show
how
N
Trang 37Example: Slay-
Slay-age
• The Scooby Gang needs to patrol the following section of
town starting at Sunnydale High (labeled G) Suppose
that they must check each side of the street except for those along the park Find an optimal route for our
intrepid demon hunters to take.
Trang 39Mathematics and the
math-y for most
composers too
music-y for most
mathematicians
Trang 40Mathematics and the
Trang 41Fibonacci Numbers
• The Fibonacci Numbers
are those that comprise
• These numbers can be
used to draw a series
of ‘golden’ rectangles
like those to the
Trang 43The Golden Ratio
• In Piano Sonata No 1
the change between parts
occurs at measure 38 of
100 (which means that
part 2 is 62 ≈ 0.618 x
100)
Trang 44The Golden Ratio
• Another example in music
Trang 45The Golden Ratio in
Art
H
Trang 46The Golden Ratio in
Art
H
Trang 47The Golden Ratio in
Art
Trang 48The Golden Ratio in
Trang 49The Golden Ratio in