Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
23 views46 pages

Chapter 5 - Elementary Graph Theory

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 46

SMA 2203

Discrete Mathematics

Chapter 5
Elementary Graph Theory
Chapter Summary
 Introduction
Applications of Graph Theory
Graph models
Directed Graphs
Terminologies
Special Graphs
Connectivity
Representing Graphs
Isomorphism of Graphs
Weighted Graphs
Euler Paths, Circuits, Eulerian graph and Traversability
Hamilton Paths and Circuits
Shortest path problem
Trees
Introduction

3
4
5
6
Introduction to Graphs
 Definition:

A graph G = (V, E) consists of a nonempty set V of vertices (or nodes) and a set E
of edges. Each edge has either one or two vertices associated with it, called its
endpoints. An edge is said to connect its endpoints.

 Example:

This is a graph
with four
vertices and five
edges.
Applications of Graph Theory
Graph theory has its applications in diverse fields of engineering ,

 ElectricalEngineering − The concepts of graph theory is used extensively in designing circuit


connections.

 Computer Science − Graph theory is used for the study of algorithms. For example,
◦ Kruskal's Algorithm
◦ Prim's Algorithm
◦ Dijkstra's Algorithm

 Computer Network − The relationships among interconnected computers in the network follows the
principles of graph theory.

 Science − The molecular structure and chemical structure of a substance, the DNA structure of an organism,
etc., are represented by graphs.

 Linguistics − The parsing tree of a language and grammar of a language uses graphs.

 General − Routes between the cities can be represented using graphs. Depicting hierarchical ordered
information such as family tree can be used as a special type of graph called tree.
Graph Models
One of the most interesting and powerful features of graphs is that they can
be used to model structures.
◦We can model relationships
◦Computer networks
◦Flight schedules
◦etc.

Ex: Graph Models: Social Networks


Graph Terminology

In
a simple graph each edge connects two different vertices and no two
edges connect the same pair of vertices.

Multigraphs may have multiple edges connecting the same two vertices.
When m different edges connect the vertices u and v, we say that {u,v} is an
edge of multiplicity m.

An edge that connects a vertex to itself is called a loop.

A pseudograph may include loops, as well as multiple edges


connecting the same pair of vertices.
Directed Graphs
Definition: An directed graph (or digraph) G = (V, E) consists of a
nonempty set V of vertices (or nodes) and a set E of directed edges (or arcs).
Each edge is associated with an ordered pair of vertices. The directed edge
associated with the ordered pair (u,v) is said to start at u and end at v.

Remark:
Graphs where the end points of an edge are not ordered are said to be
undirected graphs.
Graph Terminology (continued)

A simple directed graph has no loops and no multiple edges.

A directed multigraph may have multiple directed edges. When there are m
directed edges from the vertex u to the vertex v, we say that (u,v) is an edge
of multiplicity m.
Graph Terminology: Summary
Graph Terminology (continued)
Definition:

Two vertices u and v in an undirected graph G are called adjacent (or


neighbors) in G if {u, v} is an edge in G.
If e = {u, v}, the edge e is called incident with the vertices u and v. The edge

e is also said to connect u and v.


The vertices u and v are called endpoints of the edge {u, v}.

Definition:

The degree of a vertex in an undirected graph is the number of edges


incident with it, except that a loop at a vertex contributes twice to the degree
of that vertex.
In other words, you can determine the degree of a vertex in a displayed graph

by counting the lines that touch it.


The degree of the vertex v is denoted by deg(v).
Graph Terminology (continued)
A vertex of degree 0 is called isolated, since it is not adjacent to any vertex.
Note: A vertex with a loop at it has at least degree 2 and, by definition, is not

isolated, even if it is not adjacent to any other vertex.


A vertex of degree 1 is called pendant. It is adjacent to exactly one other

vertex.
Example: Which vertices in the following graph are isolated, which are

pendant, and what is the maximum degree? What type of graph is it?

Solution:
Vertex f is isolated, and vertices a, d and j are pendant. The
maximum degree is deg(g) = 5. This graph is a pseudograph (undirected,
loops).
Graph Terminology (continued)

The Handshaking Theorem:


Let G = (V, E) be an undirected graph with e edges. Then 2e = .

Example:

How many edges are there in a graph with 10 vertices, each of degree 6?

Solution:

The sum of the degrees of the vertices is 610 = 60. According to the
Handshaking Theorem, it follows that 2e = 60, so there are 30 edges.
Graph Terminology (continued)

Theorem: An undirected graph has an even number of vertices of odd


degree.

Proof:

Let and be the set of vertices of even and odd degrees, respectively (Thus 
= , and  = V).
Then by Handshaking theorem

2|E| = = +

Since both 2|E| and are even,


vV2 deg(v) must be even.
Since deg(v) if odd for all , || must be even.
Graph Terminology (continued)
Definition:

When (u, v) is an edge of the graph G with directed edges, u is said to be


adjacent to v, and v is said to be adjacent from u.
The vertex u is called the initial vertex of (u, v), and v is called the terminal

vertex of (u, v).


The initial vertex and terminal vertex of a loop are the same.

Definition:

In a graph with directed edges, the in-degree of a vertex v, denoted by deg-

(v), is the number of edges with v as their terminal vertex.


The out-degree of v, denoted by deg+(v), is the number of edges with v as

their initial vertex.


Question: How does adding a loop to a vertex change the in-degree and out-

degree of that vertex?


Answer: It increases both the in-degree and the out-degree by one.
Graph Terminology (continued)

Example: What are the in-degrees and out-degrees of the vertices a, b, c, d


in this graph.
Graph Terminology (continued)

Theorem:

Let G = (V, E) be a graph with directed edges. Then:


vV deg-(v) = vV deg+(v) = |E|

This is easy to see, because every new edge increases both the sum of
in-degrees and the sum of out-degrees by one.
Special Graphs
Definition:

The complete graph on n vertices, denoted by Kn, is the simple graph that
contains exactly one edge between each pair of distinct vertices.
Special Graphs
Definition:

The cycle Cn, n  3, consists of n vertices v1, v2, …, vn and edges {v1, v2},
{v2, v3}, …, {vn-1, vn}, {vn, v1}.
Special Graphs
Definition:

We obtain the wheel Wn when we add an additional vertex to the cycle Cn,
for n  3, and connect this new vertex to each of the n vertices in C n by adding
new edges.
Special Graphs
Definition:

A simple graph is called bipartite if its vertex set V can be partitioned into
two disjoint nonempty sets V1 and V2 such that every edge in the graph
connects a vertex in V1 with a vertex in V2 (so that no edge in G connects
either two vertices in V1 or two vertices in V2).

For example, consider a graph that represents each person in a village by a


vertex and each marriage by an edge.

This graph is bipartite, because each edge connects a vertex in the subset of
males with a vertex in the subset of females (if we think of traditional
marriages).
Special Graphs
Example I: Is C6 bipartite?

Example II: Is C3 bipartite?


Special Graphs
Definition:

The complete bipartite graph Km,n is the graph that has its vertex set
partitioned into two subsets of m and n vertices, respectively. Two vertices are
connected if and only if they are in different subsets.

K3,2 K3,4
Representing Graphs
Representing Graphs
Definition:

Let G = (V, E) be a simple graph with |V| = n. Suppose that the vertices of G
are listed in arbitrary order as v1, v2, …, vn.

The adjacency matrix A (or AG) of G, with respect to this listing of the
vertices, is the nn zero-one matrix with 1 as its (i, j)th entry when v i and vj
are adjacent, and 0 otherwise.
In other words, for an adjacency matrix A = [a ],
ij

 aij = 1 if {vi, vj} is an edge of G,


aij = 0 otherwise.
Representing Graphs
a
Example:
b
What is the adjacency matrix AG for the following
d
graph G based on the order of vertices a, b, c, d ?
c
Solution:
0 1 1 1
1 0 0 1
AG  
1 0 0 1
 
1 1 1 0

Note: Adjacency matrices of undirected graphs are always symmetric


Representing Graphs
Definition:

Let G = (V, E) be an undirected graph with |V| = n. Suppose that the vertices
and edges of G are listed in arbitrary order as v 1, v2, …, vn and e1, e2, …, em,
respectively.

The incidence matrix of G with respect to this listing of the vertices and
edges is the nm zero-one matrix with 1 as its (i, j)th entry when edge e j is
incident with vi, and 0 otherwise.

In other words, for an incidence matrix M = [mij],


 mij = 1 if edge ej is incident with vi
mij = 0 otherwise.
Representing Graphs
a 1
Example: 2
b
What is the incidence matrix M for the following
d 3
graph G based on the order of vertices a, b, c, d 5
and edges 1, 2, 3, 4, 5, 6? 4 c

Solution: 1 1 0 0 1 0
1 6
0 1 0 0 0
M 
0 0 0 1 1 1
 
0 1 1 1 0 0

Note: Incidence matrices of directed graphs contain two 1s per column for
edges connecting two vertices and one 1 per column for loops.
Isomorphism of Graphs
Definition:

The simple graphs G1 = (V1, E1) and G2 = (V2, E2) are isomorphic if there is
a bijection (an one-to-one and onto function) f from V1 to V2 with the property
that a and b are adjacent in G1 if and only if f(a) and f(b) are adjacent in G 2,
for all a and b in V1.
Such a function f is called an isomorphism.

Inother words, G1 and G2 are isomorphic if their vertices can be ordered in


such a way that the adjacency matrices MG1 and MG2 are identical.
Isomorphism of Graphs
Example I: Are the following two graphs isomorphic?
a a

b e e
b
c d c d

Solution: Yes, they are isomorphic, because they can be arranged to look
identical. You can see this if in the right graph you move vertex b to the left
of the edge {a, c}. Then the isomorphism f from the left to the right graph is:
f(a) = e, f(b) = a, f(c) = b, f(d) = c, f(e) = d.
Isomorphism of Graphs
Example II: How about these two graphs?

a a
b
e e
b
c c
d d

Solution: No, they are not isomorphic, because they differ in the degrees of
their vertices. Vertex d in right graph is of degree one, but there is no such
vertex in the left graph.
Connectivity
Definition:

An undirected graph is called connected if there is a path between every pair
of distinct vertices in the graph.

For example, any two computers in a network can communicate if and only if
the graph of this network is connected.

Note: A graph consisting of only one vertex is always connected, because it


does not contain any pair of distinct vertices.
Connectivity
Example: Are the following graphs are connected?
a b a
b
e e
d
d c
c
Yes. No.

b a
a
b
d e
e
c
d f
c
Yes. No.
Weighted graphs
 Weighted graphs are useful in a number of branches of mathematics.

 Givena path (or circuit) in a weighted graph, the length of the path is the sum of the
weights of each of its edges.

 Noticethat for any path, the path obtained by reversing the order of the edges has the
same length as the original path. We shall therefore not distinguish between the two
Euler Paths, Circuits, Eulerian graph
and Traversability

Definition: Euler Paths, Circuits, Eulerian graph and Traversability.

A path that uses every edge of a graph once and only once is called an Euler
path.

An Euler circuit is an Euler path that begins and ends at the same vertex.

A graph that has an Euler path (or circuit) is said to be traversable.


Example:
Find some paths in the graph to the right. Try finding an Euler path.

Solution :
Path ACEBhas length 3.
Path ACEBDA is an Euler path of length 5. It is also an Euler circuit
Hamilton Paths and Circuits
 In
Eulerien graphs we considered the problem of finding paths or circuits that use
each edge of a graph once.

 Now we will investigate a similar problem: Given a graph , can we find a path that
meets each vertex once (and only once)?

 Such a path is called a Hamiltonian path (also called traceable path) is a path that
visits each vertex exactly once.
A Hamiltonian cycle (also called Hamiltonian circuit, vertex tour or graph cycle) is
a cycle that visits each vertex exactly once (except for the starting vertex, which is
visited once at the start and once again at the end).
 A graph that contains a Hamiltonian cycle is called a Hamiltonian graph.
 Any Hamiltonian cycle can be converted to a Hamiltonian path by removing one of
its edges, but a Hamiltonian path can be extended to Hamiltonian cycle only if its
endpoints are adjacent.
Finding Hamiltonian Circuits
 Example: Find a Hamilton path in each graph.

 Solution:

a) In figure (a), the path ABCFDGE (in red) is a Hamilton path. If we return to
vertex A, then ABCFDGEA is a Hamilton circuit.
b) No Hamilton path exists.
Shortest Path Problem
We can assign weights to the edges of graphs, for example to represent the
distance between cities in a railway network:

Toronto

650

700 Boston
Chicago
200
600

New York
Shortest Path Problem
Such weighted graphs can also be used to model computer networks with
response times or costs as weights.

One of the most interesting questions that we can investigate with such
graphs is:
What is the shortest path between two vertices in the graph, that is, the path

with the minimal sum of weights along the way?

Thiscorresponds to the shortest train connection or the fastest connection in


a computer network.
The Traveling Salesman Problem
Thetraveling salesman problem is one of the classical problems in
computer science.

A traveling salesman wants to visit a number of cities and then return to his
starting point. Of course he wants to save time and energy, so he wants to
determine the shortest path for his trip.

We can represent the cities and the distances between them by a weighted,
complete, undirected graph.

The problem then is to find the circuit of minimum total weight that visits
each vertex exactly one.
The Traveling Salesman Problem
Example: What path would the traveling salesman take to visit the following
cities?
Toronto

650 550
700
Boston
Chicago 700
200
600
New York
Solution:The shortest path is Boston, New York, Chicago, Toronto, Boston
(2,000 miles).
Trees

You might also like