Chapter 6: Graph Theory and Fractals

advertisement






Chapter 6: Graph Theory and Fractals
Euler Circuits and Paths
Leonard Euler:
o born 1707
o Visited Konigsberg in
1736.
o Presented with problem:
There are 7 bridges over a
river as shown to the right.
Is it possible to cross all the
bridges only once and get
back to your starting point. The river is blue
and the land is green. It is assumed you can
walk anywhere on the land, and you cannot
walk over the river.
o Euler developed graph theory from this. He
made the bridges: edges, and the land
masses: vertices.
Graph Terms:
o A graph is said to be connected if every vertex is
connected to every other vertex by a path of edges.
 The graph above is connected.
 The graph to the right is not.
o A vertex is said to be of degree-n if it has n edges
connected to it.
 If n is even then the vertex is said to be even.
 If n is odd then the vertex is said to be odd.
o If you can traverse a graph beginning at a vertex, pass over each edge exactly
once, and return to the starting vertex, the path is called an Euler circuit.
o If you can traverse a graph beginning at a vertex, and pass over each edge
exactly once (you do not have to end up at the beginning vertex), this is called
an Euler path.
Theorem: A connected graph has an Euler path if and only if it has either no odd
vertices, or exactly two odd vertices. A connected graph has an Euler circuit if and
only if it has no odd vertices.
Which of the following three graphs have Euler paths? Which have Euler Circuits?
o The first has both (ABCDEACEBDA), the
second has neither, the third has an Euler
path (DCBEDBAEC).




Ex: What one edge can be added to the graph on the right so that it has an Euler
circuit?
Hamiltonian Cycles
o A Hamiltonian cycle in a graph is a path that starts at a vertex, visits each
vertex in the graph exactly once and returns to the starting point.
o There is no known way to determine
whether a graph has a Hamiltonian cycle
other than by trying every possible path.
(Computers)
o For the picture on the right does it have a
Hamiltonian cycle?
 Yes: ACDEBA
A graph in which the edges are
numbered (example: length) is called a
weighted graph.
o A salesman in Blacksburg wants
to visit the cities that are listed to
the right and whose distances are
given along the edges. What
path should he take to go the
minimum distance?
 Try all paths. We find
out the best is Blacksburg – Bluefield – Lewisburg – Lynchburg –
Blacksburg. (389 miles) (Note the reverse direction would also give
389 miles)
o The method of trying all paths is called the Brute Force Method and works
ok if you do not have many cities.
(n  1)!
o It turns out that the number of paths n 
, where n is the number of
2
cities. For n = 6, there are 60 paths (we do not count the reverse paths)
o Nearest Neighbor Algorithm: From your starting point go to the nearest
unvisited neighbor. Repeat the process until you return. Usually, this is not
the best path, but a good one.
 Ex: For the problem above: Blacksburg – Lewisburg – Bluefield –
Lynchburg – Blacksburg (total distance: 436 miles)
Trees
o A tree is a
connected graph
with no cycles.
(You cannot make a
trip through the
graph and return to
the same vertex visiting each vertex and using each edge only once.)
o The graph on the left is a tree. The graph on the right is not.
o A Spanning Tree


When you have a graph that contains cycles, and remove edges until
there are no cycles you then have what is called a spanning tree.
 Example: The graph to the left can be made into a
spanning tree on the right by removing the edges as
indicated. The number of spanning trees of one graph
can be many.
o Minimum Spanning Trees and Kruskal’s Algorithm
 Given a weighted graph (the edges have numbers assigned to them)
 Choose the edge of smallest weight.
 Choose the edge of smallest weight among all edges not yet
chosen, as long as it does not make a cycle. I the smallest
weight would make a cycle take the next lowest weight.
 Continue until all vertices are connected.
 Example: 5 buildings A, B, C, D, and E
will be connected by fiber-optic cable
costing $5 per foot. The weights on the
edges show the distances between the
buildings. What is the cheapest way to
connect the buildings? What is the total
cost of your solution?
 Include CD, then AB, then AF, then
EF, then ED. Note: BF cannot be
included for that would create a cycle.
Fractals
o A point has dimension 0. A line has dimension 1, a
plane has dimension 2. A Fractal is an object that has a fractional dimensional
value.
o Fractals can be generated in many ways. The way that we will construct
fractals for this class is a follows:
 Create a line segment of unit length.
 Divide the line segment into equal number of segments.
 Replace the middle segment with a predefined shape. This line
segment, the way it is shaped, becomes the generator for all future
steps. (See example below).
 Replace each line segment with the generator shape. Repeat to
infinity.
o Example: This is the generator shape ->


The Dimension of a Fractal
o Let’s see how it works with regular dimensional objects. Consider a line
which has dimension D = 1.
 Now let r be a number that represents the length of a ruler. (A ruler is
an object then measures one length of a segment exactly). So if we
divide our unit length line into N equal pieces then the length of our
1
1
ruler is r  . We want to write this for N: N  .
N
r
o Now consider a square whose sides are of unit length. A square has
Dimension 2. Notice That if you divide each of the sides in half of a square
you get 4 squares. If you divide each of the sides into thirds you get nine
1
squares. The relationship is squared: N  2
r
1
o For a cube: Dimension is 3, it is not hard to see that N  3 . Example:
r
Divide each edge into 3 equal segments and you get 27 cubes.
1
o The Dimension then is defined as: N  D . If we solve for D we
r
log N
log N
obtain: D 

1
log r
log
1
( )
r
o Example: In the example above: The generator has N = 4 pieces, and each
log 4
log 4

 1.26 .
piece is 1/3 unit long. D 
1
log 3
log
1
( )
3
o Example: Here is my
generator for the fractal.
Notice that the original unit
line is divided into r = 5
pieces (the ruler is 1/5 unit) pieces and that the generator has N = 7 segments.
log 7
 D
 1.21
log 5
Download