Unit 3 Introduction To Graph Theory

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

1

Unit 3:
Introduction to Graph Theory with Applications

Definition 1
A graph G = (V, E) consists of a finite nonempty set V , and E ⊆ V × V . The sets V and E
are the vertex set and edge set of G, respectively. We usually denote the vertex set of G
by V (G) and the edge set of G by E(G). Vertices are sometimes called points or nodes,
while edges are sometimes called lines.

Example 1. The following table lists six students at a college. An “X” indicates that the two
students participate in the same study group this semester.

Andrew Ian Jeremiah Katrina Perlyn Regine


Andrew − X X X
Ian X − X X X
Jeremiah X − X X
Katrina X X −
Perlyn X − X
Regine X X X X −

Draw a graph that represents this information where each vertex represents a student and an edge
connects two vertices if the corresponding students study together.
2

Definition 2
1. The edge e = {u, v} = uv is said to join the vertices u and v.

2. If e = uv is an edge of a graph G, then u and v are adjacent vertices, while u and e


are incident, so are v and e.

3. Furthermore, if e1 and e2 are distinct edges of G incident with a common vertex, then
e1 and e2 are adjacent edges.

4. A loop is an edge that joins a vertex with itself.

5. The degree of a vertex v in G, denoted by degG (v) or deg(v), is the number of edges
of G incident with v.

6. A vertex of degree 0 in G is called an isolated vertex and a vertex of degree 1 is an


end-vertex of G.

7. The cardinality of the vertex set of a graph G is called the order of G.

8. The cardinality of its edge set is the size of G.

Example 2. Consider the graph G below. Determine the degree of each vertex of G.

Theorem 1
1. The Handshaking Theorem: Let G = (V, E) be an undirected graph with m edges.
Then
X
2m = deg(v)
v∈V

(The sum of the degrees of all the vertices of a graph equals twice the number of edges.)

2. An undirected graph has an even number of vertices of odd degree.


3

Definition 3
A directed graph or digraph G = (V, E) consists of a finite set V of vertices and a set
E of directed edges or arcs which are ordered pairs of distinct vertices. In a digraph G, the
in-degree of a vertex v, denoted by id(v), is the number of edges with v as their terminal
vertex. The out-degree of v, denoted by od(v), is the number of edges with v as their
initial vertex. The degree of a vertex v of G is defined by deg(v) = od(v) + id(v).

Theorem 2
If G is a digraph of order n and size m with V (G) = {v1 , v2 , v3 , . . . , vn }, then
n
X n
X
od(vi ) = id(vi ) = m
i=1 i=1

Example 3. Determine the in-degree, out-degree, and degree of each vertex of the digraph below.

1.

2.
4

Definition 4
Let G = (V, E) be a graph.

1. A path in G is a sequence of vertices with no repeated edges.

2. A circuit in G is a path that starts and ends at the same vertex.

Example 4. Consider the graph below. Determine some paths and circuits

Definition 5
1. A graph G is said to be connected if there is a path joining any two of its vertices.
Otherwise, it is said to be disconnected.

2. Given a connected graph G. An edge in G is said to be a bridge if G becomes


disconnected when it is deleted.
5

The Seven Bridges of Königsberg


The town of Königsberg, Prussia (now called Kaliningrad and part of the Russian republic), was
divided into four sections by the branches of the Pregel River. These four sections included the
two regions on the banks of the Pregel, Kneiphof Island, and the region between the two branches
of the Pregel. In the eighteenth century, seven bridges connected these regions.

Question: Can you take a walk through the town, visiting each part of the town, and cross-
ing each bridge exactly once?

The townspeople took long walks through town on Sundays. They wondered whether it was
possible to start at some location in the town, travel across all the bridges once without crossing
any bridge twice, and return to the starting point.
The Swiss mathematician Leonhard Euler solved this problem. His solution, published in 1736,
may be the first use of graph theory.
6

Definition 6
1. An Euler path is a path that travels through every edge of G.

2. An Euler circuit is a circuit that travels through every edge of G.

Theorem 3: Euler’s Theorem 1


1. If a graph has any vertices of odd degree, then it cannot have an Euler circuit.

2. If a graph is connected and every vertex has an even degree, then it has at least one
Euler circuit. Such graphs are called Eulerian.

Fleury’s Algorithm for Finding an Euler Circuit

1. Make sure that the graph is connected and all vertices have even degree.

2. Start at any vertex.

3. Travel through an edge if:

(a) it is not a bridge for the untraveled part, or


(b) there is no other alternative

4. Label the edges in the order in which you travel them.

5. When you can’t travel any more, stop.

Example 5. Determine an Euler circuit, if there is any, for the following graphs.
7

Theorem 4: Euler’s Theorem 2


1. If a graph has more than two vertices of odd degree, then it cannot have an Euler path.

2. If a graph is connected and has just two vertices of odd degree, then it has at least
one Euler path. Any such path must start at one of the odd-degree vertices and end
at the other one.

Fleury’s Algorithm for Finding an Euler Path

1. Make sure that the graph is connected and only two vertices have odd degree.

2. Start at any of the two odd-degree vertices.

3. Travel through an edge if:

(a) it is not a bridge for the untraveled part, or


(b) there is no other alternative.

4. Label the edges in the order in which you travel them.

5. When you can’t travel any more, stop.

Example 6. Determine an Euler path, if there is any, for the following graphs.
8

Definition 7
Given a connected graph G.

1. A Hamilton path of G is a path that passes through each vertex exactly once.

2. A Hamilton circuit of G is a circuit that passes through each vertex exactly once.
A graph G that contains a Hamilton circuit is called Hamiltonian.

Example 7. Determine a Hamilton path and a Hamilton circuit, if there is any, for the following
graphs.
9

Applications I: Network Analysis

Definition 8
A weighted graph is a graph whose edges have an assigned numbers. Such numbers are
called weights. Common weights are time, distance, and cost.

Theorem 5: The Greedy Algorithm


1. Choose a vertex to start at, then travel along the connected edge that has the smallest
weight. (Note: 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.

Theorem 6: The Edge-Picking Algorithm

1. Mark the edge of the smallest weight in the graph. (Note: 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.
10

Example 8.

1. The cost of flying between various European cities is shown in the following table below.

London Berlin Paris Rome Madrid Vienna


London − $325 $160 $280 $250 $425
Berlin $325 − $415 $550 $675 $375
Paris $160 $415 − $495 $215 $545
Rome $280 $550 $495 − $380 $480
Madrid $250 $675 $215 $380 − $730
Vienna $425 $375 $545 $480 $730 −

Determine the lowest cost route that visits each city exactly once and starts and ends in
London using Greedy Algorithm and Edge-Picking Algorithm
11

2. Businesses often network their various computers. One option is to run cables from a central
hub to each computer individually; another is to connect one computer to the next, and that
one to the next, and so on until you return to the first computer. Thus the computers are all
connected in a large loop. Suppose a company wishes to use latter method, and the lengths
of cable (in feet) required between computers are given in the table below.

Comp A Comp B Comp C Comp D Comp E Comp F Comp G


Comp A − 43 25 6 28 30 45
Comp B 43 − 26 40 37 22 25
Comp C 25 26 − 20 52 8 50
Comp D 6 40 20 − 30 24 45
Comp E 28 37 52 30 − 49 20
Comp F 30 22 8 24 49 − 41
Comp G 45 25 50 45 20 41 −

Determine how the computers should be networked if the business wishes to use the smallest
amount of cable possible using Greedy Algorithm and Edge-Picking Algorithm.
12

Applications II: Graph Coloring and Scheduling


In the mid-1800s, Francis Guthrie was trying to color a map of the countries of England. So that
it would be easy to distinguish the countries, he wanted countries 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. (It was not
proved until over 100 years later.)

Definition 9
Graph coloring is a function of labeling either the vertices or edges of a graph for means
of classification. A coloring of a simple graph is the assignment of a color to each vertex (or
edge) of the graph so that no two adjacent vertices (or edges) are assigned the same color.

Definition 10
The chromatic number of a graph is the least number of colors needed for a coloring of
this graph. The chromatic number of a graph G is denoted by χ(G).

Definition 11
A graph is called planar if it can be drawn in the plane without any edges crossing (where
a crossing of edges is the intersection of the lines or arcs representing them at a point other
than their common endpoint). Such a drawing is called a planar representation of the
graph.

Remark: Every graph of a map is a planar graph.

Theorem 7: The Four Color Theorem


The chromatic number of a planar graph is at most four.

Vertex coloring rules:


1. Vertices connected by an edge must have different colors.

2. Use the fewest possible number of colors.


Algorithm for vertex coloring:
1. Assign color 1 to the vertex with highest degree and to any vertex not connected to this
vertex.

2. Assign color 2 to the vertex with the next highest degree not yet colored and to any vertex
not connected to this vertex.

3. Proceed in the previous manner until all vertices are colored.


13

Example 9.

1. What is the chromatic number of the planar graph representing this map?
14

2. A tropical fish collector had six different types of fish: Alphas, Betas, Certas, Deltas, Epsalas
and Fetas. Because of predator-prey relationships, water conditions, and size, some fish
cannot be kept in the same tank with other types of fish. The following table shows which
fish cannot be together:

Type of Fish Alphas Betas Certas Deltas Epsalas Fetas


Cannot be with Betas, Alphas, Alphas, Certas, Betas, Deltas,
Certas Certas, Betas, Fetas Certas, Epsalas
Epsalas Deltas, Fetas
Epsalas

What is the smallest number of tanks needed to keep the fishes? Be able to present which
types of fish will be kept in the same tank.
15

3. Eight different school clubs want to schedule meetings on the last day of the semester. Some
club members, however, belong to more than one of these clubs, so clubs that share members
cannot meet at the same time. How many different time slots are required so that all members
can attend all meetings? Be able to provide a scheduling for the eight clubs. (Clubs that
have a member in common are indicated with an “X” in the table below.)

SC SG DC HS SN CO CD CR
Ski club − X X X X
Student X − X X X
Government
Debate X − X X X
Club
Honor X X X − X X
Society
Student X X − X X
Newspaper
Community X X X − X X
Outreach
Campus X X X −
Democrats
Campus X X X −
Republicans
16

4. Five classes at an elementary school have arranged a tour at a zoo where the students get to
feed the animals:

(a) Class 1 wants to feed the elephants, giraffes, and hippos.


(b) Class 2 wants to feed the monkeys, rhinos, and elephants.
(c) Class 3 wants to feed the monkeys, deer, and sea lions.
(d) Class 4 wants to feed the parrots, giraffes, and polar bears.
(e) Class 5 wants to feed the sea lions, hippos, and polar bears.

If the zoo allows animals to be fed only once a day by one class of students, can the tour be
accomplished in two days? (Assume that each class will visit the zoo only on one day.) If
not, how many days will be required? Be able to provide a scheduling for the 5 classes.

You might also like