0% found this document useful (0 votes)
6 views

Lecture 1

The document discusses graph theory and provides definitions and examples of different types of graphs such as directed graphs, undirected graphs, bipartite graphs, planar graphs, and weighted graphs. It also covers graph representation methods like adjacency matrices and adjacency lists, as well as graph terminology and applications of graph theory.

Uploaded by

sewap61653
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Lecture 1

The document discusses graph theory and provides definitions and examples of different types of graphs such as directed graphs, undirected graphs, bipartite graphs, planar graphs, and weighted graphs. It also covers graph representation methods like adjacency matrices and adjacency lists, as well as graph terminology and applications of graph theory.

Uploaded by

sewap61653
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 43

Graph

Theory
Waqas Ali
Department of Computer Science
UET, Lahore
(Lecture # 1: January 18, 2024)
Outline
• Basic Definitions
Graph
• A Graph consists of a finite set of vertices (or nodes)
and set of Edges (or links) which connect a pair of
nodes.
• A Graph is a non-linear data structure.
Graph
• A graph is a data structure that consists of a finite set of
nodes (or vertices) and a finite set of edges (or
links) connecting them.

• Graphs are used to solve real-life problems that involve


representation of the problem space as a network.

• For example, a single user in Facebook can be represented as


a node (vertex) while his connections with others can
be represented as an edge between nodes.
Real-world Graph
Graph Theory
• In mathematics, graph theory is the study of graphs, which
are mathematical structures used to model
pairwise relations between objects.
Types of Graphs
• Null Graph: A null graph is a graph in which there are no
edges between its vertices.

• A null graph is also called an empty graph.

• A null graph with n vertices is denoted by Nn.


Types of Graphs
• Trivial Graph: A trivial graph is the graph which has only
one vertex.
Types of Graphs
• Undirected Graph: A graph is called an undirected graph
if all the edges present between any graph nodes are
non- directed.
• Directed Graph: A graph is called a directed graph or
digraph if all the edges present between any vertices
or nodes of the graph are directed or have a defined
direction.
Types of Graphs
• Simple Graph: A simple graph is the undirected
graph with no parallel edges and no loops.
• A simple graph which has n vertices, the degree of
every vertex is at most n -1.
• If a graph G= (V, E) contains a self-loop besides
other edges, it is a pseudograph.
Types of Graphs
• Complete Graph: A complete graph is a simple undirected
graph in which every pair of distinct vertices is
connected by a unique edge

• It contains all possible edges.


Types of Graphs
• Complete Directed Graph: A complete digraph is a
directed graph in which every pair of distinct
vertices is connected by a pair of unique edges (one in
each direction).
Types of Graphs
• Connected Graph: A graph in which we can visit
from any one vertex to any other vertex.
• In a connected graph, at least one edge or path
exists between every pair of vertices.
Types of Graphs
• Disconnected Graph: A graph in which a path does
not exist between every pair of vertices
Types of Graphs
• Regular Graph: A graph in which degree of all
the vertices is same.
• If the degree of all the vertices is k, then it is
calledk- regular graph.
• A complete graph is always a regular graph.
Types of Graphs
• Cycle Graph: A simple graph with ‘n’ vertices (n >= 3)
and ‘n’ edges is called a cycle graph if all its edges
form a cycle of length ‘n’.
• In the cycle graph, degree of each vertex is 2.
• A graph containing at least one cycle in it is also known as
a cyclic graph.
Types of Graphs
• Wheel Graph: A wheel graph is obtained from a
cycle graph Cn-1 by adding a new vertex.
• That new vertex is called a Hub which is connected to all
the vertices of Cn.
• Number of edges in wheel = 2(n-1)
Types of Graphs
• Acyclic Graph: A graph which does not contain any cycle
in it is called as an acyclic graph.
Types of Graphs
• Bipartite Graph: A bipartite graph is a graph in which the
vertex set can be partitioned into two sets such that
edges only go between sets, not within them.
• A graph G (V, E) is called bipartite graph if its vertex-set
V(G) can be decomposed into two non-empty
disjoint subsets V1(G) and V2(G) in such a way that
each edge e ∈ E(G) has its one last joint in V1(G)
and other last point in V2(G).
Types of Graphs
• Complete Bipartite Graph: A complete bipartite graph is
a bipartite graph in which each vertex in the first
set is joined to each vertex in the second set by exactly one
edge.

The above graph is known as K4,3.


Types of Graphs
• Weighted Graph: A weighted graph is a graph
whose edges have been labeled with some weights or
numbers.
Types of Graphs
• Multi Graph: A graph in which there are multiple edges
between any pair of vertices or there are edges
from a vertex to itself (loop) is called a multi - graph.
Types of Graphs
• Planar Graph: A planar graph is a graph that we can draw
in a plane in such a way that no two edges of it cross
each other.
Types of Graphs
• Non-planar Graph: A graph that is not a planar graph is
called a non-planar graph.
• In other words, a graph that cannot be drawn without at
least on pair of its crossing edges is known as non-
planar graph.
Types of Graphs
• Subgraph: The vertices and edges of a graph that
are subsets of another graph are known as a subgraph.
Graph Representation
• Adjacency Matrix: An adjacency matrix is a square
matrix used to represent a finite graph. The elements of
the matrix indicate whether pairs of vertices are adjacent
or not in the graph.
Graph Representation
• Weighted Graph’s Adjacency Matrix: Weight or cost is
indicated at the graph's edge
Graph Representation
• Adjacency List: An adjacency list represents a graph as an array of
linked lists. The index of the array represents a vertex and
each element in its linked list represents the other vertices that
form an edge with the vertex.
Graph Representation
• Edge List: An edge list is a used to represent a graph as a list of its
edges. An edge is defined by its start and end vertex, so each
edge may be represented by two numbers.
Graph Terminology
• Two vertices joined by an edge are called the end vertices or
endpoints of the edge.
• If an edge is directed its first endpoint is called the
origin
and the other is called the destination.
• Two vertices are said to be adjacent if they are endpoints of
the same edge.
• An edge is said to be incident on a vertex if the vertex is one
of the edges endpoints.
• The outgoing edges of a vertex are the directed edges whose
origin is that vertex.
• The incoming edges of a vertex are the directed edges whose
destination is that vertex
Graph Terminology
Graph Terminology
Degree: Number of edges incident on a node
In-degree: Number of edges entering a node
Out-degree: Number of edges leaving a node
Degree = In-degree + Out-degree
Graph Terminology
• Path: A path is a sequence of vertices such that there is
an edge from each vertex to its successor.
• A path is simple if each vertex is distinct.
• A circuit is a path in which the terminal vertex
coincides with the initial vertex
Graph Terminology
• A path from a vertex to itself is called a
cycle.
• A graph is called cyclic if it contains a cycle;
• otherwise, it is called acyclic
Graph Terminology
• Clustering coefficient is a measure of the degree to which
nodes in a graph tend to cluster together.

Average Clustering
Coefficient:
Applications of Graphs
Applications of Graph
• Graphs are used to define the flow of computation.
• Graphs are used to represent networks of communication.
• Graphs are used to represent data organization.
• Graph theory is used to find shortest path in road or
a network.
• Graph theory is used in designing of circuit connections.
• In linguistics, graphs are mostly used for parsing of
a language tree and grammar of a language tree.
• Graph theory is used to study molecules.
• Nodes in biological networks represent bimolecular such as
genes, proteins or metabolites, and edges connecting
these nodes indicate functional, physical or chemical
interactions between the corresponding bimolecular
Applications of Graph
• Nodes in biological networks represent bimolecular such as
genes, proteins or metabolites, and edges connecting
these nodes indicate functional, physical or chemical
interactions between the corresponding bimolecular.

• Graph theory is also used in sociology. For example, to


explore rumor spreading.
Summary
• Basic Definitions

You might also like