CHAPTER 2
GRAPH THEORY
LEARNING CONTENT:
Graph theory and graphs
Types of graphs
Undirected Graph
Directed Graph
Indegree
Outdegree
Weighted Graph
Unweighted Graph
INTENDED LEARNING OUTCOMES
At the end of the lesson, the student should be able to:
Recall and describe graph theory and graph
List, describe and identify the different types of graph
Recall and describe graph representations
List, describe and identify the different types of graph representation
HISTORY:
Texts typically trace the origin of graph theory to the Königsberg Bridge
Problem and its solution by Leonhard Euler (the book gives this solution
a date of 1736). The book describes the problem and the history behind it.
You may recall that Euler (pronounced “oiler”) was a brilliant
mathematician and perhaps the most prolific of history, remaining
productive into his 70’s or 80’s despite going blind.
GRAPH THEORY
APPLICATIONS:
On p. 229 the book mentions the application of graphs to printed circuit and
microchip design. Graphs seem an intuitively natural way to model many situations in
the Creation (connections of wires/leads, logistics/transportation problems, pipelines
between points with known capacities, family trees, organizational charts, among
many more). This suggests why graph theory has grown so dramatically in the past
century.
GRAPH THEORY
WHAT IS A GRAPH?
A graph is a pictorial representation of a set of objects where some pairs of objects are
connected by links. The interconnected objects are represented by points termed as
vertices, and the links that connect the vertices are called edges.
GRAPH THEORY
WHAT IS A GRAPH?
Formally, a graph is a pair of sets (V, E), where V is the set of vertices and E is the set
of edges, connecting the pairs of vertices. Take a look at the following graph −
Graph Example
In the above graph,
V = {a, b, c, d, e}
E = {ab, ac, bd, cd, de}
GRAPH THEORY
EXAMPLE 1:
LET V={A,B,C,D} AND E={{A,B},{A,C},{B,C},{C,D}}
A
B
C D
EXAMPLE 2:
LET V={A,B,C,D} AND E={{A,B},{A,C},{A,D},{B,C},{B,D},{C,D}}. THIS IS
CALLED THE COMPLETE GRAPH ON FOUR VERTICES, DENOTED K4.
A B
C D
EXAMPLE 3:
LET V={A,B,C,D} AND E=∅.
B
A
C D
MORE…
A point is a particular position in a one-dimensional, two-
dimensional, or three-dimensional space. For better
understanding, a point can be denoted by an alphabet. It can be
represented with a dot.
Example
MORE…
Line is a connection between two
points. It can be represented with a
solid line.
Example
MORE…
vertex is a point where multiple lines meet.
It is also called a node. Similar to points, a
vertex is also denoted by an alphabet.
Example
Here, the vertex is named with an alphabet ‘a’.
MORE…
Pendent Vertex
By using degree of a vertex,
we have a two special types of
vertices. A vertex with degree
one is called a pendent vertex. Here, in this example, vertex ‘a’ and vertex ‘b’
have a connected edge ‘ab’. So with respect
to the vertex ‘a’, there is only one edge
towards vertex ‘b’ and similarly with respect
to the vertex ‘b’, there is only one edge
towards vertex ‘a’. Finally, vertex ‘a’ and
vertex ‘b’ has degree as one which are also
called as the pendent vertex
MORE…
Isolated Vertex
A vertex with degree zero is called an isolated
vertex.
Example
MORE…
edge is the mathematical term for a line that
connects two vertices. Many edges can be
formed from a single vertex. Without a vertex, an
edge cannot be formed. There must be a starting
vertex and an ending vertex for an edge.
Here, ‘a’ and ‘b’ are the two vertices and the link between
them is called an edge.
MORE…
A graph ‘G’ is defined as G = (V, E) Where V is a
set of all vertices and E is a set of all edges in the
graph.
In the above example, ab, ac,
Example 1 cd, and bd are the edges of
the graph. Similarly, a, b, c,
and d are the vertices of the
graph.
MORE…
A graph ‘G’ is defined as G = (V, E) Where V is a
set of all vertices and E is a set of all edges in the
graph.
Example 2 In this graph, there are four
vertices a, b, c, and d, and
four edges ab, ac, ad, and cd.
MORE…
Loop
In a graph, if an edge is drawn from vertex to
itself, it is called a loop.
Example 1
V is a vertex for which it has an
edge (V, V) forming a loop.
MORE…
Loop
In a graph, if an edge is drawn from vertex to
itself, it is called a loop.
Example 1
there are two loops which are
formed at vertex a, and vertex b
GRAPH SUBGRAPH
A graph G′(V′,E′) is a subgraph of the graph G(V,E) if V′ ⊆V and E′ ⊆E.
Note that this does require G′(V′,E′) to be a graph, so one cannot form a
subgraph of arbitrary subsets of V and E. The second graph below is a
subset of the first.
GRAPH PATH
The notion of a path in a graph is intuitively clear but a little hard to pin down
formally. Suppose G(V,E) is a graph with vertices v0,v1,…,vk (not necessarily
distinct) and edges e1,e2,…,ek (not necessarily distinct) in which edge ei={vi-1,vi}
for i=1,…,k. Then the alternating sequence of vertices and edges v0e1v1e2v2…ekvk
is a path from v0 to vk of length k (note that the length is the number of edges, not
vertices). Unless we work with multigraphs the listing of the edges is redundant, so
we may speak more simply of the path as v0v1v2…vk. This definition allows for
incredibly knotty, repetitious paths. If we want to rule out that possibility, we can
speak of simple paths, which are paths in which no vertices (and thus no edges) are
repeated.
GRAPH PATH
Example: In the following diagram the red edges show a simple path of length three
from a to e. The path is acde. Of course this could also be the non-simple path
acdcacacdede of length 11
GRAPH CONNECTEDNESS
Intuitively a graph is connected if it has no parts that are isolated from each other, if you can
get from each part to every other part. Formally we say a graph is connected if there exists a
path between every pair of distinct vertices. Clearly this is equivalent to saying there is a
simple path between every pair of distinct vertices. The graph just given is connected, but
the following one is not since you cannot, for instance, get from a to d.
TYPES OF GRAPHS
There are two kinds of graphs, directed and undirected.
UNDIRECTED GRAPH has
DIRECTED GRAPH each vertex has
no directed edges. Consider
the following example. an indegree and an outdegree.
DIRECTED GRAPH EACH VERTEX HAS AN INDEGREE AND AN
OUTDEGREE.
Indegree of a Graph
Indegree of vertex V is the number of edges which are coming into the vertex V.
Notation − deg−(V).
Outdegree of a Graph
Outdegree of vertex V is the number of edges which are going out from the vertex V.
Notation − deg+(V). Vertex Indegree Outdegree
A 1 1
B
C
D
E
DIRECTED GRAPH EACH VERTEX HAS AN INDEGREE AND AN
OUTDEGREE.
Indegree of a Graph
Indegree of vertex V is the number of edges which are coming into the vertex V.
Notation − deg−(V).
Outdegree of a Graph
Outdegree of vertex V is the number of edges which are going out from the vertex V.
Notation − deg+(V). Vertex Indegree Outdegree
A 1 1
B 2
C
D
E
DIRECTED GRAPH EACH VERTEX HAS AN INDEGREE AND AN
OUTDEGREE.
Indegree of a Graph
Indegree of vertex V is the number of edges which are coming into the vertex V.
Notation − deg−(V).
Outdegree of a Graph
Outdegree of vertex V is the number of edges which are going out from the vertex V.
Notation − deg+(V). Vertex Indegree Outdegree
A 1 1
B 2 0
C
D
E
DIRECTED GRAPH EACH VERTEX HAS AN INDEGREE AND AN
OUTDEGREE.
Indegree of a Graph
Indegree of vertex V is the number of edges which are coming into the vertex V.
Notation − deg−(V).
Outdegree of a Graph
Outdegree of vertex V is the number of edges which are going out from the vertex V.
Notation − deg+(V). Vertex Indegree Outdegree
A 1 1
B 2 0
C 1 1
D 1 1
E 0 2
GRAPH CAN ALSO CLASSIFY INTO TWO A WEIGHTED AND
UNWEIGHTED GRAPH WHEREIN
Unweighted graph has no value in its edges
Weighted graph has a value in its edges
END OF CHAPTER 2