Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 92

CS6702 INTRODUCTION OF GRAPH THEORY

Topics
Definition
basic terminologies of graph
Isomorphism
Connectivity
Graph colouring
Operations on graphs
Euler graphs
Hamiltonian graphs

What is Graph Theory?


Branch of mathematics concerned with networks of points

connected by lines
Graphs are discrete structures consist of vertices and edges

that connect these vetices.


Problems in almost every conceivable disciplene can be

solved using graph models.

Definition: The mathematical theory of the properties and


applications of graphs.

Used to understand and solve


many of mathematical and path
problems.

applications
Chemistry - study of molecules and atoms, and construction of bonds between

them. ( ex- Ethane)

sociology - for example to measure actors prestige or to explore diffusion

mechanisms.
biology - where a vertex represents regions where certain species exist and the
edges represent migration path or movement between the regions. This
information is important when looking at breeding patterns or tracking the
spread of disease, parasites and to study the impact of migration that affect
other species.
operations Research -For example, the traveling salesman problem, the
shortest spanning tree in a weighted graph
modeling of network topologies can be done using graph concepts.
concept of graph coloring is utilized in resource allocation, job scheduling and
other scheduling concepts.
5

Applications in computer Science


Networks: Graph theory can be used in computer
networks, to schematize network topologies.

Webpage: can be represented by a direct graph. The


vertices are the web pages available at the website and a
directed edge from page A to page B exists if and only if
A contains a link to B.

Facebook is based
in graph theory
7

Workflow: Its sequence of processes through which a


piece of work passes from initiation to completion. Can
be also represented as directed graph.

Neural Networks: A series of algorithms that attempt


to identify underlying relationships in a set of data by
using a process that mimics the way the human brain
operates.

Google Maps:

10

Graphs
In elementary mathematics, "graph" refers to a function graph or

"graph of a function," i.e., a plot.


As used in graph theory, the term graph does not refer to data
charts such as line graphs or bar graphs.
Instead, it refers to a set of vertices (that is, points or nodes) and
of edges (or lines) that connect the vertices.
Graph - a visual representation of edges and vertices
Edge - the line between two boundaries (branch, arc, element)
Vertex - a point where two or more lines meet (node, junction,
point)

11

Edges connect two


vertices.
2. Edges only intersect
at vertices.
3. Edges joining a
vertex to itself are
called loops.
1.

Example 1: The
following picture
is a graph. List its
vertices
and
A
D
edges.
C

E
B
12

Formal Definition
A graph or a linear graph G = (V ,E) consists of set of objects

V , a nonempty set of vertices (or nodes) and E, a set of edges.


Each edge has either one or two vertices associated with it,
called its endpoints.
An edge is said to connect its endpoints.
Graphs are a structure for describing relationships between
similar objects
A graph with an infinite vertex set or an infinite number of
edges is called an infinite graph,
And a graph with a finite vertex set and a finite edge set is
called a finite graph.
13

This is also a graph.


The vertices just happen to have peoples names.
Such a graph could represent friendships (or any kind
of relationship).
Flexo
Flexo

Bender
Bender

Leela
Leela
Zoidberg
Zoidberg

Fry
Fry

14

Amy
Amy

Farnsworth
Farnsworth

It is immaterial whether the lines are drawn are

straight or curved, long or short.


It is important to check incidence between Edges and
vertices.

15

Loop, Multiple edges


Loop: An edge whose endpoints are equal
Multiple edges or parallel edges:
edges have the same pair of endpoints
Or more than one edge associated with a given pair of

vertices

Multiple
edges
16

loop

Simple Graph
each edge connects two different vertices and no two edges
connect same pair of vertices.
A graph that has neither self loops nor paralled edges

Multiple
edges
It is not
simple.

17

loo
p
It is a simple
graph.

Types of Graphs
Multigraph multiple edges connecting the same vertices
Pseudograph - A graph that may contain multiple

edges and graph loops

18

Adjacent, neighbors, incident

Two vertices are adjacent and are neighbors if they are

the endpoints of an edge. or


Two vertices u and v in an undirected graph G are called
adjacent in G if {u, v} is an edge in G.
If e = {u, v},edge e is called incident with vertices u &
v
Example:
A and B are adjacent
A and D are not adjacent

A
C

19

Null graph
It is possible for the edge set E to be empty.
Such a graph without any edges called null graph.
Every vertex in a null graph is an isolated vertex.

20

Complement
Complement of G: The complement G of a simple

graph G :
A simple graph
V(G) = V(G)
E(G) = { uv | uv E(G) }
u

G
x

21

y
w

v
x

Directed and undirected graphs


A directed graph or digraph G = (V, E) consists of a set
V of vertices and a set E of edges that are ordered pairs of
elements in V.
For each eE, e = (u, v) where u, v V.
A directed edge associated with the ordered pair (u, u) is
to start at u and end at v for some u,vV.
An undirected graph, has no specified direction of its
edges.

22

Example I: In a round-robin tournament, each


team plays against each other team exactly
once. How can we represent the results of the
tournament (which team beats which other
team)?
We should use a directed graph with an
edge (a, b) indicating that team a beats team
Bruins
b.
Maple

Penguins
23

Giants

Example II: How can we represent a network


of (bi-directional) railways connecting a set of
cities?
We should use a simple undirected graph
with an edge {a, b} indicating a direct train
connection between cities a and b.
Boston

Toronto

Lbeck

New York
Hamburg
Washington
24

Degree of a vertex deg(v)


The degree or valency of a vertex in an undirected graph

is the number of edges incident with it, except that a loop at


a vertex contributes twice to the degree of that vertex.
can determine the degree of a vertex in a displayed graph
by counting the lines that touch it.
A vertex of degree 0 is called isolated, since it is not
adjacent to any vertex.
A vertex of degree 1 is called pendant. It is adjacent to
exactly one other vertex.
The graph in which the degree of all vertices are equal
called regular graph.
25

Graph Terminology
Example: Which vertices in the following graph are isolated,

which are pendant, and what is the maximum degree? What type of
graph is it?
f

d
a

e
g

Solution: Vertex f is isolated, and vertices a, d and j are pendant. The


maximum degree is deg(g) = 5. This graph is a pseudograph
(undirected, loops).
26

Number of vertices =5 ; Number of edges=7


deg(v1)=deg(v3)=deg(v4)=3; deg(v2)=4; deg(v5)=1
deg(v1)+deg(v3)+deg(v4)+deg(v2)+deg(v5)=14 (twice

number of edges). It implies the theorem

27

Handshaking Theorem
Theorem: An undirected graph has an even number of
vertices of odd degree
Let G = (V, E) be an undirected graph with e edges.
V1 and V2 are set of even and odd degree vertices
respectively
Then 2e = vV deg(v)
2|E| = vV deg(v) = vV1 deg(v) + vV2 deg(v)
Example: How many edges are there in a graph with 10
vertices, each of degree 6?
Solution: The sum of the degrees of the vertices is 610 =
60. According to the Handshaking Theorem, it follows that
2e = 60, so there are 30 edges.

28

Graph Terminology contd..


In a graph with directed edges, the in-degree of a vertex

v, denoted by deg-(v), is the number of edges with v as their


terminal vertex.
The out-degree of v, denoted by deg+(v), is the number of
edges with v as their initial vertex.
Question: How does adding a loop to a vertex change the
in-degree and out-degree of that vertex?
Answer: It increases both the in-degree and the out-degree
by one.

29

Example: What are the in-degrees and out-degrees of the


vertices a, b, c, d in this graph
deg-(a) = 1
deg+(a) = 2

deg-(d) = 2
deg+(d) = 1

30

deg-(b) = 4
deg+(b) = 2

deg-(c) = 0
deg+(c) = 2

Representation of Graphs

31

a
b

d
c

32

Vertex

Adjacent
Vertices

Initial
Vertex

Terminal
Vertices

b, c, d

a, d

a, d

a, b, c

a, b, c

adjacency matrix
Let G = (V, E) be a simple graph with |V| = n.
Suppose that the vertices of G are listed in arbitrary

order as v1, v2, , vn.


adjacency matrix A (or AG) of G, with respect to this
listing of the vertices, is the nn zero-one matrix with 1 as
its (i, j)th entry when vi and vj are adjacent, and 0
otherwise.
In other words, for an adjacency matrix A = [aij],
aij = 1
aij = 0
33

if {vi, vj} is an edge of G,


otherwise.

Example: What is the adjacency

matrix AG for the following graph G


based on the order of vertices a, b, c, d ?

b
d
c

0 1 1 1
1 0 0 1

AG
1 0 0 1

1 1 1 0
Note: Adjacency matrices of undirected graphs are always symmetric.
34

Incident matrix
Let G = (V, E) be an undirected graph with |V| = n.
incidence matrix of G with respect to this listing of the
vertices and edges is the nm zero-one matrix with 1 as its
(i, j)th entry when edge ej is incident with vi, and 0
otherwise.
In other words, for an incidence matrix M = [mij]
mij = 1 if edge ej is incident with vi

mij = 0

35

otherwise.

Example: What is the incidence matrix M for the


following graph G based on the order of vertices v1, v2, v3,
v4, v5 and edges e1, e2, e3, e4,e5, e6?

36

Isomorphism of Graphs

37

Definition: The simple graphs G1 = (V1, E1) and G2 = (V2,


E2) are isomorphic iff there is a one-to-one correspondence
between their vertices and between their edges such that the
incidence relationship is preserved.
Such a function f is called an isomorphism.
In other words, G1 and G2 are isomorphic if their vertices
can be ordered in such a way that the adjacency matrices
MG1 and MG2 are identical.

38

Suppose that e is incident on vertices v1 and v2 in G.

Then the corresponding edge e in G must be incident on


the vertices v1 and v2 that correspond to v1 and v2
respectively.
The correspondence is a-v1 , b-v2 , c-v3 , d-v4 , e-v5

39

Except for the labels of their vertices and edges, isomorphic graphs are same

graph, drawn differently. The figure shows two different ways of drawing the
same graph

It is not easy task to determine whether or not the given two graphs are isomorphic,

example these two graphs are isomorphic , but just by looking at them

40

observations
two isomorphic simple graphs must both have.
the same number of vertices,
the same number of edges, and
the same degrees of vertices.
there is a one to one correspondence between sets of Vertices of the
graph which establishes a one-to-one correspondence between edges.
It is not always an easy task to determine whether or not to find given
graphs are isomorphic. Non isomorphic graphs example :

41

Example I: Are the following two graphs


a
isomorphic?
b

a
e

e
b

Solution: Yes, they are isomorphic, because they can be arranged to look identical.
You can see this if in the right graph you move vertex b to the left of the edge {a,
c}. Then the isomorphism f from the left to the right graph is:
f(a) = e,
f(b) = a,
f(c) = b,
f(d) = c,
f(e) = d.
42

Example II: How about these two graphs?


a

b
e

e
b

c
d

Solution: No, they are not isomorphic, because they differ in the
degrees of their vertices. Vertex d in right graph is of degree one, but
there is no such vertex in the left graph.

43

Graph isomorphism arise in applications of graph theory


to chemistry
the design of electronic circuits
multigraphs, known as molecular graphs, to model chemical
compounds, in which vertices represent atoms and edges
represent chemical bonds between these atoms.

C6H6

44

Two structural isomers, molecules with identical molecular

formulas but with atoms bonded differently, have nonisomorphic


molecular graphs.

When a potentially new chemical compound is synthesized, a

database of molecular graphs is checked to see whether the


molecular graph of the compound is the same as one already
known.
45

Graph isomorphism is the basis for the verification

that a particular layout of a circuit produced by an


automated tool corresponds to the original schematic
of the design.
Graph isomorphism can also be used to determine

whether a chip from one vendor includes intellectual


property from a different vendor.
This can be done by looking for large isomorphic

subgraphs in the graphs modeling these chips.

46

subgraphs
A graph g is said to be subgraph of a graph G , if all the

vertices and all the edges of g are in G, and each edge of g


has the same end vertices in g as in G.
The symbol gG states that g is a subgraph of G.
Every graph is its own subgraph
A subgraph of a subgraph of G is a subgraph of G.
A single vertex in a graph G is a subgraph of G.
A single edge in G, together with its end vertices is also a
subgraph of G.

47

Subgraphs examples

48

G1

v
G2

Edge-disjoint subgraphs
Two or more subgraphs g1 and g2 of a graph G are said to be

edge disjoint if they donot have edges in common, but they


may have vertices in common.

49

Connectivity

50

Many problems can be modeled with paths formed by

traveling along the edges of graphs.


problem of determining whether a message can be sent

between two computers using intermediate links can be


studied with a graph model.
Problems of efficiently planning routes for mail

delivery, garbage pickup, diagnostics in computer


networks, and so on can be solved using models that
involve paths in graphs.
51

Walk or edge train or chain


A walk in a graph is a sequence of vertices, each linked to the next

vertex by a specified edge of the graph.


No edge appears more than once in a walk.
A vertex may appear more than once.
The set of vertices and edges constituing a walk is clearly a subgraph of
G.
Vertices with which a walk begins and ends called its terminal vertices.
If a walk begins and ends at same vertex called closed walk.
Or else it is called open walk

v1 a v2 b v3 c v3 d v4 e v2 f v5
52

path

A open walk in which no vertex appears more than once called a

path, hence self loop cannot be included in a path.


It does not intersect itself.
The number of edges in a path called its length.
Edge which is not a self loop is path length=1
Degree of the terminal vertices in the path is 1, for rest of the
vertices , the degree of vertices is 2
Example - v1 a v2 b v3 d v4

53

circuit
A closed walk in which no vertex appears more than

once.
Degree of every vertex in a circuit =2
It is a subgraph of another graph.
Is also called a cycle, elementary cycle, circular path
and polygon

54

Walks,paths and circuits

55

An undirected graph is called connected if there is a path


between every pair of distinct vertices in the graph.
For example, any two computers in a network can communicate if and

only if the graph of this network is connected.


A graph consisting of only one vertex is always connected,

because it does not contain any pair of distinct vertices.


A disconnected graph consists of two or more connected
graphs. Each of these connected sub graphs is called component.
A directed graph is strongly connected if there is a path from a
to b and from b to a whenever a and b are vertices in the graph.
An directed graph is weakly connected if there is a path
between any two vertices in the underlying undirected graph.

56

Example: Are the following graphs connected?


a

e
d

Yes.

No.
b

b
e

c
57

d
Yes.

d
c

f
No.

Connectivity
Example: Are the following directed graphs strongly or

weakly connected?
a
b
d

Weakly connected, because, for example,


there is no path from b to d.

c
a
b
d
c
58

Strongly connected, because there are


paths between all possible pairs of vertices.

Special Graphs

A complete graph on n vertices, denoted by Kn, is a simple graph


that contains exactly one edge between each pair of distinct vertices.
The graphs Kn, for n = 1, 2, 3, 4, 5, 6, are displayed

A simple graph is called bipartite if its vertex set V can be


partitioned into two disjoint nonempty sets V1 and V2 such
that every edge in the graph connects a vertex in V1 with a
vertex in V2 (so that no edge in G connects either two
vertices in V1 or two vertices in V2).
59

Special Graphs
Example I: Is C3 bipartite?
No, because there is no way to partition the vertices into
two sets so that there are no edges with both endpoints in
the same set.

v1
v2

v3

Example II: Is C6 bipartite?


v1
v2

v5
v3

60

v1

v6

v4

Yes, because we
can display C6 like
this:

v5
v3

v6
v2
v4

Special Graphs
Definition: The complete bipartite graph Km,n is the

graph that has its vertex set partitioned into two subsets of
m and n vertices, respectively. Two vertices are connected if
and only if they are in different subsets.

K3,2

61

K3,4

Special Graphs
Definition: The cycle Cn, n 3, consists of n vertices v1,

v2, , vn and edges {v1, v2}, {v2, v3}, , {vn-1, vn}, {vn, v1}.

C3

62

C4

C5

C6

Special Graphs
Definition: We obtain the wheel Wn when we add an

additional vertex to the cycle Cn, for n 3, and connect this


new vertex to each of the n vertices in Cn by adding new
edges.

W3

63

W4

W5

W6

Graph Colouring

64

A coloring of a simple graph is the assignment of a color to

each vertex of the graph so that no two adjacent vertices are


assigned the same color.
However, for most graphs a coloring can be found that uses
fewer colors than the number of vertices in the graph.
The chromatic number of a graph is the least number of
colors needed for a coloring of this graph.
FOUR COLOR THEOREM
The chromatic number of a planar graph is no greater than four.

65

Cromatic number of a complete graph with n vertices is n and


for bipartite graph is 2. examples are given below

66

For cycles : When n is odd and n > 1, the chromatic


number of Cn is 3.
two colors are needed to color Cn when n is even

67

Operations on Graphs

Union
Intersection
Ring sum
Deletion
decomposition
fusion
68

Definition: The union of two simple graphs G1 = (V1,


E1) and G2 = (V2, E2) is the simple graph with vertex set
V1 V2 and edge set E1 E2. The union of G1 and G2
is denoted by G1 G2.

G1

69

G2

G1 G2 = K5

Intersection of Graphs
Definition: The intersection of of two simple graphs G1

=(V1, E1) and G2 = (V2, E2) is the simple graph consists of


vertices and edges that are both in G1 and G2.
intersection of G1 and G2 is denoted by G1 G2.

70

Ringsum operation
The ring sum of two graphs G1 and G2, denoted by

G1 G2 is a graph consisting of the vertex set V1


V2 and of edges that are either in G1 or G2; but not in
both.

71

Decomposition: A graph G is said to be decomposed into two

subgraphs G1 and G2, if G1 G2 = G and G1 G2=null


graph.
Deletion : If vi is a vertex in graph G, then G vi denotes a
subgraph of G obtained by deleting vi from G. Deletion of a
vertex always implies the deletion of all edges incident on that
vertex.
Fusion : A pair of vertices a, b in a graph G are said to be fused
if the two vertices are replaced by a single new vertex such that
every edge, that was incident on either a or b or on both, is
incident on the new vertex.
fusion of two vertices does not alter the number of edges, but reduces

the number of vertices by one.


72

Example deletion

Fusion of vertices a and b

73

Euler Circuits and Paths

74

Knigsberg Bridges
In the 1700s, seven bridges connected two islands

on the Pregel River to the rest of the city.


The people wondered whether it would be possible
to walk through the city by crossing each bridge
exactly once and return to the original starting
point.

75

The Seven Bridges Problem


Each area is a vertex
Each bridge is an edge

Find a path that


traverses each edge
exactly once

76

Related Problems: Puzzles


A

Two problems:
1) Can you draw these without lifting your pen,
drawing each line only once
2)
77

Can you start and end at the same point.

An Euler Circuit for Puzzle A

8
1

9
1
0

78

Euler line and graph


Given G(V,E), an Euler line is a closed walk running through

every edge exactly once. The graph contains Euler line is


called Euler graph.
A given connected graph is an Euler graph if and only if all
its vertices are of even degree.
Example for Euler graph

79

HAMILTON PATHS & CIRCUITS


A Hamiltonian circuit in a connected graph is defined as a closed
walk that traverses every vertex of G exactly once, except at the
starting vertex at which the walk terminates.
A circuit in a connected graph G is said to be Hamiltonian if it
includes every vertex of G
A Hamilton circuit is a graph of n vertices has only n edges.
In the example it starts at vertex v, passing through each vertex
exactly once.

80

Not every connected graph has a Hamiltonian circuit.


for example the following graph shown does not have a Hamiltonian

circuit.

If we remove one edge from Hamiltonian circuit we are left with a path,

called Hamiltonian path which covers traverses every vertex of G.


Every graph has Hamiltonian circuit has a Hamiltonian path.
However many graphs with Hamiltonian paths that have no Hamiltonian
circuits
In considering existence of Hamiltonian Circuit we need to consider only
simple graphs
81

Theorem
A sufficient condition for a simple graph G to have a

Hamiltonian circuit is that the degree of every vertex


in G be at least n/2 where n is the number of vertices
in G.

82

Seating problem

Nine members of a club meet each day for lunch at a round table. They decide
to sit such that every member has different neighbors at each lunch. How
many days can this arrangement last?
Solution
This situation can be represented by a graph with 9 vertices such that each
vertex represents a member and an edge represents relationship of sitting
next to each other. Possible arrangements are
1234567891
1352749681
1573928461
1795836241
For n people number of arrangements are
(n-1)/ 2 if n is odd
(n-2)/2 if n is even
83

Example

Hamilton versus Euler

The figure shows a graph that (1) has


Euler circuits (the vertices are all
even) and (2) has Hamilton circuits.

One such Hamilton


circuit is A, F, B, C, G,
D, E, A there are
plenty more.
84

Example

Hamilton versus
Euler

This figure shows a graph that (1) has no Euler


circuits but does have Euler paths (for example
C, D, E, B, A, D) and (2) has no Hamilton circuits
(sooner or later you have to go to C, and then
you are stuck) but does

have Hamilton paths


(for example, A, B, E,
D, C). This illustrates
that a graph can have
a Hamilton path but
no
Hamilton
circuit!
85

Example

Hamilton versus
Euler

This figure shows a graph that (1) has neither


Euler circuits nor paths (it has four odd vertices)
and (2) has Hamilton circuits (for example A, B,
C, D, E, A there are plenty

more) and
consequently has
Hamilton paths (for
example, A, B, C, D,
E).
86

Example

Hamilton versus
Euler

This figure shows a graph


that (1) has no Euler
circuits but has Euler paths
(F and G are the two odd
vertices) and (2) has
neither Hamilton circuits
nor Hamilton paths.

87

Example

Hamilton versus
Euler

This figure shows a graph


that (1) has neither Euler
circuits nor Euler paths
(too many odd vertices)
and (2) has neither
Hamilton circuits nor
Hamilton paths.

88

Traveling Salesman Problem


traveling salesman problem is one of the classical

problems in computer science.


A traveling salesman wants to visit a number of cities and
then return to his starting point. Of course he wants to save
time and energy, so he wants to determine the shortest path
for his trip.
We can represent the cities and the distances between
them by a weighted, complete, undirected graph.
The problem then is to find the circuit of minimum total
weight that visits each vertex exactly one.

89

The Traveling Salesman Problem


Example: What path would the traveling

salesman take to visit the following cities?


Toronto

650
Chicago

700
700

600

550
Boston

200
New York

Solution: The shortest path is Boston, New York, Chicago, Toronto, Boston (2,000
miles).
90

The Traveling Salesman Problem


Question: Given n vertices, how many different cycles Cn

can we form by connecting these vertices with edges?


Solution: We first choose a starting point. Then we have
(n 1) choices for the second vertex in the cycle, (n 2) for
the third one, and so on, so there are (n 1)! choices for the
whole cycle.
However, this number includes identical cycles that were
constructed in opposite directions. Therefore, the actual
number of different cycles Cn is (n 1)!/2.

91

Thank You

92

You might also like