Lecture-3
Lecture-3
Graph Theory
Lecture 3
1/11/2023
• In order to classify the various computer models of graphs, the
three following principles can be distinguished:
The natural way to represent a non-simple graph is the
Adjacency matrix. This is a square matrix of order n, M = (mij),
where mij is the number of edges having xi & xj endvertices in
G. This implementation of graph takes memory space of order
n2, where n is the number of vertices. So any algorithm over
graphs modeled after adjacency matrix has O(n2) time
complexity.
1/11/2023
(Contd…)
A second principle for implementing a graph is to give for each
vertex its “neighborhood”. The most classic way to implement
this principle is showing the neighbors as adjacency list. List
of neighbors N(x) for each vertex x. The memory space need for
this type of implementation is of order n + m, n vertices and m
edges. Such model is coherent with linear processing.
If in an algorithm the entry to the graph is done by the edges
and not directly by the vertices, as in the above models, a third
implementation principle consists of giving a list of edges with,
for each of them, its endvertices. Such a list may be linked,
which makes it possible to modify the graph being processed.
The memory space necessary for this type of model is minimal
since it is of the order of the number of edges m of the graph
(the isolated vertices do not appear in this implementation,
since they are not endvertices of an edge).
Representation of Graphs inside a Machine
1/11/2023
(Contd…)
Weighted Graph
1/11/2023
• Weighted Graphs are often considered, that is graphs with
values, integer or real, positive or not, associated with the edges.
• Formally, we have a graph G = (X, Y ) with a mapping v : E → R.
• When a weighted graph is a simple graph, which is often the
case, its computer model is generally a matrix, such as the
adjacency matrix, but with entries being the values of the edges
under consideration.
• The matrix M = (v(xixj)), where 1 ≤ i, j ≤ n, with mapping v
extended by stating: v(xixj) = ∞ when i ≠ j and xixj ∉ E, v(xixj) = 0
when i = j. This matrix is symmetric.
Incidence Matrix
1/11/2023
• If the edge set of undirected graph G is E(G) = {al, a2, ... , ae},
• then the incidence matrix NG of G is the v x e matrix with entries
nij, such that
7
1/11/2023
Isomorphism (Contd…)
8
A B P Q
1/11/2023
D C S R
• Observe that both graphs have four vertices and four edges.
• The one-to-one correspondence between the vertices are:
A↔P; B↔Q; D↔S and C↔R.
• The one-to-one correspondence between the edges are:
(A,B) ↔ (P,R); (A,D)↔(P,S); (B,C)↔(Q,R); (C,D)↔(S,Q).
• These represent one-to-one correspondence between the edges of
the two graphs which preserve the incidence relationship, i.e.,
the adjacent vertices and adjacent edges in the first graph
correspond to adjacent vertices and edges in the second graph.
Thus they are isomorphic. 9
1/11/2023
Graph Isomorphism-Example
is isomorphic to
14
1/11/2023
Proper subgraph
A A
B B
C C
D D
E
15
1/11/2023
• The following results are immediate consequences of the
definition of Subgraph
Every graph is a subgraph itself
Every simple graph of n vertices is a subgraph of the
complete graph Kn
If K is subgraph of H and H is subgraph of G then K is
subgraph of G
A single vertex in a graph G is a subgraph of G
A single edge in a graph G together with its end vertices
is a subgraph of G
16
Edge-disjoint and Vertex-disjoint
1/11/2023
subgraphs
• Let G be graph. Let K and H are two graphs of G. Then
K and H are said to be edge-disjoint if they do not have any
common edge
K and H are said to be vertex-disjoint if they do not have any
common edge and any common vertex.
• Notice that the edge-disjoint subgraphs may have common
vertices. Subgraphs that have no vertices in common cannot
possibly have edge in common, i.e., two vertex-disjoint
subgraphs must be edge-disjoint but the converse is not
necessarily true.
17
1/11/2023
• Example of edge-disjoint but not vertex-disjoint subgraphs
A
C A
B
B D
E` E
E
Subgraph K Subgraph H
D
Graph G
18
1/11/2023
Operations on graphs
Let G1(V1, E1) and G2(V2, E2) be two graphs. Then the
graph whose vertex set is V1V2 and the edge set
E1 E2 is called the union of G1 and G2 and it is
denoted by G1 G2
G1 G2 = (V1 V2, E1 E2)
19
1/11/2023
• Intersection of two graphs
Let G1(V1,E1) and G2(V2,E2) be two graphs. Then the
graph whose vertex set is V1∩V2 and the edge set
E1∩E2 is called the intersection of G1 and G2 denoted
by G1∩G2 is
G1∩G2 = (V1∩V2, E1∩E2), Provided V1∩V2 ≠ϕ
• Ring sum
Consider a graph whose vertex set is V1UV2 and the
edge set E1 E2, where is the symmetric difference
of E1 and E2 then G1 G2=(V1UV2, E1 E2) is called
the ring sum of G1 and G2 .
Note: Symmetric difference means
E1E2 = (E1 – E2)U(E2 – E1)=(E1UE2) –(E1∩E2)
20
• The following consequences of the above definition of union,
1/11/2023
intersection and ring sum
G1U G2 = G2U G1
G1 G2 = G2 G1
If G1 and G2 have no edge in common (edge-disjoint), then G1∩
G2 is a null graph and G1 G2 = G1U G2
If G1 and G2 have no vertex in common (vertex-disjoint), then
G1∩ G2 does not exist
Sometimes, we also write G1 + G2 for G1U G2 .
Note that G1,G2 ⊆ G1U G2 and G1∩ G2 ⊆ G1,G2.
G – U := G[V \U, E], G – F := (V, E \F ), G + F := (V, E U F ).
If U = {u} or F = {e} then we simply write G – u, G – e and G + e
for G – U, G – F and G + F , respectively.
The complement of G, denoted by G or GC, is defined as the
graph (V; V1V2\ E). In particular, G + G is a complete graph,
and G = (G + G) – E. 21
1/11/2023
V2 V2
V1 V1 V6
V3
V3
V5 V4
V4 G2
G1
V1 V2 V6
V2
V1 V6 V1 V2
V5 V4 V3
V5
V4 V3 V4 V3 G1G2
G1UG2 G1∩G2
22
Complement of Graph
1/11/2023