After having gone over this chapter, you will be
able to:

Define graph and represent the same in different

Define and construct the special types of graph

Find the degree of a vertex and the degree
sequence of a graph
Determine whether graphs are isomorphic or not

Determine the adjacency and incidence matrix of
a graph

Define path

Define complete graphs

Define Digraphs

Define and apply the operations on graphs
Graph Theory
the study of graphs which are mathematical
structures used to model pairwise relations
between objects.

Basic Concepts of a Graph

A graph is a symbolic representation of a network and of its connectivity.
It implies an abstraction of the reality so it can be simplified as a set of linked

 A graph G is a finite nonempty set of vertex v connected by
(possible empty) edges e. Thus G = (V, E).

Vertex (Node) Edge (Link)
A node v is a terminal An edge e is a link
point or an intersection between two nodes.
point of a graph.
Order of a graph
Size of the graph
The number of
The number of edges
vertices in a graph.|V
in a graph.|E (G) |
(G) |
V(G)={v1,v2, v3, v4, v5}
Size = 5
E(G)= {(v1, v2), (v2, v5), (v5, v5), (v5, v4),(v5, v4)}
G(V,E) = {{v1,=v52, v3, v4, v5}, {(v1, v2), (v2, v5), (v5, v5), (v5, v4), (v5,



a An edge joining a vertex to itself is [The degree of v1 is 1 so it is a
called a loop. [e3 is a loop ] pendant vertex]
b An isolated vertex is a vertex e A graph with only one vertex is
whose degree is 0. called trivial.
[The degree of v3 is 0 so it is an f A simple graph has no parallel
isolated vertex] edges or loops.
c Edges that have the same end g A multi-graph is graph with no
vertices are parallel. loops but with multiple edges.

[e4 and e5 are parallel ] h A pseudograph is a graph in

d A pendant vertex is a vertex which both loops and multiple

whose degree is 1. edges are permitted.

simple graph


Undirected graph
The edges of a graph are assumed
to be unordered pairs of nodes.
In an undirected graph, we write
edges using curly braces to
denote unordered pairs.

Directed graph (Digraph)
In a directed graph, the two
directions are counted as being
distinct directed edges. In directed
graph, we write edges using
parentheses to denote ordered pairs.

 The neighborhood of a vertex v in a graph G is the set of vertices adjacent
to v. The neighborhood is denoted N(v).
 The degree of a vertex is the total number of vertices adjacent to the
vertex. The degree of a vertex v is denoted deg(v)=|N(v)|.

deg(v1) = 2
N(v1) = {2,5}
deg(v2) = 3
deg(v3) = 2
deg(v4)= 3
deg(v5)= 3
deg(v6)= 1
N(v2) = {1,3,5}
N(v3) = {2,4}
N(v4) = {3,5,6}
N(v5) = {4,2,1}
N(v6) = {4} Size = 7
Order = 6

Two vertices are called adjacent if they share a common edge, in which
case the common edge is said to join the two vertices.


Nodes 4 and 6 are adjacent (as well as many other pairs of nodes)
Nodes 1 and 3 are not adjacent (as well as many other pairs of nodes)

Special Types of Graphs

1. Complete Graph
 Denoted by Kn.
 Simple graph that contains one edge between each pair of vertices.
Has n(n-1)/2 edges.

2 Cycle Graph
 Denoted by Cn.
 It is a graph that consists of a single cycle and each vertices are
connected in
a closed chain.

a The number of vertices is equal to the number of edges.
b The degree of every vertex is 2.
c A cycle with an even number of vertices is called an even cycle and
cycle with an odd number of vertices is called an odd cycle.
d Cn ≥ 3


3 Star Graph
 Known as N-star. Denoted by Sn
 It is a tree star on n nodes with 1 node having a vertex degree n-1 and the
n- 1 having vertex degree 1.

4 Wheel Graph
 Denoted by Wn
 It is a graph with n vertices formed by connecting a single vertex to all
vertices of n-1 cycle.
 Combination of star graph and cycle graph.


Regular Graph

 A Regular graph is a graph where each vertex has the same number of
neighbors i.e; every vertex has the same degree or valence.
 A Regular graph with vertices of degree r is called a r-regular.
R-regular graph

The degree of each vertex is r, and it is regular if there exist a non-negative
integer r.

Example: order 6







Degree Sequence is a sequence of deg(V1),deg(V2)…deg(Vp)of non-
integers with deg(V1)≥deg(V2)≥…≥deg(Vp).Where deg(Vp) is the
minimum degree of G, deg(V1) is the maximum degree of G.

Degree sequence= 4,3,3,3,2,1

Supposed given is a non-increasing sequence of p ≥ 1, non-negative
integers. If this sequence contains terms exceeding p-1, then it cannot be
If the sequence does not contain term exceeding p-1, then the following
steps can be applied recursively to determine whether the given sequence is

Step 1:
If all integers in the sequence are
Step 2:
Reorder the numbers in the
then the sequence is graphical.
current sequence so that
If the sequence contains a negative
now form a non-increasing
integer then the sequence is
not graphical.

Step 3:
Delete the first number n from
the sequence and subtract 1
from the next n numbers in
the sequence. Return to step 1.

S: 4, 4, 3, 3, 2, 2
S1:4, 3, 3, 2, 2
S1:3, 2, 2, 1, 2 Thus, it is graphical.
S1:3, 2, 2, 1
S2:1, 1, 1, 1
S3:0, 1
S3:1, 1, 0
S4:0, 0

Graphs G1 ={V1, E1} and G2 ={V2, E2}are isomorphic if

1. There is a bijection (one-to-one correspondence) f from V1 to V2 and
2. There is a bijection g from E1 to E2 that maps each edge (v, u) to (f (v),
f( u))

The function is called isomorphism.


V1  1 V4 2 (V1, V2) = (1,3) (V2, V3) = (3,4)
V2 3 V5  5 (V1, V5) = (1,5) (V4, V5) = (2,5)
V3 4 (V1, V4) = (1,2)


The adjacency matrix of a graph is the n × n matrix A = [ aij ] where
the nondigonal
entryaij is the number of edges joining i and vertex j and the diagonal
entry aij is twice the loops at vertex i.
The incidence matrix of G is a p × q matrix B = [ bij ], where p and q
are the numbers of vertices and edges respectively, such that [ bij ]=1
if the vertex viand edge xj are incident and 0 otherwise.

V1 V2 V3 V4 V5 V6 V7

V1 0 0 0 0 0 0 0
V2 0 0 0 3 1 0 0
V3 0 0 0 0 0 0 0
V4 0 3 0 0 0 0 1
V5 0 1 0 0 0 1 1
V6 0 0 0 0 1 1 0
V7 0 0 0 1 1 0 0


Node 7 passing through node

matrix e e e e e e
1 2 3 4 5 6

Node 3
V 1 1 1 0 0 0 passing
V 1 0 0 1 1 0
V 0 1 0 1 0 1
V 0 0 1 0 1 1

Node 4 passing through

A path in a graph is a sequence of vertices such that from each of its
vertices there is an edge to the next vertex in the sequence.

A path may be infinite, but a finite path always has a first vertex, called its
start vertex, and a last vertex, called its end vertex. Both of them are called
terminal vertices of the path. The other vertices in the path are internal

Simple path is a path with no repeated vertices.

Hamiltonian path is a simple path that includes every vertex of the graph.

Induced path is a path such that no graph edges connect two nonconsecutive path vertices.

P=(v2, e7, v5, e6, v4, e3, v3 )

is path from node 2 to node 3

A cycle is a path such that the start vertex and end vertex are the same.
The choice of the start vertex in a cycle is arbitrary.

Simple cycle is a cycle with no repeated vertices or edges aside from
the necessary repetition of the start and end vertex.
Hamiltonian cycle is a simple cycle that includes every vertex of the
Fundamental cycle is a cycle with just one edge removed in the
corresponding spanning tree of the original graph.
P = ( v2, e7, v5, e6, v4, e3, v3, e2, v2 )from the figure above is an example of

A walk is a sequence v0,e1,v1, ...,vk of graph vertices vi and graph
edges ei such that for 1≤i≤k, the edge ei has endpoints vi-1 and vi.
The length of a walk is its number of edges. A u,v-walk is a walk with first
vertex u and last vertex v, where u and v are known as the endpoints.
Every u,v-walk contains a u,v-graph path.

A walk in which no edge is repeated is a trail, such that the edges- e1,
e2, . . .ek of a
walk w are distinct. In this case, the length of w is just E(w).
A closed walk in a graph is a walk between a vertex and itself
A closed walk in which no edges repeated is a cicuit.



Walk of length 4 between u Closed walk:
and w.
1 ueyfvgyhw circuit
2 uavfydvbw yeuavgy cycle
3 uavgydxcw
4 ueygvfyhw
5 uavfydxcw yeuavbwcxdy
Operations On Graphs

The complement of the simple graph G = (V, E) is the simple graph Ǵ = (V,
É), where the edges in É are exactly the edges not in G.

The union of a
simple graph G1∪ G2= (V1∪ V2, E1∪ E2)
The intersection of a simple graph is G1∩ G2= (V1∩ V2, E1∩ E2)

Example for the graphs

After having gone over this chapter, you will be able to:

Define connected graphs

Define and represent vertex connectivity

Define and represent edge connectivity
Define and represent block

Determine the vertex connectivity and edge connectivity of a

Connectivity is one of the basic concepts of graph
it asks for the minimum number of elements (nodes or
edges) which need to be removed to disconnect the
node from each other. It is closely related to the theory of
network flow problems. The connectivity of a graph is an
important measure of its robustness as a network.

Connected Graphs
A graph is called connected if given any two
vertices Pi,Pj there is a path from Pi to Pj .

G1 G2
G1 is called connected because every pair of distinct vertices in the graph is
connected, otherwise G2 is not a connected graph.


Cut-Vertex Cut-edge
Cut-edge (or bridge) is a
A cut-vertex is a single
single edge whose removal
vertex whose removal
disconnects a graph.
disconnects a graph.

Edge-cut Vertex-cut
Edge-cut in a graph is a set Vertex-cut in a graph G is
of edges such that G-D has a vertex set S such that
G-S is disconnected
more components than G.

Vertex Conectivity
The connectivity (or vertex connectivity) K(G) of a connected graph G is the
minimum number of vertices whose removal disconnects G.
When we remove a vertex, we must also remove the edges incident to it

When K(G) ≥ k, the graph is said to be k-connected

A graph G is k-connected (or k-vertex connected) if G is connected and
K(G)≥ k. If G has non-adjacent vertices then G is k-connected if every vertex-
cut has at least k-vertices

The graph has a vertex connectivity of 1.

Deleted Deleted
vertex: 0 vertices: 1

Edge Conectivity
The edge-connectivity λ(G) of a connected graph G is the smallest number
of edges whose removal disconnects G. When λ(G) ≥ k, the graph G is said
to be k-edge-connected.


The graph has an edge connectivity of 1.


The above graph can be split up to two components by removing one of the
edges bc and bd.
A block is a connected graph which has no vertex-cut.
A block of a graph is a maximal subgraph with no cut vertices.


Block graphs are exactly the graphs for which, for every four vertices u, v,
x, and y, the largest two of the three distances d(u,v) + d(x,y),
d(u,x) + d(v,y), and d(u,y) + d(v,x) are always equal.

They also have a forbidden graph characterization as the graphs that do
not have the diamond graph or a cycle of four or more vertices as an
induced subgraph; that is, they are the diamond-free chordal graphs. They
are also the Ptolemaic graphs (chordal distance-hereditary graphs) in
which every two nodes at distance two from each other are connected by a
unique shortest path, and the chordal graphs in which every two maximal
cliques have at most one vertex in common.

A graph G is a block graph if and only if the intersection of every two
connected subsets of vertices of G is empty or connected. Therefore, the
connected subsets of vertices in a connected block graph form a convex
geometry, a property that is not true of any graphs that are not block
graphs. Because of this property, in a connected block graph, every set of
vertices has a unique minimal connected superset, its closure in the
convex geometry. The connected block graphs are exactly the graphs in
which there is a unique induced path connecting every pair of vertices.

The Connector problem
The connector problem is to build a network connecting n nodes (towns,
computers, chips in a computer) which it is desirable to decrease the cost of
construction of the links to the minimum.

In graph theoretical terms we wish to find an optimal spanning subgraph
of a weighted graph. Such an optimal subgraph is clearly a spanning tree,
for, otherwise a deletion of any nonbridge will reduce the total weight of the
CHAPTER circuit
and Graph

After having gone over this chapter, you will be able

Define and represent Eulerian graphs

Define and represent Hamiltonian graphs

Define weighted graphs
Define and represent graph coloring

Eulerian Graph

A closed walk in a graph G containing all “the edges” of G is called an Euler
line in G.
A graph containing an Euler line is called an Euler graph. Eulerian circuit
every edge in a graph exactly once, but may repeat vertices,

Consider the road map given:

A tourist wants to explore all the routes between numbers of cities. Can a
tour be found which traverses each route only once? Particularly, find a tour
which starts at A, goes along each road exactly once, and ends back at A.

A B C D E F B G C E G F A Examples of such tour are:

The tourist travels along each road (edges) just once but may visit a
particular city (vertex) several times.

Therefore, the given road map is an example of Eulerian graph.

Eulerian Digraphs
A digraph is Eulerian if there is a closed path covering all the edges. A
necessary condition is: the graph is connected and even (each vertex
has an equal number of ``in'' and ``out'' edges). This is in fact

Hamiltonian Graph
Hamiltonian circuit in a graph is a closed path that visits “every vertex” in
the graph exactly once but may repeat edges.. (Such a closed loop must be
a cycle.) A Hamiltonian circuit ends up at the vertex from where it started.

Hamiltonian graphs are named after the nineteenth-century Irish
mathematician Sir
William Rowan Hamilton (1805-1865). This type of problem is often referred
to as the
traveling salesman or postman problem.

If a graph has a Hamiltonian circuit, then the graph is called a Hamiltonian


Hamiltonian circuit:


Hamiltonian circuits:

A weighted graph associates a label (weight) with every edge in the graph. Weights are
usually real numbers. Such weights might represent, for example, costs, lengths
or capacities, etc. depending on the problem at hand.


Travelling Salesman
The travelling salesman problem (TSP) asks the following question: Given a list of cities and
the distances between each pair of cities, what is the shortest possible route that visits each city
exactly once and returns to the origin city? It is an NP-hard(Non-deterministic Polynomial-time
hard) problem in combinatorial optimization, important in operations research and theoretical
computer science.

TSP is a special case of the travelling purchaser problem.

In the theory of computational complexity, the decision version of the TSP (where, given a
length L, the task is to decide whether the graph has any tour shorter than L) belongs to the class
of NP-complete problems. Thus, it is possible that the worst-case running time for any algorithm
for the TSP increases super polynomial (or perhaps exponentially) with the

number of cities.

Graph coloring and Chromatic
Graph coloring is a special case of graph labeling; it is an assignment of
labels traditionally called "colors" to elements of a graph subject to certain

It is a way of coloring the vertices of a graph such that no two
adjacent vertices share the same color; this is called a vertex
coloring. Similarly, an edge coloring assigns a color to each edge
so that no two adjacent edges share the same color, and a face
coloring of a planar graph assigns a color to each face or region so
The chromatic number of a graph is the least number of colors required to
do a
coloring of a graph.


A proper vertex coloring
of the Petersen graph with
3 colors, the minimum
number possible

Vertex Coloring

A k-coloring of G is an assignment of k colors to the vertices of G in such a
way that adjacent vertices are assigned different colors. If G has a k-coloring,
then G is said to be
k-coloring, then G is said to be k-colorable.


Not a permissible
coloring since one of
the edge has color
blue to both nodes.
Edge Coloring
A k-edge-coloring of G is an assignment of k colors to the edges of G in such
a way that any two edges meeting at a common vertex are assigned
different colors,. If G has a k-edge coloring, then G is said to be k-edge


Not a permissible coloring
since two of the edge
colored blue meet at a
common node.


After having gone over this chapter, you will be able

Define and represent trees.

Determine the shortest path of a graph.

Determine the minimum spanning tree
Basic properties of a Tree


A tree is an undirected graph in
which any two
vertices are connected by exactly
one simple
path. In other words,
any connected graph without
simple cycles is a tree.

A tree is an undirected simple graph G that satisfies any of the following
equivalent conditions:

G is connected and has no cycles.

G has no cycles, and a simple cycle is formed if any edge is added
to G.

G is connected, but is not connected if any single edge is removed
from G.

G is connected and the 3-vertex complete graph is not
a minor of G.

Any two vertices in G can be connected by a unique simple path.
parent of a vertex is the vertex connected to
Terminologi it on the path to the root; every vertex except
es the root has a unique parent.
child of a vertex v is a vertex of which v is
leaf is a vertex of degree 1.
the parent.
internal vertex is a vertex of degree at least
2. labeled tree is a tree in which each vertex is
given a unique label. The vertices of a
irreducible tree is a tree in which there is
labeled tree on n vertices are typically given
no vertex of degree 2.
the labels 1, 2, …, n.
forest is an undirected graph, all of
whose connected components are trees; recursive tree is a labeled rooted tree where
hedge sometimes refers to an ordered the vertex labels respect the tree order (i.e.,
sequence of trees. if u < v for two
vertices u and v, then the label of u is
polytree or oriented tree is a directed graph
smaller than the label of v).
with at most one undirected path between
any two vertices. n-ary tree is a rooted tree for which each
directed tree is a directed graph which vertex has at most n children. 2-ary trees are
would be a tree if the directions on the edges sometimes called binary trees, while 3-ary
were ignored trees are sometimes called ternary trees.
rooted tree it is a rooted tree if one vertex
has been designated the root, in which case terminal vertex of a tree is a
the edges have a natural vertex of degree 1. In a rooted
orientation, towards or away from the root. tree, the leaves
normal tree it is a normal tree if the ends of are all terminal vertices;
every edge in G are comparable in this tree- additionally,
order whenever those ends are vertices of the root, if not a leaf itself, is a
the tree. Designated root is called a free terminal vertex if it has precisely
tree. one child

Search Trees and spanning
Search Tree

Also called as Binary Search Tree (BST)

It is a tree where each node has a left and right child. Either child, or both children, may be

Assuming k represents the value of a given node, and then a binary search tree also has the
following property: all children to the left of the node have values smaller than k, and all children
to the right of the node have values larger than k. The top of a tree is known as the root, and the
exposed nodes at the bottom are known as leaves.

The root is node 20 and
the leaves are nodes 4,
16, 37, and 43. The
height of a tree is the
length of the longest
path from root to leaf.
For this example the
Insertion in BST
If we need to insert an element x, we first search for x. If x is present, there
is nothing to do. If x is not present, then our search procedure ends in a null
link. It is at this position of this null link that x will be included.
If we repeatedly insert a sorted sequence of values to form a BST, we obtain a completely
skewed BST. The height of such a tree is n - 1 if the tree has n nodes. Thus, the worst case
complexity of searching or inserting an element into a BST having n nodes is O(n).

Deletion in BST
Let x be a value to be deleted from the BST and let X denote the node containing the value x.
Deletion of an element in a BST again uses the BST property in a critical way. When we delete
the node X containing x, it would create a "void" that should be filled by a suitable existing node
of the BST. There are two possible candidate nodes that can fill this void, in a way that the BST
property is not violated: (1). Node containing highest valued element among all descendants of
left child of X. (2). Node containing the lowest valued element among all the descendants of the
right child of X. In case (1), the selected node will necessarily have a null right link which can be
conveniently used in patching up the tree. In case (2), the selected node will necessarily have a
null left link which can be used in patching up the tree.


Delete 10 (delete a node w/ no left
Delete 4 (delete
Spanning Tree
A spanning tree for a graph G is a sub-graph of G which is a tree that
includes every vertex of G.

A spanning tree of a graph G is a “maximal” tree contained in the
graph G.
When you have a spanning tree T for a graph G, you cannot add
another edge of G to


Delete 27 (delete a node w/ no right

It has 16 spanning

Shortest Path
The shortest path is the problem of finding a path between two vertices (or nodes) in
a graph such that the sum of the weights of its constituent edges is minimized.

This is analogous to the problem of finding the shortest path between two intersections on a road
map: the graph's vertices correspond to intersections and the edges correspond to road segments,
each weighted by the length of its road segment.

The shortest path problem can be defined for graphs whether undirected, directed, or mixed. It is
defined here for undirected graphs; for directed graphs the definition of path requires that
consecutive vertices be connected by an appropriate directed edge.

(A, C, E, D, F) is the
Shortest path between
vertices A and F in the
weighted directed
Minimal Spanning Tree

Given a connected, undirected graph, a spanning tree of that graph is
a subgraph that is a tree and connects all the vertices together. A single
graph can have many different spanning trees. We can also assign
a weight to each edge, which is a number representing how unfavorable it is,
and use this to assign a weight to a spanning tree by computing the sum of
the weights of the edges in that spanning tree.

Minimum Spanning Tree
A minimum spanning tree in a network is a spanning tree of the underlying graph which has the
smallest sum of weights amongst all spanning trees.

ADijkstra’s Algorithm
graph search algorithm that solves the single-source shortest path problem for a graph with
non-negative edge path costs, producing a shortest path tree. This algorithm is often used
in routing and as a subroutine in other graph algorithms.
For a given source vertex in the graph, the algorithm finds the path with lowest cost (i.e. the
shortest path) between that vertex and every other vertex.



After having gone over this chapter, you will be able to:
Define cuts

Define flows

Determine the maximum and minimum cut of a
Cuts and
A cut C = (S,T) is a partition of V of a graph G = (V,E).

s-t cut C = (S,T ) of a network N = (V,E) is a cut of N such that s ϵ S and t ϵ T, where
sand t are the source and the sink of N respectively.
The cut-set of a cut C = (S,T ) is the set {(u,v)∈E∣u∈T}.

The size of a cut C = (S,T ) is the number of edges in the cut-set. If the edges are
weighted, the value (or weight) of the cut is the sum of the weights.

Minimum Cut
For a graph, a cut is minimum if the size of the cut is not larger than the size of any other cut.

Maximum Cut
For a graph, a maximum cut is a cut whose size is at least the size of any other cut. The problem
of finding a maximum cut in a graph is known as the max-cut problem. The problem can be
stated simply as follows.


Flow network (also known as a transportation network) is a directed graph where each edge
has a capacity and each edge receives a flow. The amount of flow on an edge cannot exceed the
capacity of the edge.

Often in Operations Research, a directed graph is called a network, the vertices are called nodes
and the edges are called arcs.
A flow must satisfy the restriction that the amount of flow into a node equals the amount of flow
out of it, except when it is a source, which has more outgoing flow, or sink, which has more
incoming flow. A network can be used to model traffic in a road system, fluids in pipes, currents
in an electrical circuit, or anything similar in which something travels through a network of

G(V,E) is a finite directed graph in which every edge (u,v) ∈E has a non-negative, real-valued
capacity c(u,v). If (u,v)∉E, we assume that c(u,v)=0. We distinguish two vertices: a source and
a sink t. A flow in a flow network is a real function f: V×V⇾ R with the following three
properties for all nodes u and v:

f(u,v)≤c(u,v). The flow along an edge cannot exceed its capacity.

f(u,v)= -f(u,v). The net flow from u to v must be the opposite of the net flow
Skew symmetry:
from v to u.

∑ f (u , w )=0 , unless u=s or u=t. The net flow to a node is zero, except
w ∈V
for the source, which "produces" flow, and the sink, which "consumes" flow.

Notice that f(u,v) is the net flow from uto v. If the graph represents a physical network, and if
there is a real flow of, for example, 4 units from u to v, and a real flow of 3 units
from v to u, we have f(u,v)=1 and f(u,v)= -1.

The residual capacity of an edge is cf(u,v)=c(u,v)-f(u,v) . This defines a residual network
denoted Gf (V,Ef) , giving the amount of available capacity. See that there can be a path from u
to v in the residual network, even though there is no path from u to v in the original network.
Since flows in opposite directions cancel out, decreasing the flow from v to u is the same as
increasing the flow from u to v.

An augmenting path is a path (u1,u2…uk in the residual network, where u1=s, uk=t, and
cf(ui,ui+1). A network is at maximum flow if and only if there is no augmenting path in the
residual network.

Should one need to model a network with more than one source, a super source is introduced
to the graph. This consists of a vertex connected to each of the sources with edges of infinite
capacity, so as to act as a global source. A similar construct for sinks is called a super sink.