0% found this document useful (0 votes)
16 views46 pages

‎⁨خالد graph theory⁩

Graph theory

Uploaded by

mauriziobelal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views46 pages

‎⁨خالد graph theory⁩

Graph theory

Uploaded by

mauriziobelal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Chapter IV

Graph Theory
Index

4.1 DEGREE OF A VERTEX


4.2 ISOLATED AND PENDENT VERTICES
4.3 TYPES OF GRAPHS
4.3.1 Properties of a Complete Graph:
4.3.2 Regular graph
4.3.3 Cycles
4.4 THE HANDSHAKING THEOREM
4.5 Other Representations of Graphs
4.6 ISOMORPHIC
4.7 DIRECTED GRAPHS AND MULTIGRAPHS
4.8 BASIC TERMINOLOGIES
4.8.1 Loop
4.8.2 Multigraph
4.8.3 Pseudo graph
4.8.4 Simple graph
4.8.5 Finite and Infinite graphs
4.9 More about Directed Graph
4.10 Representation of Direct Graph
4.11 OPERATIONS OF GRAPHS
4.11.1 Union
4.11.2 Intersection
4.11.3 Sum of two graphs
4.11.4 Ring sum
4.11.5 Product of graphs
4.11.6 Composition
4.12 Connected and Disconnected Graphs
4.12.1 Connected Graph
4.12.2 Disconnected Graph
4.13 Practical Applications
Graph Theory Goals
1. Understand Fundamental Concepts:
o Gain a comprehensive understanding of the basic definitions and
terminology in graph theory, including vertices, edges, loops, and
various types of graphs such as undirected, directed, multigraphs,
pseudographs, finite, infinite, null, and complete graphs.
2. Analyze Graph Structures:
o Develop the ability to analyze and categorize different types of
graphs based on their properties. This includes understanding
connected vs. disconnected graphs, regular graphs, and various
graph invariants like degree, diameter, and girth.
3. Graph Operations:
o Learn to perform and understand the results of various graph
operations including union, intersection, ring sum, and graph
products (Cartesian, tensor, strong, lexicographic). Develop skills
to compute and interpret these operations in practical scenarios.
4. Graph Algorithms:
o Implement and analyze fundamental graph algorithms such as
graph traversal (BFS and DFS), shortest path algorithms
(Dijkstra’s, Bellman-Ford), and network flow algorithms (Ford-
Fulkerson). Understand their applications in solving real-world
problems.
5. Graph Isomorphism and Subgraphs:
o Gain proficiency in identifying graph isomorphisms and working
with subgraphs. This includes understanding the concepts of graph
homeomorphisms and the role of subgraphs in the context of graph
theory.
6. Graph Theory in Computer Science:
o Explore the applications of graph theory in various domains of
computer science, including data structures, databases, computer
networks, artificial intelligence, and software engineering.
Understand how graph theory concepts are applied in these fields.
7. Problem-Solving Skills:
o Develop strong problem-solving skills through the analysis and
solution of graph theory problems. This includes hands-on practice
with problems related to graph traversal, connectivity, graph
coloring, and planarity.
8. Theoretical and Practical Knowledge:
o Balance theoretical knowledge with practical application. Gain
experience in using graph theory tools and software for modeling
and solving problems, as well as writing and presenting proofs of
graph theory theorems and properties.
9. Research and Development:
o Encourage engagement in research and development activities by
exploring advanced topics in graph theory. Foster a mindset of
innovation and critical thinking in applying graph theory to new
and emerging technologies.
10.Collaborative Learning:
o Promote collaborative learning through group projects and
discussions. Encourage students to work together on complex
graph theory problems and share their insights and solutions with
peers.
By the end of this course, students will have a strong foundation in graph theory
and its applications, equipping them with the skills needed to tackle complex
problems in computer science and related fields.

INTRODUCTION
Graph theory, a branch of mathematics, focuses on the study of graphs, which are
structures made up of vertices (or nodes) and edges (or lines) connecting them.
This field has grown to be integral to numerous modern disciplines, including
computer science, biology, and social sciences, due to its capacity to model and
solve complex problems involving relationships and connections.
The inception of graph theory is often traced back to 1736 with the work of Swiss
mathematician Leonhard Euler. Euler's paper on the Seven Bridges of Königsberg
problem laid the groundwork for the field. The problem involved finding a walk
through the city of Königsberg that would cross each of its seven bridges exactly
once. Euler proved that no such walk existed, introducing the concept of what is
now known as the Eulerian path. In the 19th century, the development of graph
theory continued with contributions from mathematicians such as Gustav
Kirchhoff, who applied graph theoretical concepts to electrical circuits. Later, in
the early 20th century, the works of Dénes Kőnig and the introduction of the term
"graph" by James Joseph Sylvester further solidified the foundation of graph
theory as a distinct mathematical discipline.
Graph theory's importance lies in its versatility and ability to abstract and model
various types of relationships and structures. It provides a framework for
analyzing complex networks and systems, enabling the understanding and
optimization of these systems. The theoretical concepts and methods developed
within graph theory have wide-reaching implications and applications.
The primary goals of graph theory include modeling and representation, analysis
and problem solving, optimization, prediction and simulation. These goals are
achieved by providing a mathematical framework to model complex systems
involving relationships between objects, developing algorithms and techniques to
analyze graphs and solve graph-related problems, finding optimal solutions for
problems such as shortest paths, maximum flows, and minimal spanning trees,
and using graph models to predict behaviors and outcomes in various fields, such
as biology and social networks.
Graph theory finds applications in numerous fields. In computer science,
algorithms for searching, sorting, and optimizing are often based on graph theory,
and data structures like trees and graphs are fundamental in areas like network
design, database management, and artificial intelligence. In biology, graphs
model biological networks such as food webs, neural networks, and genetic
regulatory networks, helping to understand complex interactions within
biological systems. In social sciences, social networks are analyzed using graph
theory to understand relationships and influences among individuals,
communities, and organizations. In transportation and logistics, graph theory
optimizes routes, schedules, and networks, improving efficiency and reducing
costs. In telecommunications, network design, routing, and communication
protocols rely on graph theoretical concepts to ensure robust and efficient
communication systems. In chemistry, molecular structures are modeled as
graphs, aiding in understanding chemical properties and reactions.
Graph theory's origins in the 18th century have led to a robust and versatile
mathematical framework that underpins many modern technologies and scientific
fields. Its ability to model complex relationships and systems makes it an
invaluable tool for solving a wide range of problems, from optimizing network
flows to understanding social dynamics. As research and technology advance, the
applications of graph theory continue to expand, solidifying its importance in
both theoretical and practical domains.

What is the Graph?

A graph G consists of a set of objects V = {v1, v2, v3,…} called vertices (also
called points or nodes) and other set E = {e1, e2, e3,…} whose elements are called
edges (also called lines or arcs).
The set V(G) is called the vertex set of G and E(G) is the edge set.
Usually, the graph is denoted as G = (V, E)
Let G be a graph and {u, v} an edge of G. Since {u, v} is 2-element set, we may
write {v, u} instead of {u, v}. It is often more convenient to represent this edge
by uv or vu.
If e = uv is an edge of a graph G, then we say that u and v are adjacent in G and
that e joins u and v. (We may also say that each that of u and v is adjacent to or
with the other).

Example 1:
A graph G is defined by the sets
V(G) = {u, v, w, x, y, z} and E(G) = {uv, uw, wx, xy, xz}.

Now we have the following graph (Fig.1) by considering these sets.

Figure 1.
Every graph has a diagram associated with it. The vertex u and an edge e are
incident with each other as are v and e. If two distinct edges say e and f are
incident with a common vertex, then they are adjacent edges.
A graph with p-vertices and q-edges is called a (p, q) graph.
The (1, 0) graph is called trivial graph.
In the following Figure 2 the vertices a and b are adjacent, but a and c are not.
The edges x and y are adjacent, but x and z are not.
Although the edges x and z intersect in the diagram, their intersection is not a
vertex of the graph.

Figure 2.

(1) Let V = {1, 2, 3, 4} and E = {{1, 2}, {1, 3}, {3, 2}. {4, 4}}.
Then G(V, E) is a graph.
(2) Let V = {1, 2, 3, 4} and E = {{1, 5}, {2, 3}}.
Then G(V, E) is not a graph, as 5 is not in V.

(3)

Figure 3.
Figure 3. A graph with 5-vertices and 8-edges is called a (5, 8) graph.
4.1 DEGREE OF A VERTEX
The number of edges incident on a vertex vi with self-loops counted twice (is called the degree of a
vertex vi and is denoted by deg G(vi) or deg vi or d(vi).
The degrees of vertices in the graph G and H are shown in Figure 4(a) and 4(b).

Fig. 4(a) Fig. 4(b)

In G as shown in Figure 4(a), degG (v2) = 2 = degG (v4) = degG (v1), degG (v3) = 3 and degG (v5) = 1
and In H as shown in Figure 4(b), degH (v2) = 5, degH (v4) = 3, degH (v3) = 5, degH (v1) = 4 and degH
(v5) = 1.
The degree of a vertex is some times also referred to as its valency.

4.2 ISOLATED AND PENDENT VERTICES

Isolated vertex
A vertex having no incident edge is called an isolated vertex.
In other words, isolated vertices are those with zero degree.

Pendent or end vertex


A vertex of degree one, is called a pendent vertex or an end vertex.
In the above Figure, v5 is a pendent vertex.

4.3 TYPES OF GRAPHS


Different types of graph are demonstrated here.
Null graph
A graph which contains only isolated node, is called a null graph.
i.e., A null graph, also known as an empty graph, is a special type of graph
that has no edges. Formally, a null graph G=(V,E) is defined as a graph where:
• V is a set of vertices.
• E is an empty set, meaning there are no edges in the graph.

Figure 5
Note that each vertex of a null graph is isolated (Fig. 5).
A complete graph is a type of simple graph where every pair of distinct
vertices is connected by a unique edge. Formally, a complete graph Kn with n
vertices is defined as follows:
• Vertices: n vertices, denoted as V={v1,v2,…,vn}.
• Edges: Every possible pair of distinct vertices is connected by an edge,
denoted as E={{vi,vj }|1 ≤ i < j ≤ n}.

4.3.1 Properties of a Complete Graph:


1. Number of Vertices: n vertices.

2. Number of Edges edges.


3. Degree of Each Vertex: Each vertex has a degree of n-1, as it is
connected to every other vertex in the graph.

Characteristics of a Complete Graph:


• Connected: A complete graph is fully connected, meaning there is a path
between any pair of vertices.
• Simple Structure: It is one of the simplest and most symmetrical types
of graphs.
Example 2:
The following are some figures demonstrating connected graphs

Figure 6.
4.3.2 Regular graph
A graph in which all vertices are of equal degree, is called a regular graph.
If the degree of each vertex is r, then the graph is called a regular graph of
degree r.
• Vertices: {A, B, C, D}
• Edges: {(A, B), (B, C), (C, D), (D, A)}
• Description: This is a simple regular graph where each vertex has a
degree of 2.
• Visualization:

Figure 7
4.3.3 Cycles

The cycle Cn, n ≥ 3, consists of n vertices v1, v2, ......, vn and edges {v1, v2}, {v2,
v3}, ......, {vn-1 , vn},
and {vn, v1}.
The cyles c3, c4, c5 and c6 are shown in following Figure 8

Figure 8.

4.4 THE HANDSHAKING THEOREM


In a graph, the sum of the degrees of the vertices equals twice the number of
edges.
If G = (v, E) be an undirected graph with e edges then

Corollary: In a non-directed graph, the total number of odd degree vertices is


even.

4.5 Other Representations of Graphs

It is often necessary to analyze graphs and perform a variety of procedures and


algorithms upon them. When a graph has many vertices and edges, it may be
essential to use a computer to perform these algorithms. Thus, it is necessary to
communicate to the computer the vertices and edges of a graph. One way to do
so is to represent a graph by means of matrices, which are easily manipulated
with a computer.

Suppose we have a graph G with n vertices labeled V1, V2, ..., Vn. Such a graph is
called a labeled graph. To represent the labeled graph G by a matrix, we form an
n x n matrix in which the i, j entry is 1 if there is an edge between the vertices Vi
and Vj and 0 if there is not. This matrix is called the adjacency matrix of G (with
respect to the labeling) and is denoted by A(G).

Example 3:
Figure 9 contains two graphs and their adjacency matrices.
For (a) the 1, 2 entry is 1 because there is an edge between vertices V 1 and V2,
and the 3, 4 entry is 0 because there is no edge between V3 and V4. For (b) we see
that the 1, 2 and 1, 3 entries are 1 because of the edges between V 1 and V2 and
between V1and V3.

0 1 0 0 0 1 1
1 0 1 1
A (G1 ) = [0 1 0 0] 𝐴 (𝐺2 ) = [1 0 1]
0 1 0 0 1 1 0

(a) (b)
Figure 9

Note that in A (G1) the sum of the entries in row 1 is 1, which is the degree of
V1, and likewise the sum of the entries in row 2 is the degree of V2. This
illustrates a more general result.

Theorem 4.1 The sum of the entries in row i of the adjacency matrix of a graph
is the degree of the vertex Vi in the graph.
Proof. We recall that each 1 in row i corresponds to an edge on the vertex V i.
Thus, the number of 1s in row i is the number of edges on Vi, which is the degree
of Vi.
Matrices are not the only way to represent graphs in a computer. Although an
adjacency matrix is easy to construct, this form of representation requires n . n =
n2 units of storage for a graph with n vertices and so can be quite inefficient if
the matrix contains lots of zeros. This means that if an algorithm to be performed
on the graph requires a lot of searching of vertices and adjacent vertices, then the
matrix representation can require a lot of unnecessary time. A better
representation for such a graph is an adjacency list.
The basic idea of an adjacency list is to list each vertex followed by the vertices
adjacent to it. This provides the basic information about a graph: the vertices and
the edges. To form the adjacency list, we begin by labeling the vertices of the
graph. Then we list the vertices in a vertical column, and after each one we write
down the adjacent vertices. Thus, we see that the 1s in a row of an adjacency
matrix tell what vertices are listed in the corresponding row of an adjacency list.

Example 4:
For the graph in Figure 9 there are 6 labeled vertices, and we list them in a
vertical column as in (b). Beside vertex V1 we list the adjacent vertices, which
are V2 and V3. Then proceeding to the next vertex V2, we list the vertices
adjacent to it, V1 and V4. This process is continued until we get the adjacency
list in (b).

V1: V2, V3
V2: V1, V4
V3: V1, V4
V4: V2, V3, V5
V5: V4, V6
V6: V5

(a) (b)
Figure 9
4.6 ISOMORPHIC

In 1953 the CIA managed to photograph a KGB document listing their agents in
a large third-world city, showing their past operations, duties, and contacts among
themselves. Unfortunately, it listed the agents by the code designations D through
L. The document shows that agent D 's contacts were F and L; E 's were J and K;
F's were D, J, and L; G's were I and L; H's were I and J; I's were G, H, and K; J's
were E, F, and H; K's were E and I; and L's were D, F, and G. Drawing an edge
between agents if they are contacts produces the graph A shown in Figure 10.
Unfortunately, the information in the document was of little use without knowing
the identities of the agents.

Figure 10
An inquiry to the CIA office in this city revealed that the suspected agents there
were Telyanin, Rostov, Lavrushka, Kuragin, Ippolit, Willarski, Dolokhov,
Balashev, and Kutuzov. By examining records of past meetings observed among
them, the CIA created the contact graph C in Figure 11 by joining two individuals
with an edge if they were known to have met together.

Figure 11
If these nine persons are the agents described in the KGB document, then it must
be possible to match the code designations D through L with the names in Figure
11 so that the edges in A correspond exactly to the edges in C.
In general, we say that a graph G1 is isomorphic to a graph G2 when there is a
one-to-one correspondence f between the vertices of G1 and G2 such that the
vertices U and W are adjacent in G1, if and only if the vertices f(U) and f (W) are
adjacent in G2.
The function f is called an isomorphism of G1 with G2. Because the relation "is
isomorphic to" is a symmetric relation on any set of graphs
we usually just say that the graphs G1 and G2 are isomorphic. Thus, isomorphic
graphs are essentially the same in the sense that, except for notation, they have
the same vertices and the same pairs of vertices are adjacent.

In other words,
Let G1 = (v1, E1) and G2 = (v2, E2) be two graphs. A function f : v1 → v1 is called a
graphs isomorphism if
(i) f is one-to-one and onto.
(ii) for all a, b  v1, {a, b} E1 if and only if {f(a), f(b)}  E2 when such
a function exists, G1 and G2 are called isomorphic graphs and is written
as G1  G2.
In other words, two graphs G1 and G2 are said to be isomorphic to each other if
there is a one- to-one correspondence between their vertices and between edges
such that incidence relationship is preserve. Written as G1  G2 or G1 = G2.
The necessary conditions for two graphs to be isomorphic are
1. Both must have the same number of vertices
2. Both must have the same number of edges
3. Both must have equal number of vertices with the
same degree.
4. They must have the same degree sequence and same
cycle vector (c1,… , cn), where ci is the number of
cycles of length i.
An examination of the graphs in Figure 12 shows that they are isomorphic by
using the correspondence indicated in the figure.

A ……... a B……... b C ……... c


D ……... d E ……... e F ……... f
G ……... g

(a) (b)
Figure 12

Isomorphic pair of graphs

The graphs in Figures 10 and 12 are not isomorphic, however, because they
have different numbers of vertices. In Figure 13, vertex C in (a) is adjacent to
the vertices A, B, D, and E. Therefore, under any isomorphism of (a) with (b),
the image of C would also need to have 4 adjacent vertices s. Since there are no
vertices of degree 4 in (b), we see that (a) and (b) are not isomorphic.
This last observation illustrates the following theorem.

Figure 13

Theorem 4.2 Let f be an isomorphism of graphs G1 and G2. For any vertex V in
G1, the degrees of V and f (V) are equal.
Proof. Suppose f is an isomorphism of G1 with G2 and that V is a vertex of degree
k in Gl. Then there is exactly k vertices U1, U2, …, Uk in G1 that are adjacent
to V. Since f is an isomorphism, f (Ul), f (U2), ..., f (Uk) are adjacent to f (V). Since
there are no other vertices in G1 adjacent to V, there are no other
vertices in G2 adjacent to f (V) Thus f (V) has degree k in G2.
As a consequence of this theorem, we see that the degrees of the vertices of
isomorphic graphs must be exactly the same.
A property is said to be a graph isomorphism invariant if, whenever G1and G2
are isomorphic graphs and G has this property, then so does G 2. The properties
“has n vertices,” “has e edges,” and “has a vertex of degree k” are all invariants.
Thus, one way to show two graphs are not isomorphic is to find an invariant
property possessed by only one of the graphs. This is what was done in showing
that the graphs in Figure 13 are not isomorphic.
Note that if there had been more than one isomorphism from A to C, then a
complete identification of the agents would not have been possible. For example,
consider the graphs of agents (a) and contacts (b) in Figure 14.
(a) (b)
Figure 14
Notice that in addition to the obvious isomorphism sending V, W, X, Y, and Z
into V *, W *, X *, Y *, and Z *, respectively, there is also an isomorphism that is
the same except that W maps to
X* and X to W*. Hence, in this case, it would be impossible to deduce whether
W* or X* is the identity of agent W.

Exercises

1. List the set of edges and set of vertices for each graph of the
following:

i.

ii.
iii.

iv.
2. Draw a diagram representing the graph with the set V of vertices
and the set E of edges.

i. 𝑉 = {𝐴, 𝐵, 𝐶, 𝐷}, 𝐸 = {{𝐵, 𝐶}, {𝐶, 𝐴}, {𝐵, 𝐷}

ii. 𝑉 = {𝑋, 𝑌, 𝑍, 𝑊}, 𝐸 = {{𝑋, 𝑌}, {𝑋, 𝑍}, {𝑌, 𝑍}, {𝑌, 𝑊}}

iii. 𝑉 = {𝐺, 𝐻, 𝐽}, 𝐸 = ∅

iv. 𝑉 = {𝐴, 𝑋, 𝐵, 𝑌}, 𝐸 = {{𝐴, 𝑋}, {𝑋, 𝐵}, {𝐵, 𝑌}, {𝑌, 𝐴}}

3. Construct the graph where the vertices are you, your parents, and
your grandparents with a relationship of "are the same sex."

4. Draw the graph with 𝑉 = {1, 2, … , 10} as its set of vertices and as
its set of edges.
𝐸 = {{𝑥, 𝑦}: 𝑥, 𝑦 𝑖𝑛 𝑉, 𝑥 ≠ 𝑦 𝑎𝑛𝑑 𝑥 𝑑𝑖𝑣𝑖𝑑𝑒𝑠 𝑦 𝑜𝑟 𝑦 𝑑𝑖𝑣𝑖𝑑𝑒𝑠 𝑥}

5. Draw graphs where

i. there are 4 vertices, each with degree 1.

ii. there are 4 vertices, each with degree 2.

6. How many edges does K3 have? K4? K5? Kn, in general?

7. How many vertices are there in a graph with 10 edges if each vertex
has degree 2?

8. Find the adjacency matrix and the adjacency list for each graph

i. K4
ii.

iii.

iv.

9. Construct the graph for each adjacency matrix. Label the vertices
V1, V2, V3, …

0 1 1 1
1 0 1 1
i. [1 1 0 1]
1 1 1 0

0 1 1 0 1
1 0 1 1 1
ii. 1 1 0 1 0
0 1 1 0 0
[1 1 0 0 0]
10. Construct the graph for each adjacency list
i. V1: V2, V4, V5
V2: V1, V3
V3: V2, V5
V4: V1
V5: V1, V3

ii. V1: V2, V3


V2: V1, V4
V3: V1, V4
V4: V2, V3

11. What does it mean when the adjacency matrix of a graph


contains only zeros?

12. Can each matrix be an adjacency matrix?


0 1 0 1 0
1 0 0 1 0
i. 0 0 0 0 1
1 1 0 0 1
[0 0 0 0 0]

0 1 0 0
1 0 1 1
ii. [1 1 0 1]
0 0 1 0

1 1 1
iii.[1 1 1]
1 1 1
13. Will two graphs that have the same number of vertices always be
isomorphic? Justify your answer.

14. Will two graphs that have the same number of edges always be
isomorphic? Justify your answer.

15. Will two graphs having the same number of vertices of degree k
for each nonnegative integer k always be isomorphic? Justify your
answer.

16. Are the following pairs of graphs isomorphic? Justify your answer.

i.
ii.

iii.

v.
vi.

vii.

17. Draw all the nonisomorphic graphs with 3 vertices.

18. Draw all the nonisomorphic graphs with 4 vertices.

19. Draw all the nonisomorphic graphs with 5 vertices of degrees 1,


2, 2, 2, and 3.

20. Draw all the nonisomorphic graphs with 6 vertices of degrees 1,


1, 1, 2, 2, and 3.
21. Suppose a graph has n vertices, each with degree at least 1. What
is the smallest number of edges the graph can have? Justify your
answer.

22. Suppose a graph has n vertices, each with degree at least 2. What
is the smallest number of edges it can have? Justify your answer.

23. A graph has m edges with m > 2. What is the smallest number of
vertices it can have? Justify your answer.
4.7 DIRECTED GRAPHS AND MULTIGRAPHS

In previous sections, an edge was used to represent a two-way or symmetric


relationship between two vertices. However, there are situations where
relationships hold in only one direction. In these cases, the use of a line segment
is not descriptive enough, and a directed line segment is needed.
Example 5
In many urban downtown areas, the city streets are one-way. In such a case, it is
necessary to use a directed line segment to indicate the legal flow of traffic. In
Figure 15 major downtown locations are represented by dots, and two dots are
connected by an arrow when it is possible to go from the first location to the
second by means of a one-way street. For example, the arrow from BANK to
HOTEL denotes that there is a one-way street from BANK to HOTEL.

Figure 15

Example 6:
Although in a communication network there are routes where information can
flow either way, there are also some where the flow is in just one direction. Within
a microcomputer system, data usually can travel in either direction between CPU
and the Memory, but only from the Input to the Memory and from the Memory
to the Output. This type of situation can be represented by the diagram in Figure
16, where the arrows indicate how the data can flow.
Figure 16
4.7.1 Directed and undirected graphs
A directed graph or digraph G consists of a set V of vertices and a set E of edges
such that e ∈ E is associated with an ordered pair of vertices.
In other words, if each edge of the graph G has a direction then the graph is
called directed graph (diagraph)
In the following figure of directed graph, each edge e = (u, v) is represented by
an arrow or directed curve from initial point u of e to the terminal point v.
Figure 17 is an example of a directed graph

Fig. 17((a) Directed graph

Suppose e = (u, v) is a directed edge in a digraph, then


(i) u is called the initial vertex of e and v is the terminal vertex of e
(ii) e is said to be incident from u and to be incident to v.
u is adjacent to v, and v is adjacent from u.
Example 7
V={ 1, 2, 3, 4}
E={(1, 2), (2, 3), (3, 1), (4, 2)}
Description: This graph has directed edges, meaning the connections have a
direction. Vertex 1 points to vertex 2, vertex 2 points to vertex 3, vertex 3 points
back to vertex 1, and vertex 4 points to vertex 2.

4.7.2 Undirected graph is a type of graph in which the edges have no direction.
Each edge in an undirected graph simply connects two vertices, and the
connection is bidirectional. Formally, an undirected graph G is defined as a pair
G = (V , E) where:
• V is a set of vertices (or nodes).
• E is a set of edges, where each edge is an unordered pair of vertices {u,v}
with u,v ∈ V.
In an undirected graph, if there is an edge between vertices u and v, it is the
same as having an edge between v and u. See Figure 17.(b)

Fig. 17((b) Undirected graph

Example 8.
Simple Undirected Graph:
o Vertices: {A, B, C, D}
o Edges: {(A, B), (A, C), (B, D), (C, D)}
o Description: This graph has four vertices connected as follows: A
is connected to B and C, B is connected to D, and C is connected
to D
o Visualization:

Figure 18
4.8 BASIC TERMINOLOGIES

4.8.1 Loop: (also known as a self-loop) is an edge that connects a vertex to itself.
Formally, if G=(V , E) is a graph where V is a set of vertices and E is a set of
edges, then an edge e∈E is called a loop if e connects a vertex v∈V to itself,
denoted as e={v,v}
Loops are special types of edges and can exist in both directed and undirected
graphs. In an undirected graph, a loop is simply an edge with the same vertex on
both ends. In a directed graph, a loop is an edge that starts and ends at the same
vertex.

Example 9.
1. Undirected Graph with a Loop:
o Vertices: {A, B, C}
o Edges: {(A, A), (A, B), (B, C)}
o Description: In this graph, there is a loop at vertex A, an edge from
A to B, and an edge from B to C.
o Visualization:
Figure 19
2. Directed Graph with a Loop:
o Vertices: {1, 2, 3}
o Edges: {(1, 1), (1, 2), (2, 3)}
o Description: In this directed graph, there is a loop at vertex 1, a
directed edge from 1 to 2, and a directed edge from 2 to 3.
o Visualization:

Figure 20

4.8.2 Multigraph
A multigraph (or parallel edges)is a type of graph in which multiple edges
(also called parallel edges) between the same pair of vertices are allowed.
Unlike simple graphs, where there can be at most one edge between any two
vertices, a multigraph can have more than one edge connecting the same two
vertices. Formally, a multigraph G=(V,E) consists of:
• A set V of vertices.
• A multiset E of edges, where each edge is an unordered or ordered pair of
vertices, allowing for multiple instances of the same pai
Two edges (vi, vj) and (vf , vr) are parallel edges if vi = vr and vj, vf.
Fig. 21(a) Fig. 21(b)
In Figure 21.(a), there are two parallel edges associated with v2 and v3.
In Figure 21.(b), there are two parallel edges joining nodes v1 and v2 and v2
and v3.

4.8.3 Pseudo graph


A graph in which loops and multiple edges are allowed, is called a pseudo
graph.

Fig. 22.(a) Fig. 22(b)

4.8.4 Simple graph


A graph which has neither loops nor multiple edges. i.e., where each edge
connects two distinct vertices and no two edges connect the same pair of vertices
is called a simple graph. Figure 17 represents simple undirected and directed
graph because the graphs do not contain loops and the edges are all distinct.

4.8.5 Finite and Infinite graphs


Finite graphs are graphs that have a finite number of vertices and edges. In other
words, the set of vertices V and the set of edges E are both finite sets. Finite
graphs are commonly used to model discrete structures and finite systems where
the number of elements (vertices and edges) is countable and bounded.
Otherwise, it is an infinite graph.
Example 10
Vertices:V= {1, 2, 3}
Edges: E={(1, 1), (1, 2), (1, 2), (2, 3), (3, 3)}
Description: This pseudograph has a loop at vertex 1, multiple edges between
vertices 1 and 2, an edge from 2 to 3, and a loop at vertex 3.
Visualization:

Figure 23

4.9 More about Directed Graph: Directed graph is a finite nonempty set V and
a set E of ordered pairs of distinct elements of V. The elements of V are called
vertices and the elements of E are called directed edges.
Figure 16 depicts a directed graph with vertices C, I, M, and 0 and directed edges
(C, M), (M, C), (I, M), and (M, 0). As was true for graphs, a directed graph can
be described either by the use of sets or by the use of a diagram, where arrows
between the vertices in V describe which ordered pairs of vertices are being
included.
If there is a directed edge e = (A, B), it is said that e is a directed edge from A
to B. In Figure 16 there is a directed edge from
M to 0 but no directed edge from 0 to M. Similarly, there is a directed edge from
M to C and one from C to M.
In a directed graph, the number of directed edges from vertex A is called the
outdegree of A and is denoted as outdeg(A). Similarly, the number of directed
edges to vertex A is called the indegree of A and is denoted by indeg(A). In
Figure 16 we see that
outdeg(M) = 2, indeg(C) = l, and outdeg(O) = 0.
Theorem 4.3 In a directed graph the following three numbers are equal: the
sum of the indegrees of the vertices, the sum of the outdegrees of the vertices,
and the number of directed edges.

4.10 Representation of Direct Graph

As for graphs, a directed graph can be represented by a matrix. Suppose we have


a directed graph D with n vertices labeled Vl, V2, ..., Vn. Such a directed graph is
called labeled. Form an 𝑛 𝑥 𝑛 matrix in which the i, j entry is 1 if there is a
directed edge from the vertex Vi to the vertex Vj and 0 if there is not. This matrix
is called the adjacency matrix and is denoted by A(D).

Example 11:
Figure 24 contains a directed graph and its adjacency matrix.
The 1, 4 entry is 0 because there is no directed edge from V 1 to V4, but the 4, 1
entry is 1 because there is a directed edge from V4 to V1. Row 3 contains all zeros
because there are no directed edges from the vertex V3. Since there are no directed
edges to the vertex V4, column 4 also contains all zeros.

0 1 0 0
1 0 1 0
A(D) = [0 0 0 0]
1 0 1 0

Figure 24
Directed graphs can also be represented by adjacency lists. To form an
adjacency list, we begin by labeling the vertices of the directed graph. Then we
list the vertices in a column, and after each vertex we list the vertices to which
there is a directed edge from the given vertex.
Example 12:
For the directed graph in Figure 24, the adjacency list is given below. Since V2 is
the only vertex to which there is a directed edge from V1, V2 is the only vertex
listed after V1. Similarly, because the only directed edges from V4 are to V1 and
V3, these are the two vertices listed after V4.
V1:V2
V2: V1, V3
V3: (none)
V4:V1, V3

Exercises

1. list the vertices and directed edges for the directed graph.
i.

ii.
iii.

2. Draw a diagram representing the


directed graph with the set of
vertices V and the set E of directed edges.
i. 𝑉 = {𝑋, 𝑌, 𝑍, 𝑊, 𝑈 }
𝐸 = {(𝑋, 𝑌), (𝑍, 𝑈), (𝑌, 𝑋), (𝑈, 𝑍), (𝑊, 𝑋), (𝑍, 𝑋)}
ii. 𝑉 = {𝐴, 𝐵, 𝐶, 𝐷},
𝐸=∅
iii. 𝑉 = {𝐴, 𝐵, 𝐶)}
𝐸 = {(𝐴, 𝐵), (𝐵, 𝐶), (𝐶, 𝐴), (𝐵, 𝐴), (𝐶, 𝐵)}
iv. 𝑉 = {𝐴, 𝐵, 𝐶, 𝐷}
𝐸 = {(𝐴, 𝐷), (𝐷, 𝐵), (𝐷, 𝐴)}
3. Construct the labeled directed graph for the adjacency matrix
0 1 0 1
1 0 1 0
i. [0 0 0 0]
0 1 1 0
0 1 1 1
1 0 1 1
ii. [1 1 0 1]
1 1 0 0

0 1 0 1 1
1 0 0 0 0
iii. 1 0 0 1 1
1 1 0 0 0
[1 0 0 1 0]

0 0 0
iv. [0 0 0]
0 0 0
4. List for the directed graph the other vertices on the directed edges to A, the
other vertices on the directed edges from A, the indegree of A, and the
outdegree of A.

i.

ii.

iii.
4.11 OPERATIONS OF GRAPHS

4.11.1 Union
Given two graphs G1 and G2, their union will be a graph such that
V(G1  G2) = V(G1)  V(G2)
and E(G1  G2) = E(G1)  E(G2)

Figure 25

4.11.2 Intersection
Given two graphs G1 and G2 with at least one vertex in common then their
intersection will be a graph such that
V(G1  G2) = V(G1)  V(G2)
and E(G1  G2) = E(G1)  E(G2)

Figure 26
4.11.3 Sum of two graphs

If the graphs G1 and G2 such that V(G1)  V(G2) = 𝜙, then the sum G1 + G2 is
defined as the graph whose vertex set is V(G1) + V(G2) and the edge set is consisting
those edges, which are in G1 and in G2 and the edges obtained, by joining each vertex
of G1 to each vertex of G2.
For example,

Figure 27

4.11.4 Ring sum


Let G1 (V1, E1) and G2 (V2, E2) be two graphs. Then the ring sum of G1 and G2,
denoted by
G1 ⊕ G2 is defined as the graph G such that:
(i) V(G) = V(G1) ∪ V(G2)
(ii) E(G) = E(G1) ∪ E(G2) – E(G1) ∩ E(G2)
i.e., the edges that either in G1 or G2 but not in both. The ring sum of two graphs G1
and G2 is shown below.
Figure 28

4.11.5 Product of graphs


To define the product G1 × G2 of two graphs consider any two points u = (u1, u2)
and v = (v1, v2) in V = V1 × V2. Then u and v are adjacent in G1 × G2 whenever
[u1 = v1 and u2 adj. v2] or [u2 = v1 and u1 adj. v1]
For example,

The product of two graphs.

To define the product G1 × G2 of two graphs consider any two points u = (u1, u2) and
v = (v1, v2) in V = V1 × V2. Then u and v are adjacent in G1 × G2
whenever [u1 = v1 and u2 adj. v2] or [u2 = v1 and u1 adj. v1]
For example,

Fig. 29 The Product of two graphs


4.11.6 Composition
The composition G = G1[G2] also has V = V1 × V2 as its point set, and u = (u1, u2) is
adjacent with v = (v1, v2) whenever (u1 adj. v1) or (u1 = v1 and u2 adj. v1)
For the graphs G1 and G2 of Figure. (a), both compositions G1[G2] and G2[G1] are
shown in Figure (30).

Fig. (30). Two compositions of graphs

Fig. 30 Composition of two graphs


4.11.7 Complement
The complement 𝐺′ of G is defined as a simple graph with the same vertex set as G
and where two vertices u and v adjacent only when they are not adjacent in G.
For example,

Figure 31
4.12 Connected and Disconnected Graphs
4.12.1 Connected Graph
A connected graph is a type of graph where there is a path between every pair of
vertices. In other words, a graph G = (V, E) is connected if, for every pair of vertices
u, v ∈ V, there exists a sequence of edges that connects u to v. A graph can be
connected if it consists of a single component.
Characteristics of Connected Graphs:
- Path Existence: There is at least one path between any two vertices.
- Single Component: The graph is a single connected component.
- No Isolated Vertices: There are no vertices that are not connected to any other
vertex.

Example 13
1. Simple Connected Graph:
Vertices: {A, B, C, D}
Edges: {(A, B), (A, C), (B, D), (C, D)}
Description: There is a path between every pair of vertices.
visualization:

Figure 32
2. Complete Graph:
Vertices: {1, 2, 3}
Edges: {(1, 2), (1, 3), (2, 3)}
Description: Every pair of vertices is directly connected by an edge.
visualization:
Figure 34
4.12.2 Disconnected Graph
A disconnected graph is a type of graph in which at least two vertices are not
connected by a path. In other words, there exists at least one pair of vertices u, v ∈
V such that no sequence of edges connects u to v. Disconnected graphs consist of
two or more components.
Characteristics of Disconnected Graphs:
- Multiple Components: The graph is made up of two or more connected
components.
- Isolated Vertices: There can be vertices that are not connected to any other vertex
or are part of separate subgraphs.
- No Path Between Some Pairs of Vertices: There exist pairs of vertices with no
connecting path.
Example 14:
1. Simple Disconnected Graph:
Vertices: {A, B, C, D}
Edges: {(A, B), (C, D)}
Description: There are two separate components: one containing vertices A and B,
and the other containing vertices C and D.
Visualization:

Figure 35
2. Graph with Isolated Vertex:
Vertices: {1, 2, 3, 4}
Edges: {(1, 2), (2, 3)}
Description: Vertex 4 is isolated and not connected to any other vertices.
Visualization:

Figure 36
4.13 Practical Applications
Connected Graphs:
- Computer Networks: Ensuring that each computer (vertex) can communicate
with any other computer.
- Transportation Systems: Ensuring that there is a route between any two locations.
- Social Networks: Ensuring that every user is somehow connected to every other
user.
Disconnected Graphs:
- Cluster Analysis: Identifying separate clusters or groups within a dataset.
- Fault Tolerance: Modeling and understanding the effects of failures in network
components.
- Decomposition: Analyzing components of complex systems by breaking them
down into simpler, disconnected subgraphs.

For example, the graphs in Figure 30(a, b, c, d, e) are connected whereas the
graphs in Figure 31(a, b, c) are disconnected

Examples of Connected graphs


Examples of disconnected graphs

Exercises

1. Given two graphs G1=(V1,E1) and G2=(V2,E2), find the union graph
G=(V,E)
V1={1,2,3},E1={(1,2),(2,3)}
V2={3,4,5},E2={(3,4),(4,5)}
2. Given two graphs G1=(V1,E1) and G2=(V2,E2), find the intersection
graph G=(V,E)
V1={A,B,C},E1={(A,B),(B,C)}
V2={B,C,D},E2={(B,C),(C,D)}
3. Given two graphs G1=(V1,E1) and G2=(V2,E2),
find the ring sum graph G=(V,E)
V1={1,2,3},E1={(1,2),(2,3)}
V2={1,2,3},E2={(1,3),(2,3)}
4. Find the Cartesian product of the following graphs G1=(V1,E1) and
G2=(V2,E2),
V1={A,B},E1={(A,B)}
V2={1,2},E2={(1,2)}
5. Find the complement of the following graph G=(V,E)
V={1,2,3},E={(1,2),(2,3)}
6. Determine if the following graphs G1=(V1,E1) and G2=(V2,E2), are
isomorphic.
V1={A,B,C},E1={(A,B),(B,C),(C,A)}
V2={1,2,3},E2={(1,2),(2,3),(3,1)}
7. Find the union of the following directed graphs D1=(V1,E1) and
D2=(V2,E2)
V1={1,2},E1={(1,2)}
V2={2,3},E2={(2,3)}
8. Find the intersection of the following directed graphs G1=(V1,E1) and
G2=(V2,E2),
V1={A,B},E1={(A,B)}
V2={B,C},E2={(B,C)}
9. Find the complement of the following directed graph D=(V,E)
V={1,2,3},E={(1,2),(2,3)}
10.Find the Cartesian product of the following directed graphs
D1=(V1,E1) and D2=(V2,E2)
V1={A,B},E1={(A,B)}
V2={1,2},E2={(1,2)}
11.Identify if the following graph is disconnected.
V={1,2,3,4},E={(1,2),(3,4)}

You might also like