Chapter 5 - The Mathematics of Graphs

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 90

THE

MATHEMATICS
OF
GRAPHS
5.1 Introduction to Graph Theory
5.2 Euler Path And Circuit
5.3 Hamiltonian Path And Circuit
5.4 Graph Coloring
5.5 Trees
LEARNING OBJECTIVES

1. Differentiate Eulerian from Hamiltonian


graphs
2. Apply Euler and Hamiltonian paths to
solve problems
3. Apply Euler and Hamiltonian circuits to
solve problems
4. Solve problems using graphs
ACTIVITY

See if you can find a way to trace the shape without lifting your
pen and without tracing over the same segment.

1. 2.
ACTIVITY

See if you can find a way to trace the shape without lifting your
pen and without tracing over the same segment.

3. 4.
GRAPH THEORY

- A branch
of Mathematics concerned with
networks of points connected
by lines.
- It had its beginnings in
recreational math problems,
but it has grown into a
significant area of
mathematical research, with
applications in Chemistry,
Operations Research, Social
Sciences, and Computer
Sciences.
GRAPH THEORY

Seven Bridges of Konigsberg

- An eighteenth century problem,


- The City of Konigsberg
(Kaliningrad, Russia) has four
districts divided by the Pregel
River
- During that time, people were
puzzled if there is a travel route
that would only cross each of
the seven bridges exactly one
LEONHARD EULER

- A Swiss mathematician

- He proved in 1736 that it is


IMPOSSIBLE to take a stroll
that would lead them across
each bridge and return to the
starting point without
traversing the same bridge
twice
GRAPH

- A collection of points called


vertices or nodes and line
segments or curves called Vertices / Nodes
edges that connect the vertices
- The position of the vertices,
the lengths of the edges, and
the shape of the edges do not
matter in a graph Edges
- The number of vertices and
which of them are joined by
edges that matter most
CONSTRUCTING A GRAPH

The table on the next slide shows the lists of eleven cities
connected by Cebu Pacific Airline Flights. The symbol /
indicates that the cities have direct flights.

Draw a graph that represents this information where each


vertex represents a city and an edge connects two vertices if the
two cities have a direct flight.
CONSTRUCTING A GRAPH

Kuala Lumpur
Ho Chi Minh
Hong Kong

Bangkok

Singapore
Manila

Macau

Brunei
Taipei
Tokyo

Seoul
Manila / / / / / / / / / /
Tokyo / / /
Seoul / / / /
Taipei / / /
Hong Kong / /
Macau /
Bangkok / /
Ho Chi Minh / /
Kuala Lumpur / /
Singapore / /
DEFINITIONS

Loop

- Is an edge connecting a
vertex to itself
DEFINITIONS

Multiple Edges

- Two vertices that are


connected by more than
one edge
DEFINITION

Simple Graph

- A graph with no loops and


no multiple edges
DEFINITIONS
DEFINITIONS

Connected

- A graph is connected if
there is a path connecting
all the vertices
DEFINITIONS

Adjacent

- Two vertices are adjacent if


there is an edge joining
them
DEFINITIONS

Degree

- The degree of a vertex is


the number of edges
attached to it
EXAMPLES OF GRAPHS

Null or Disconnected Graphs

- A graph that has vertices but


no edges
EXAMPLES OF GRAPHS

Graph with a Loop

- A graph that has a vertex


which is connected by an
edge to itself
EXAMPLES OF GRAPHS

Graph with Multiple Edges

- A graph that has vertices


connected to other vertices
with more than one edge
DEFINITIONS

Complete Graph

- A graph is complete if every


pair of vertices of a graph
are adjacent
- A connected graph in which
every possible edge is
drawn between vertices
- A complete graph with n
vertices is denoted by K n
COMPLETE GRAPH

K 1 : One Vertex K 2 : Two Vertices


COMPLETE GRAPH

K 3 : Three Vertices K 4 : Four Vertices


COMPLETE GRAPH

K 5 : Five Vertices K 10 : Ten Vertices


COMPLETE GRAPH

Name Number of Vertices Number of Edges Degree of Each


(n) Vertex

K1 1 0 0

K2 2 1 1

K3 3 3 2

K4 4 6 3

K5 5 10 4

K10 10 45 9

Kn n n-1
EQUIVALENT GRAPHS

- A graph whose edges form the same connections of vertices


EQUIVALENT GRAPHS

Determine whether the following two graphs are equivalent.


EQUIVALENT GRAPHS

Determine whether the following two graphs are equivalent.


MATHEMATICS OF GRAPHS

Path

- An alternating sequence of
vertices and edges

- It can be seen as a trip


from one vertex to another
using the edges of the
graph
MATHEMATICS OF GRAPHS

Path

- An alternating sequence of
vertices and edges

- It can be seen as a trip


from one vertex to another
using the edges of the
graph
MATHEMATICS OF GRAPHS

Circuit / Cycle

- If a path begins and ends


with the same vertex

- it is a closed path
MATHEMATICS OF GRAPHS

Circuit / Cycle

- If a path begins and ends


with the same vertex

- it is a closed path
EULERS PATHS AND CIRCUITS
EULERS CIRCUIT

Euler Circuits

- A closed path that uses


every edge, but never uses
the same edge twice
- The path may cross
through vertices more than
once
- A graph that contains an
Euler Circuit is called
Eulerian
EULERS CIRCUIT

1. Determine whether the


following graph is Eulerian.
If it is, Find an eulerian
circuit.
If it is NOT, explain why.
EULERS CIRCUIT

1. Determine whether the


following graph is Eulerian.
If it is, Find an eulerian
circuit.
If it is NOT, explain why.
EULERS CIRCUIT

2. Determine whether the


following graph is Eulerian.
If it is, Find an eulerian
circuit.
If it is NOT, explain why.
EULERS CIRCUIT

2. Determine whether the


following graph is Eulerian.
If it is, Find an eulerian
circuit.
If it is NOT, explain why.
EULERS CIRCUIT

2. Determine whether the


following graph is Eulerian.
If it is, Find an eulerian
circuit.
If it is NOT, explain why.
EULERS CIRCUIT

3. Determine whether the


following graph is Eulerian.
If it is, Find an eulerian
circuit.
If it is NOT, explain why.
EULERS CIRCUIT

3. Determine whether the


following graph is Eulerian.
If it is, Find an eulerian
circuit.
If it is NOT, explain why.
EULERIAN GRAPH THEOREM

- A connected graph is
Eulerian if and only if every
vertex of the graph is of even
degree.
EULERIAN GRAPH THEOREM

Which of the following graph has an Euler Circuit?


EULERIAN GRAPH THEOREM

Determine whether the graph shown below is Eulerian. If it is,


find an Euler circuit. If it is not, explain how you know. The
number beside each vertex indicates the degree of the vertex.
EULERS PATH

Euler Path

- A path that uses every edge


in the graph exactly once
but it does not start and end
at the same vertex
EULERS PATH

Euler Path

- A path that uses every edge


in the graph exactly once
but it does not start and end
at the same vertex
EULERS PATH

- Determine whether the following graph is an Eulerian. If it is, find an


Eulerian Circuit. If its not, can you find an Eulerian Path?
EULERS PATH

- Determine whether the following graph is an Eulerian. If it is, find an


Eulerian Circuit. If its not, can you find an Eulerian Path?
EULERIAN PATH THEOREM

A connected graph contains an Euler Path if and only if the


graph has two vertices of odd degrees with all other vertices of
even degrees.

Every Euler Path must start at one of the vertices of odd


degrees and end at the other.
APPLICATION OF EULER PATH
THEOREM

At the right is the map of all trails


in Quezon National Park. A biker
would like to traverse all the trails
exactly once.
a. Is it possible for the biker to
plan a trip that traverses all the
trails exactly once?
b. Is it possible for him to traverse
all the trails and return to the
starting point without repeating
any trail in the trip?
HAMILTONIAN PATHS AND
CIRCUITS
HAMILTONIAN PATHS AND
CIRCUITS

Sir William Rowan Hamilton

- Irish mathematician whose


works proved significant for
the development of quantum
mechanics.
- In 1856 Hamilton investigated
closed paths along the edges
of a dodecahedron (one of
the Platonic Solids) that visit
each vertex exactly once
HAMILTONIAN CIRCUITS

Hamiltonian Circuits

- A path that uses each


vertex of a graph exactly
once and returns to the
starting vertex

- A graph that contains a


Hamiltonian Circuit is
called Hamiltonian
HAMILTONIAN CIRCUITS

Determine whether the graph


shown at the right is
Hamiltonian. If it is, find a
Hamiltonian Circuit. If it is
not, explain how you know.
HAMILTONIAN CIRCUITS

Determine whether the graph


shown at the right is
Hamiltonian. If it is, find a
Hamiltonian Circuit. If it is
not, explain how you know.
DIRAC’S THEOREM

Consider a connected graph with at least three vertices and


no multiple edges. Let n be the number of vertices in the graph.
If every vertex has degree of at least n/2, then the graph must
be Hamiltonian.
DIRAC’S THEOREM

The graph below shows the


available flights of a popular
airline. (An edge between two
vertices in the graph means that the
airline has direct flights between
the two corresponding cities.)
Apply Dirac’s theorem to verify
that the following graph is
Hamiltonian. Then find a
Hamiltonian circuit.
What does the Hamiltonian circuit
represent in terms of flights?
HAMILTONIAN PATH

Hamiltonian Path

- A path that visits each


vertex of the graph exactly
once
HAMILTONIAN PATH

Determine whether the graph


shown at the right has a
Hamiltonian Path. If it is, find
a Hamiltonian Path. If it is
not, explain how you know.
APPLICATION OF HAMILTONIAN
CIRCUITS AND PATHS

A large law firm has offices in seven


major cities. The firm has overnight
document deliveries scheduled every
day between certain offices. In the
graph below, an edge between
vertices indicates that there is
delivery service between the
corresponding offices.
Using the law firm’s existing delivery
service, is it possible to route a
document to all the offices and return
the document to its originating office
without sending it through the same
office twice?
WEIGHTED GRAPHS
WEIGHTED GRAPH

• A weighted graph is a
graph in which each edge
is associated with a value,
called a weight.

• The value can represent


any quantity we desire
WEIGHTED GRAPH

Application: The Traveling Salesman Problem


The table below lists the distances in miles between six popular cities
that a particular airline flies to. Suppose a traveler would like to start in
Chicago, visit the other five cities this airline flies to, and return to
Chicago. Find three different routes that the traveler could follow, and find
the total distance flown for each route.
WEIGHTED GRAPH

Graph:
WEIGHTED GRAPH

A route that visits each city just once corresponds to a Hamiltonian circuit.
a. Chicago – New York – Dallas – Philadelphia – Atlanta – Washington, D.C. – Chicago
713 + 1374 + 1299 + 670 + 544 + 597 = 5197
WEIGHTED GRAPH

A route that visits each city just once corresponds to a Hamiltonian circuit.
b. Chicago – Philadelphia – Dallas – Washington, D.C. – Atlanta – New York – Chicago

665 + 1299 + 1185 + 544 + 748 + 713 = 5154


WEIGHTED GRAPH

A route that visits each city just once corresponds to a Hamiltonian circuit.
c. Chicago – Washington, D.C. – Dallas – New York – Atlanta – Philadelphia – Chicago
597 + 1185 + 1374 + 748 + 670 + 665 = 5239
ALGORITHMS IN COMPLETE GRAPHS

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 vertex.

*The greedy algorithm is so called because it has us choose the “cheapest”


option at every chance we get.
THE GREEDY ALGORITHM

The table below lists down the distances (miles) between the cities having
direct routes as well as the corresponding distances between them.

Cagayan de Oro
Cities

Palawan

Ozamis
Manila

Davao
Cebu

Manila - 355 485 589 358 477


Cebu 355 - 137 240 354 148
Cagayan de Oro 485 137 - 118 414 64
Davao 589 240 118 - 495 133
Palawan 358 354 414 495 - 363
Ozamis 477 148 64 133 363 -
THE GREEDY ALGORITHM

Manila 355
Cebu

358 148
354
477
455
137
Ozami 363 Palawan
589 495
s
240
133 414

64
118
Davao Cagayan de Oro
ALGORITHMS IN COMPLETE GRAPHS

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 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.
THE EDGE-PICKING ALGORITHM

Manila 355
Cebu

358 148
354
477
455
137
Ozami 363 Palawan
589 495
s
240
133 414

64
118
Davao Cagayan de Oro
GRAPH COLORING
GRAPH COLORING

• In the mid-1800s, Francis Guthrie was


trying to color a map of the counties of
England. So that it would be easy to
distinguish the counties, he wanted
counties sharing a common border to
have different colors.
• After several attempts, he noticed that
four colors were required to color the
map, but not more. This observation
became known as the four-color
problem.

• Note that the map has only four colors and


that no two states that share a common border
have the same color.
GRAPH COLORING

Planar Graph
- a graph that can be drawn so that no edge intersect each other
(except at vertices)

Planar Non-Planar
GRAPH COLORING

Chromatic Number of a Graph


minimum number of colors needed to color a graph so that
no edge connects vertices of the same color
GRAPH COLORING

Two Colorable Graph Theorem


- a graph is two colorable if and only if it has no circuits that consist of
an odd number of vertices
GRAPH COLORING

Four-Color Theorem
- The chromatic number of a planar graph is at most 4
GRAPH COLORING

Application:
At the right shown the map of a
fictional town, labeled as letters, of a
barangay We will assume that no
barangay is split into more than one
piece and barangay that touch at just a
corner point will not be considered
neighbors. We can represent each
barangay by a vertex, placed anywhere
within the boundary of that barangay.
We will then connect two vertices with
an edge if the two corresponding
barangay are neighbors—that is, if they
share a common boundary.
GRAPH COLORING

Application:

Six college accreditation committees need to hold meetings on the


same day, but some teachers belong to more than one committee. In order
to avoid members missing meetings, the meeting need to be scheduled at
different times slots. An X in the table indicates that the two corresponding
committees share at least one member. Use graph coloring to determine the
minimum number of time slots necessary to ensure that all faculty members
can attend all meetings.
GRAPH COLORING

Faculty Instruction

Outreach Program
Faculty Development

Physical Facility

Student Welfare
Library Facility
Committee

Faculty Instruction - X X X
Faculty Development X - X X X
Outreach Program X - X X X
Physical Facility X X - X
Library Facility X X X - X
Student Welfare X X X X -
GRAPH COLORING

Faculty Instruction

Outreach Program
Faculty Development

Physical Facility

Student Welfare
Library Facility
Committee
FI FD

Faculty Instruction - X X X
OP
SW
Faculty
X - X X X
Development

Outreach Program X - X X X

Physical Facility X X - X

Library Facility X X X - X

LF PF
Student Welfare X X X X -
GRAPH COLORING

The minimum number of time slots


necessary to ensure that all faculty FI FD
members can attend all meetings is 3.
First Time Slot:
Faculty Instruction OP
Student Welfare SW

Second Time Slot:


Faculty Development
Outreach Program
Third Time Slot:
Library Facility
LF PF
Physical Facility
TREES
TREES

Tree
- A mathematical structure which is
a type of graph which has the
following properties:
a. Undirected
b. Connected (each of the vertices
is connected or linked to at least
one other vertex)
c. Acyclic (there is only one route
from any vertex to any other
vertex or has no cycle).
TREES

Terminologies:

Internal
Root Vertice
s

parent of 5
terminal
Vertices
Child of 4
TREES

Full M-ary Tree

- A tree in which all external


vertices are at the same depth or
has exactly m children
- Ex: Full Binary Tree (T 2 )

Height
- the number of edges along the
longest path from the root vertex
to the farthest child vertex
TREE

Given a full m-ary tree T of height h, T has:

a. Vertices m h 1  1
v
m 1

b. Internal Vertices
mh 1
i
m 1

c. Terminal Vertices
t  mh
TREE

A local basketball league Solution:


implements a new ruling of t = 16 teams
single-elimination wherein a m = 2 teams competing for
team is eliminated after a each ball game
single loss. If there are 16 mh 1
i
teams to compete in the m 1
tournament, how many 24  1
i
matches must be played to 2 1
determine the champion? 16  1
i  15 matches
1

You might also like