Lecture-2
Lecture-2
Graph Theory
Lecture 2
Fundamentals of Graphs
1/11/2023
• A graph with finite numbers of vertices and edges is called a
Finite graph otherwise Infinite graph.
• No. of vertices in a finite graph is called order of the graph.
• No. of edges in a finite a graph is called size of the graph.
• A graph of order n and size m is called a (n, m) graph.
• A graph which contains neither self-loop nor parallel edges is
called a Simple graph. The number of simple graphs possible
with ‘n’ vertices = 2n(n-1)/2. (nC2 = n(n – 1)/2)
Simple Graph
1/11/2023
• The maximum number of simple graphs with n=3
vertices. 2nC2 = 2n(n-1)/2 = 23(3-1)/2 = 23 = 8
Fundamentals of Graphs (Contd.)
1/11/2023
• A graph which contains parallel edges but no self-loop is
called a Multiple graph (Multigraph).
• A graph which contains parallel edges and self-loop is called
a General graph.
• A graph having no edges is called a Null Graph.
•A graph with only one vertex is called a Trivial Graph.
Null Graph
Multiple Graph General Graph
Trivial
Graph
Fundamentals of Graphs (Contd.)
1/11/2023
• In many situations, the names assigned to vertices are
insignificant. In such situations, we do not assign any names
to the vertices. Such a graph is called unlabelled graphs.
• If the names are assigned to the vertices of a graph the graph
is called labeled graph
• Adjacent edges
Two non-parallel edges are said to be adjacent edges if they
are incident on a common vertex (i.e., if they have a vertex in
common).
• Adjacent vertices
Two non-parallel vertices are said to be adjacent vertices (or
neighbors) if there is an edge joining them.
Fundamentals of Graphs (Contd.)
1/11/2023
• Degree of a vertex
If v is a vertex of a graph, then the number of edges incident on v
(i.e., the number of edges that join v to other vertices in the graph)
with self-loops counted twice, is called the degree of the vertex v. It
is denoted by deg(v) or d(v).
• A vertex is said to be odd or even according as d(v) is odd or even.
• Two adjacent edges are said to be in series if their common vertex
is of degree two.
• Wheel graph
Fundamentals of Graphs (Contd.)
1/11/2023
• The graph (slide no. 7) contains 9 vertices of which
one is at the center and the remaining 8 are on the
circumference. The degree of the vertex at the center
is 8 and the degree of vertices on the circumference
are 3 each. This graph is called Wheel graph of order
9 denoted by W9.
• Ingeneral, a wheel graph of order n is denoted by Wn.
In this graph, one vertex lies at the center of a circle
(wheel) and n-1 vertices lie on the circumference; the
degree of the vertex at the center is n-1, the degree of
the remaining vertices are 3 each and the number of
edges is 2(n-1).
Fundamentals of Graphs (Contd.)
1/11/2023
• Isolated vertex
A vertex in a graph, which is not an end vertex of any edge is
called an isolated vertex (Zero Degree)
• Pendant vertex
A vertex of degree 1 is called a pendent vertex. An edge incident
on a pendant vertex is called a pendant edge.
• Regular graph
A graph in which all the vertices are of the same degree is called a
regular graph.
• The degree of a graph is denoted by δ(G). The maximum element
in the degree sequence of a graph G is usually denoted by Δ(G).
It is called maximum degree of the graph.
Fundamentals of Graphs (Contd.)
1/11/2023
• For the graphs given below δ(G)=2, Δ(G)=3.
v2
v1
v1 v3
v2 v4
v3 v4
1/11/2023
• Complete graph
1/11/2023
Example.
(a) Show that in a complete graph of n vertices (Kn) the
degree of every vertex is (n-1) and that the total
number of edges is n(n-1)/2.
Solution:
The complete graph is a simple graph in which every
vertex is joined with every other vertex through one
edge. Therefore, if there are n vertices, there occur n-1
edges at every vertex.
Fundamentals of Graphs (Contd.)
1/11/2023
The degree of every vertex is therefore n-1. Further,
two vertices out of n vertices can be chosen in
n
c2=½n(n-1) ways and each such choice gives an edge.
The total number of edges is therefore ½n(n-1).
Another way of getting the result is the following:
Since there are n vertices each of degree n-1, the sum
of the degrees of vertices is n(n-1). This is equal to
twice the number of edges is ½n(n-1).
Fundamentals of Graphs (Contd.)
1/11/2023
(b) If Kn has m edges, then we have,
form what has been proved above,
m = ½n(n-1)
This gives n + m = n +½n(n-1)
2
2(n+m) = 2n + n – n = n(n+1).
1/11/2023
•A path in a graph G consists of an alternating
sequence of vertices and edges of the form;
v0, e1, v1, e2, v2, ………., en-1, vn-1 , еn, vn
• whereeach edge ei contains the vertices vi-1
and vi (which appear on the sides of edge ei in the
sequence).
• The path is said to be closed if v0 = vn. Otherwise, we
say the path is from v0 to vn, or between v0 and vn, or
connects v0 to vn. A simple path is a path in which
all vertices are distinct.
1/11/2023
Paths (continued)
• Example: In the simple graph here:
a, d, c, f, e is a simple path of length 4.
d, e, c, a is not a path because e is not connected to c.
b, c, f, e, b is a circuit of length 4.
a, b, e, d, a, b is a path of length 5, but it is not a simple
path.
Path, Trail, Cycle & Circuit
1/11/2023
• A path is a walk that does not include any vertex twice,
except that its first vertex might be the same as its last.
• A trail is a walk that does not pass over the same edge twice.
A trail might visit the same vertex twice, but only if it comes
and goes from a different edge each time.
1/11/2023
An undirected graph is called connected if there is a
path between every pair of vertices. An undirected
graph that is not connected is called disconnected.
The graph given below is not connected because
there is no path between vertices a and f, for
example.
Connected Components
1/11/2023
• A connected component of a graph G is a connected
subgraph of G that is not a proper subgraph of another
connected subgraph of G. A graph G that is not
connected has two or more connected components that
are disjoint and have G as their union.
• The graph H is the union of three disjoint subgraphs
H1, H2, and H3, none of which are proper subgraphs of
a larger connected subgraph of G. These three
subgraphs are the connected components of H.
Connectedness in Directed Graphs
1/11/2023
•A directed graph is strongly connected if there is
a path from a to b and a path from b to a
whenever a and b are vertices in the graph.
•A directed graph is weakly connected if there is a
path between every two vertices in the
underlying undirected graph, which is the
undirected graph obtained by ignoring the
directions of the edges of the directed graph.
1/11/2023
Connectedness in Directed Graphs
(contd.)
•G is strongly connected because there is a path
between any two vertices in the directed graph.
The graph H is not strongly connected, since there
is no directed path from a to b, but it is weakly
connected.
Undirected Graph Connectivity
1/11/2023
• An undirected graph is connected if for all pairs
of vertices u≠v, there exists a path from u to v
21
Directed Graph Connectivity
1/11/2023
• A directed graph is strongly connected if there is
a path from every vertex to every other vertex
22
The bridge of Konigsberg; traversable
1/11/2023
graph
•A graph is said to be traversable if it can be
drawn without any breaks in the curve and
without repeating any edges.
• If
there is a path which includes all vertices and
uses each edge exactly once (no edge is used
twice), will be called a traversable trail.
1/11/2023
Konigsberg bridge
1/11/2023
1/11/2023
Eulerian circuit vs Hamiltonian
circuit
•A Hamiltonian circuit in a graph G, named
after the nineteenth-century Irish
mathematician William Hamilton (1805-1865), is
a closed path that visits every vertex in G exactly
once.
• Eulerian circuit traverses every edge exactly
once, but may repeat vertices, while a
Hamiltonian circuit visits each vertex exactly
once but may repeat edges.
1/11/2023
Complete, regular and bipartite
graphs
•A graph G is said to be complete if every vertex in
G is connected to every other vertex in G.
•A graph G is regular of degree k or k-regular if
every vertex has degree k.
•A graph G is said to be bipartite if its vertices V can
be partitioned into two subsets M and N such that
each edge of G connects a vertex of M to a vertex of
N.
• Bya complete bipartite graph, we mean that each
vertex of M is connected to each vertex of N.
1/11/2023
Examples
1/11/2023
1/11/2023
Degrees of digraph
• Theoutdegree of a vertex v of G, written
outdeg(v), is the number of arcs beginning at v,
and the indegree of v, written indeg(v), is the
number of arcs ending at v. each arc begins and
ends at a vertex.
• Theorem: The sum of the outdegrees of the
vertices of a digraph G equals to the sum of the
indegrees of the vertices, which equals the
number of edges in G.
1/11/2023
Adjacency matrix of digraph
No. of 1’s in A is X Y Z W
equal to no. of X
edges, row total Y
and col. gives the Z
indegree and
W
outdegree, resp.
1/11/2023
Connectivity of digraphs
• There are three types of connectivity in a directed graph G:
• (i) G is strongly connected or strong if, for any pair of vertices
u and v in G, there is a path from u to v; and a path from v to
u, that is, each is reachable from the other.
• (ii) G is unilaterally connected or unilateral if, for any pair of
vertices u and v in G, there is a path from u to v or a path
from v to u, that is, one of them is reachable from the other.
• (iii) G is weakly connected or weak if there is a undirected
path between any pair of vertices u and v in G.
1/11/2023
Digraphs and relations
• The relation R is reflexive if every node has a
loop.
• The relations R is symmetric if arcs are
bidirectional.
• The relation R is transitive if for any sequence of
consecutive arcs, there is a single arc from the
first to the last node.
1/11/2023
Digraphs and relations
Sets, Binary Relations and
1/11/2023
Graphs
1/11/2023
Sets, Binary Relations and Graphs
• Suppose the binary relations <, ≡, , ≈, and ~ are defined on the
set S = {1,2,3, 4} as follows:
x < y means x is less than y;
x ≡ y means x is congruent to y (mod 2) and x ≠ y;
x ~ y means x = y± 1;
x ≈ y means y =x2 .
Then the corresponding subsets of S x S are
< (S) = {(l , 2), (l , 3), (1, 4), (2, 3), (2, 4), (3, 4)};
≡ (S) = {(l , 3), (3, I) , (2, 4), (4, 2)};
~ (S) = {(I , 2), (2, I), (2, 3), (3, 2), (3, 4), (4, 3)};
≈ (S) = {(l, I), (2, 4)}.
1/11/2023
Relation-Examples
• Consider, for example, a set A = {p, q, r, s}.
• The relation R1 = {(p, p), (p, r), (q, q), (r, r), (r, s), (s, s)} in A is
reflexive, since every element in A is R 1-related to itself.
• The relation R2 = {(p, p), (p, r), (q, r), (q, s), (r, s)} is not
reflexive in A since q, r, s ∈ A but (q, q) ∉ R2, (r, r) ∉ R2 and
(s, s) ∉ R2.
• The relation R1 = {(p, q), (p, r), (r, p), (r, r), (q, p), (r, s), (s, r)} in
A is symmetric, since every element in A is R 1-related to itself.
• The relation R2 = {(q, r), (p, q), (s, r), (q, s), (r, s)} is not
symmetric in A since q, r, s ∈ A but (r, q) ∉ R2, (q, p) ∉ R2 and
(s, q) ∉ R2.
1/11/2023
Relation-Examples
• Consider, for example, a set A = {p, q, r, s}.
• The relation R1 = {(p, p), (p, q), (p, r), (p, s), (q, q), (q, s), (r, r),
(s, s)} in A is transitive, since every element in A is R 1-related
to itself.
• The relation R2 = {(p, q), (p, r), (p, s), (q, p), (q, r), (q, s), (r, p),
(r, q), (r, s), (s, p), (s, q), (s, r)} is not transitive since (p, q) ∈ R2
and (q, p) ∈ R2 but (p, p) ∉ R2.