Sie sind auf Seite 1von 44

Mathematics of Graphs

Unit V
If you’re a frequent traveler, a
hiker, an outdoorsman or a weekend
vacationer, Camiguin should be in
your must- visit islands in the
Philippines. With so many places to
visit within – beaches, mountains,
falls, hot and cold springs, Camiguin
is a safe-adventure haven for you and
me.
The figure represents the map
Camiguin Islands. Create a plan of
your visit so that you can visit the
most enchanting spots of the island
in a ONE DAY tour.
Introduction to Graphs
Think of all the various connections we experience in
our lives - friends are connected on facebook, cities
are connected on roads, computers networks,
chemical compounds and the like.
A branch of mathematics called graph theory
illustrates and analyzes connections such as these.

For example, the diagram in Figure 5.1.1 represent


Figure 5.1.1
friends that are connected on Facebook . Each dot
represents a person, and a line segment connecting
two dots means that those two people are friends on
Facebook. This type of diagram is called a graph.
GRAPH

A 𝒈𝒓𝒂𝒑𝒉 𝐺 consists of a pair (𝑉, 𝐸) where 𝑉(𝐺) is nonempty


finite set whose elements are 𝒗𝒆𝒓𝒕𝒊𝒄𝒆𝒔 and 𝐸(𝐺) is a set of
unordered pairs of distinct elements of 𝑉 called the 𝒆𝒅𝒈𝒆𝒔 of
graph 𝐺.

If 𝑒 = 𝑢𝑣 ∈ 𝐸(𝐺), the edge 𝑒 is said to join vertices 𝑢, 𝑣 ∈ 𝑉(𝐺) of a graph


𝐺. We write 𝑒 = 𝑢, 𝑣 and we say that the vertices 𝑢 and 𝑣 are 𝒂𝒅𝒋𝒂𝒄𝒆𝒏𝒕. We
also say that the vertex 𝑢 and the edge 𝑒 are 𝒊𝒏𝒄𝒊𝒅𝒆𝒏𝒕 with each other. If two
edges 𝑒1 and 𝑒2 are incident with a common vertex, then they are called
𝒂𝒅𝒋𝒂𝒄𝒆𝒏𝒕 𝒆𝒅𝒈𝒆𝒔. The number of vertices in G is called the 𝒐𝒓𝒅𝒆𝒓 of 𝐺. The
number of edges of 𝐺 is called the 𝒔𝒊𝒛𝒆 of 𝐺.
As an example, the graph depicted in Figure 5.1.2 has vertex set
𝑉 = {𝑎, 𝑏, 𝑐, 𝑑, 𝑒. 𝑓} and an edge set 𝐸 = {(𝑎, 𝑏), (𝑏, 𝑐), (𝑐, 𝑑), (𝑐, 𝑒), (𝑑, 𝑒), (𝑒, 𝑓)}.
d

e f
a b
c
Vertices are
always clearly
Figure 5.1.2
indicated with a
“dot.” Edges that Vertex set: 𝑉 = {𝑎, 𝑏, 𝑐, 𝑑, 𝑒, 𝑓} Figure 5.1.3
intersect with no Edge set: 𝐸 = 𝑎𝑏, 𝑏𝑐, 𝑐𝑑, 𝑑𝑒, 𝑒𝑓, 𝑐𝑒 This graph has four
marked vertex are vertices but no edges
Order: 6
considered to and is referred to as a
cross over each Size: 6 null graph. It is also
other without vertices 𝑎 and 𝑏 are adjacent vertices an example of a
touching. edge 𝑎𝑏 is incident with vertices 𝑎 and 𝑏 disconnected
graph.
In general, graphs can contain vertices that are not connected to any edges, two
or more edges that connect the same vertices (called multiple edges), or edges that
loop back to the same vertex. We will usually deal with connected graphs, graphs in
which any vertex can be reached from any other vertex by tracing along edges.
(Essentially, the graph consists of only one “piece.”) Several examples of graphs are
shown below.

This graph is not connected. It


also contains a loop.

This is a connected graph in which


This is a connected every possible edge is drawn
graph that has a pair of between vertices (without any
multiple edges. multiple edges). Such a graph is
called a complete graph.
Equivalent Graphs

The three graphs shown above are considered equivalent graphs


because the edges form the same connections of vertices in
each graph.
Example.
PATH
A Path is a sequence of edges that begins at a vertex of a graph and travels along
edges of the graph, always connecting pairs of adjacent vertices.

If a path ends at the same vertex at which it started, it is considered a closed path or
circuit.

Example: The path A–D–F–G–E–B–A is a circuit because it begins and ends at the same
vertex. The path A–D–F–G–E–H is not a circuit, as it does not begin and end at the same
vertex.
ISOMORPHISM
Two graphs 𝐺1 and 𝐺2 are 𝒊𝒔𝒐𝒎𝒐𝒓𝒑𝒉𝒊𝒄 denoted by 𝑮𝟏 ≅ 𝑮𝟐 , if
there is a one to one correspondence between the vertices of 𝐺1 and 𝐺2
such that the number of edges joining any two vertices of 𝐺1 is equal to
the number of edges joining the corresponding vertices of 𝐺2 . In the same
way, two graphs 𝐺1 and 𝐺2 are isomorphic if these graphs are identical.
Example 5.1.2 The two graphs shown in Figure 5.1.6 are completely different; however
the graphs can be rearranged so that the graphs are identical (see Figure 5.1.7).
Consider the mapping between the vertices of graphs 𝐺 and 𝐻, that is 𝑎 ↔ 1,2 ↔
ℎ, 3 ↔ 𝑑, 4 ↔ 𝑖, 5 ↔ 𝑔, 6 ↔ 𝑏, 7 ↔ 𝑗, 8 ↔ 𝑑 . Therefore, graphs 𝐺 and 𝐻 are
isomorphic.

Figure 5.1.6 isomorphic graphs, G≅ 𝐻 Figure 5.1.7 identical graphs 𝐺 and 𝐻


Exercise:
1. How many vertices are there in the figure?

2. How many edges are there in the graph?

3. Count and record the number of edges


attached to every vertex.

4. How many routes can you find from Z to W?


List them all.

5. How many other routes can you find


beginning and ending in V with at most 4
stops? List them all.
EULER CIRCUITS

Leonhard Euler was one of the most prolific mathematicians


of all time. He wrote hundreds of papers in almost every area of
mathematics. In one of these papers, published in 1736 Euler
proved that it was impossible to traverse each of the bridges of
Königsberg exactly once and return to the starting point. Although
he did not present his paper in the language of graph theory, his
arguments were equivalent to our discussion in this section. In
fact, his proof was more general than just a proof of the
Königsberg bridges problem, and it can be considered the first
paper in graph theory.
The good people of Königsberg,
Germany had a puzzle that they
liked to contemplate while on their
Sunday afternoon walks through
the village. The Pregel River
completely surrounded the central
part of Königsberg, dividing it into
two islands.

PUZZLE:
Was it possible to pick a starting
point in the town and find a
walking route which would take
them over each bridge exactly
once?
EULER CIRCUITS

To solve the Königsberg bridges problem , we can


represent the arrangement of land areas and bridges
with a graph.
Let each land area be represented by a vertex, and
connect two vertices if there is a bridge spanning the
corresponding land areas. Then the geographical
situation becomes the graph shown on the left.
In terms of a graph, the original problem can be stated as follows:
Can we start at any vertex, move through each edge once (but not
more than once), and return to the starting vertex?

Every attempt seems to end in failure. It was Leonhard Euler who


proved this task impossible.
If a path ends at the same vertex at which
it started, it is considered a closed path or
circuit.
The path A–D–F–G–E–B–A is a circuit because
it begins and ends at the same vertex.
The path A–D–F–G–E–H is not a circuit, as it
does not begin and end at the same vertex.
EULER PATHS AND 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 different vertices. An


Euler circuit start and ends at the same vertex.
In this lesson we will see how Euler paths and circuits can be used to solve real-world
problems. Let us help Mr. Man in delivering the packages to the addresses on eleven
different streets, shown in Figure 5.2.3, the simplified version of the map drawn by Mr.
Man with vertices as the road intersections and lines as the roads. In order for him to
make the best use of his time, he needs to walk each edge just once.

Example 5.2.2 Looking at the graph in Figure


5.2.3 starting and ending at vertex pointed with
an arrow, the Mr. man can follow the route A-D-
C-B-E-I-J-G-F-H-K. Since the he can end up at the
vertex where he began, he actually walked an
Euler circuit. Are there other ways he could have
done an Euler circuit?

Have you wondered if there is a way to find out if


the given graph is Eulerian? That is, one can pass
through all the edges exactly once and return to
the starting vertex by not doing a trial and error? 𝐹𝑖𝑔𝑢𝑟𝑒 5.2.3
Theorem 5.2.1 ( Euler 1736)
A connected graph 𝐺 is Eulerian if and only if the degree of each
vertex of 𝐺 is even.

Remark: A connected graph with exactly two odd vertices has at least one Euler path but no
Euler circuit. Each Euler path must begin at one of the two odd vertices, and it will end at the
other odd vertex.

Example 5.2.3 Does


the graph in Figure
5.2.4 have an Euler
circuit? How about the
graph in Figure 5.2.5?

𝐹𝑖𝑔𝑢𝑟𝑒 5.2.4
𝐹𝑖𝑔𝑢𝑟𝑒 5.2.5
All of this relates to the Königsberg bridges problem in the following way:
Finding a path that crosses each bridge exactly once and returns to the starting
point is equivalent to finding an Euler circuit essentially proved by Leonhard Euler
that could not have an Euler circuit. He accomplished this by examining the
number of edges that met at each vertex. He made the observation that in order
to complete the desired path, every time you approached a vertex you would then
need to leave that vertex. If you travelled through that vertex again, you would
again need an approaching edge and a departing edge.
Thus, for an Euler circuit to exist, the degree of every vertex would have to
be an even number. Furthermore, he was able to show that any graph that has
even degree at every vertex must have an Euler circuit. Consequently, such graphs
are called Eulerian.
Theorem 5.2.1 ( Euler 1736)
A connected graph 𝐺 is Eulerian if and only if the degree of each vertex
of 𝐺 is even.

Since every vertex has an even degree, by


Eulerian Graph Theorem, the graph is Eulerian.
No. of vertices No. of vertices
No. of Euler Euler
Graph with even with odd
vertices Path? Circuit?
degree degree

5 3 2 Yes No
No. of vertices No. of vertices
No. of Euler Euler
Graph with even with odd
vertices Path? Circuit?
degree degree
No. of vertices No. of vertices
No. of Euler Euler
Graph with even with odd
vertices Path? Circuit?
degree degree
Weighted Graphs
Sometimes more information needs to be conveyed in a graph. For
instance, in Konigsberg Bridge problem, the focus was on the parts of
the land connected by bridges. Some problems require consideration of
how long (in terms of distance or time) it takes to traverse a given edge.
The graphs that appear in this lesson have weights associated with their
edges. As with many mathematical problems, the focus is on finding
extreme paths (that is, paths that maximize or minimize a certain
quantity).
Example 5.3.1. Shown in Figure 5.3.1 a weighted graph where
the number of miles (as weight) between the corresponding
cities.

Figure 5.3.1
A path from a vertex 𝑢 to a vertex 𝑣 of a graph is a sequence of adjacent edges
starting 𝑢 and ending in 𝑣 such that the end of each edge other than the last one is the
start of the next edge in the sequence. The length of a path is the sum of the weights of
the edges of the path.

Example:
There are five paths from
A to F:
Length
ABCDF 6+8+11+7=32
ACEF 8+7+6=21
ABDF 6+9+7=22
ACBDF 8+8+9+7=32
ACDF 8+11+7=26

Thus, the shortest path


from A to F is ACEF.
Hamiltonian Circuits
Hamiltonian Circuit
▪ A path on a graph that goes through
each vertex once is called a Hamiltonian
path.
▪ A path that starts and stops at the same
vertex and goes through each vertex
once is called a Hamiltonian circuit.
▪ A graph that contains a Hamiltonian
circuit is called Hamiltonian.
Hamiltonian Circuit
▪ A path on a graph that goes through
each vertex once is called a Hamiltonian
path.
▪ A path that starts and stops at the same
vertex and goes through each vertex
once is called a Hamiltonian circuit.
▪ A graph that contains a Hamiltonian
circuit is called Hamiltonian.
Dirac’s Theorem
Consider a connected graph with Example:
at least three vertices and no multiple Manila Cebu
edges. Let 𝑛 be the number of vertices in
the graph. If every vertex has degree of at
𝑛
least , then the graph must be
2
Hamiltonian.

Puerto Davao
NOTE: If graphs do not meet the requirements of
this theorem, it still might be Hamiltonian. Princesa
a 5.4.1.
Figure Figure
Flights in5.4.1
the Philippines
Example:
The table below lists the number of minutes spent traveling by an airline between the
four popular destinations in the Philippines. Suppose a traveller would like to start in Davao,
visit the other three cities this airline flies to, and return to Davao. Find at least two different
routes that the traveller could follow, and find the total travel time flown for each route.

Puerto
Cebu Davao Manila
Princesa Manila Cebu

Cebu - 60 80 75
Davao 60 - 110 90
Manila 80 110 - 75 Puerto Davao
Princesa
Puerto a Figure 5.4.1
75 90 75 -
Princesa
POSSIBLE ROUTES:
Davao - Cebu - Puerto Princesa - Manila - Davao
Total travel time: 60+75+75+110 = 320
Davao - Manila - Puerto Princesa - Cebu – Davao
Total travel time: 110+75+75+60 = 320
Davao - Cebu – Manila - Puerto Princesa - Davao
Total travel time: 60+80+75+90 = 305
Davao - Puerto Princesa - Cebu - Manila - Davao
Total travel time: 90+75+80+110 = 355
Algorithms on finding the optimal Hamiltonian circuit

NOTE: Both of these algorithms apply only to complete graphs - graphs in which every possible edge is drawn
between vertices (without any multiple edges).

The Greedy Algorithm The Edge-Picking Algorithm


1. Choose a vertex to start at, then travel along 1. Mark the edge of smallest weight in the graph. (If
the connected edge that has the smallest two or more edges have the same weight, pick
weight. (If two or more edges have the same any one.)
weight, pick any one.)
2. Mark the edge of the next smallest weight in the
2. After arriving at the next vertex, travel along the graph, as long as it does not complete a circuit
edge of smallest weight that connects to a and does not add a third marked edge to a single
vertex not yet visited. Continue this process vertex.
until you have visited all vertices.
3. Continue this process until you can no longer
3. Return to the starting vertices.
mark any edges. Then mark the final edge that
completes the Hamiltonian circuit.
Example: The cost of flying between various Philippine cities is shown in the following table.
Use both the greedy algorithm and the edge-picking algorithm to find a low-cost route that
visits each city just once and starts and ends in Manila. Which route is more economical?

SOLUTION:

Puerto
Cebu Davao Manila
Princesa

Cebu
- ₱1,900 ₱2,100 ₱1,850
Davao
₱1,900 - ₱2,400 ₱2,450
Manila
₱2,100 ₱2,400 - ₱2,300
Puerto
Princes ₱1,850 ₱2,450 ₱2,300 -
a
Example: The cost of flying between various Philippine cities is shown in the following table.
Use both the greedy algorithm and the edge-picking algorithm to find a low-cost route that
visits each city just once and starts and ends in Manila. Which route is more economical?

The Greedy Algorithm


1. Choose a vertex to start at, then travel along
the connected edge that has the smallest
weight. (If two or more edges have the same
weight, pick any one.)
2. After arriving at the next vertex, travel along the
edge of smallest weight that connects to a
vertex not yet visited. Continue this process
until you have visited all vertices.
3. Return to the starting vertices.

RESULTING ROUTE: TOTAL WEIGHT:


Manila – Cebu – Puerto Princesa – Davao – Manila 2100 + 1850 + 2450 + 2400 = ₱𝟖, 𝟖𝟎𝟎
Example: The cost of flying between various Philippine cities is shown in the following table.
Use both the greedy algorithm and the edge-picking algorithm to find a low-cost route that
visits each city just once and starts and ends in Manila. Which route is more economical?

The Edge-Picking Algorithm


1. Mark the edge of smallest weight in the graph. (If
two or more edges have the same weight, pick
any one.)
2. Mark the edge of the next smallest weight in the
graph, as long as it does not complete a circuit
and does not add a third marked edge to a single
vertex.
3. Continue this process until you can no longer
mark any edges. Then mark the final edge that
completes the Hamiltonian circuit.

RESULTING ROUTE:
TOTAL WEIGHT:
Manila – Davao – Cebu – Puerto Princesa
Puerto Princesa – Manila
2400 + 1900 + 1850 + 2300 = ₱𝟖, 𝟒𝟓𝟎
Use the Greedy and Edge-picking Algorithms to find a Hamiltonian circuit in the
graph. Start at vertex A.

GREEDY ALGORITHM:

𝑨– 𝑫– 𝑩– 𝑭– 𝑬– 𝑪 − 𝑨
𝟒 + 𝟐 + 𝟓 + 𝟏𝟎 + 𝟔 + 𝟏𝟓 = 𝟒𝟐

EDGE-PICKING ALGORITHM:

𝑨– 𝑫– 𝑩– 𝑭– 𝑪– 𝑬 − 𝑨
𝟒 + 𝟐 + 𝟓 + 𝟏𝟒 + 𝟔 + 𝟓 = 𝟑𝟔
The cost of flying between various European cities is shown in the table

QUIZ: below. Use both the greedy algorithm and the edge-picking algorithm to find a
low-cost route that visits each city just once and starts and ends in London.
Which route is more economical?

London, Berlin, Paris, Rome, Madrid, Vienna,


England Germany France Italy Spain Austria
London,
England - 325 160 280 250 425
Berlin,
Germany 325 - 415 550 675 375
Paris,
France 160 415 - 495 215 545
Rome,
Italy 280 550 495 - 380 480
Madrid,
Spain 250 675 215 380 - 730
Vienna,
Austria 425 375 545 480 730 -

Das könnte Ihnen auch gefallen