Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Graph Theory

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

School of Computing Science and Engineering

Course Code : MATH2007 Course Name: Discrete Mathematics

Graph Terminology,
Special Types of
Graphs and
Representation of
Graphs.

Name of the Faculty: Shelly Khurana Program Name: B.Tech


School of Computing Science and Engineering
Course Code : MATH2007 Course Name: Discrete Mathematics

Graph
•A graph G(V,E) is a collection of vertices (or nodes) and a
collection of edges that connect pairs of vertices.
•A graph may be undirected, meaning that there is no
distinction between the two vertices associated with each
edge, or its edges may be directed from one vertex to another.

Name of the Faculty: Shelly Khurana Program Name: B.Tech


School of Computing Science and Engineering
Course Code : MATH2007 Course Name: Discrete Mathematics

Terminologies
•Vertex (plural:vertices) : A node in a graph.
•Arc: The edge in a directed graph.
•Cycle:
 A path consisting of at least three vertices that
starts and ends with the same vertex.
 Must follow the proper direction in a digraph.
•Loop:
 A special case of a cycle in which a single arc begins and
ends with the same vertex.

Name of the Faculty: Shelly Khurana Program Name: B.Tech


School of Computing Science and Engineering
Course Code : MATH2007 Course Name: Discrete Mathematics

Directed graph (or digraph) : Undirected graph:


Each edge has a direction. There is no direction on any graph
The flow can go either direction

Name of the Faculty: Shelly Khurana Program Name: B.Tech


School of Computing Science and Engineering
Course Code : MATH2007 Course Name: Discrete Mathematics

•Adjacent Vertices (neighbors):


Two vertices are said to be adjacent if there exists an edge
which directly connects them.

•Degree:
The degree of a vertex is the number of edges incident to it
The outdegree of a vertex in a digraph is the number of
arcs leaving the vertex
The indegree of a vertex in a digraph is the number of arcs
entering the vertex
Name of the Faculty: Shelly Khurana Program Name: B.Tech
School of Computing Science and Engineering
Course Code : MATH2007 Course Name: Discrete Mathematics

Add your content here

Add your content here

Name of the Faculty: Shelly Khurana Program Name: B.Tech


School of Computing Science and Engineering
Course Code : MATH2007 Course Name: Discrete Mathematics

Multigraph
Any graph which contains some multiple edges is called
a multigraph. In a multigraph. No loops are allowed.

There are two different ideas of multiple edges:


•Edges without own identity: The identity of an edge is defined just
by the two nodes it connects. The term "multiple edges" means that
the same edge can occur several times between these two nodes.

•Edges with own identity: Edges are basic units just like nodes.
When multiple edges connect two nodes, these are different edges.

Name of the Faculty: Shelly Khurana Program Name: B.Tech


School of Computing Science and Engineering
Course Code : MATH2007 Course Name: Discrete Mathematics

BIPARTITE GRAPH
A bipartite graph, also called a bigraph, is a set of graph vertices decomposed into two separate
sets such that no two graph vertices within the same set are adjacent.

Name of the Faculty: Shelly Khurana Program Name: B.Tech


School of Computing Science and Engineering
Course Code : MATH2007 Course Name: Discrete Mathematics

REPRESENTATION OF GRAPHS

You can represent graphs in two ways :


1. As an Adjacency Matrix
2. As an Adjacency List

Name of the Faculty: Shelly Khurana Program Name: B.Tech


School of Computing Science and Engineering
Course Code : MATH2007 Course Name: Discrete Mathematics

Adjacency Matrix
•You can represent a directed or undirected graph in
the form of a matrix or two-dimensional array.

•For this, let us assume that V = the number of


vertices in the graph.

Name of the Faculty: Shelly Khurana Program Name: B.Tech


School of Computing Science and Engineering
Course Code : MATH2007 Course Name: Discrete Mathematics

Adjacency Matrix of a Directed Graph


For a directed graph, if there is a directed edge between two vertices, then the value is
considered to be 1, else it is considered to be 0.
For example, in the following graph, there is a directed edge between the vertices P and Q.
Therefore, this relationship would have a value of 1 in the matrix. However, the value for the
edge Q-->P would be 0, as it is not a directed edge.
Let's construct the adjacency matrix for the directed graph shown below.

Name of the Faculty: Shelly Khurana Program Name: B.Tech


School of Computing Science and Engineering
Course Code : MATH2007 Course Name: Discrete Mathematics

If you compare the adjacency matrix with the directed graph shown above, you will find that all
the directed edges viz, PQ, PT, RP, RS, TR, TS have a value of 1 whereas the other edges have a
value of 0.
The adjacency matrix of a directed graph can also be represented in the form of an array of size
V*V with rows represented by the letter i and columns represented by the letter j. An entry in
row i or column j will be equal to either 1 or 0. It will be equal to 1 if there is a directed edge
between i and j, else it is 0. Let's see how to represent the directed graph shown above, as an
array.

Name of the Faculty: Shelly Khurana Program Name: B.Tech


School of Computing Science and Engineering
Course Code : MATH2007 Course Name: Discrete Mathematics

Adjacency Matrix of an Undirected Graph


For an undirected graph, if there is an edge between two vertices, then the value is considered to
be 1, else it is considered to be 0.
For example, in the following graph, there is an edge between the vertices P and Q. Therefore,
this relationship would have a value of 1 in the matrix. The value for the edge Q-->P would also
be 1. However, there is no edge between Q and R and hence the value for Q-->R would be 0.
Let's construct the adjacency matrix for the undirected graph shown below.

Name of the Faculty: Shelly Khurana Program Name: B.Tech


School of Computing Science and Engineering
Course Code : MATH2007 Course Name: Discrete Mathematics

Adjacency list
Another way to represent a graph without multiple edges is to list all the edges of this graph. Another
way to represent a graph with no multiple edges is to use adjacency lists, which specify the
vertices that are adjacent to each vertex of the graph.

Name of the Faculty: Shelly Khurana Program Name: B.Tech


School of Computing Science and Engineering
Course Code : MATH2007 Course Name: Discrete Mathematics

Name of the Faculty: Shelly Khurana Program Name: B.Tech

You might also like