Chapter 5 - Elementary Graph Theory
Chapter 5 - Elementary Graph Theory
Chapter 5 - Elementary Graph Theory
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 ,
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.
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.
Remark:
Graphs where the end points of an edge are not ordered are said to be
undirected graphs.
Graph Terminology (continued)
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:
Definition:
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)
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 610 = 60. According to the
Handshaking Theorem, it follows that 2e = 60, so there are 30 edges.
Graph Terminology (continued)
Proof:
Let and be the set of vertices of even and odd degrees, respectively (Thus
= , and = V).
Then by Handshaking theorem
2|E| = = +
vV2 deg(v) must be even.
Since deg(v) if odd for all , || must be even.
Graph Terminology (continued)
Definition:
Definition:
In a graph with directed edges, the in-degree of a vertex v, denoted by deg-
Theorem:
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).
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?
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 nn 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
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 nm zero-one matrix with 1 as its (i, j)th entry when edge e j is
incident with vi, and 0 otherwise.
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.
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.
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
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.
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
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