Introduction
Basic Graph Theory
Saksham Agrawal
August 30, 2015
Saksham Agrawal
Basic Graph Theory
Introduction
List Of Contents
1- Introduction To Graph
2- Definitions And Terminology
3- Graph Representation
4- Breadth First Search
5- Depth first search
Saksham Agrawal
Basic Graph Theory
Introduction
Introduction To Graphs
In mathematics and computer science, graph theory is the
study of graphs, which are mathematical structures used to model
pairwise relations between objects. A ”graph” in this context is
made up of ”vertices” or ”nodes” and lines called edges that
connect them.
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. Graphs are
one of the prime objects of study in discrete mathematics.
Saksham Agrawal
Basic Graph Theory
Introduction
Figure: A Typical Graph
Saksham Agrawal
Basic Graph Theory
Introduction
Definitions And Terminology
Graphs are much clear when defined in mathematical terms. A
Graph G (V, E), consists of two sets,
Set of Vertices, V Set of Edges, E As the name suggest, V, is the
set of vertices or, the set of all nodes in a given graph and E, is the
set of all the edges between these nodes, or the associations
between them. So, V denotes the number of nodes in a graph and
E denotes the number of edges
Saksham Agrawal
Basic Graph Theory
Introduction
Figure: Types Of Graph
Saksham Agrawal
Basic Graph Theory
Introduction
Graph Representations ⇒
Adjacency Matrix
Adjacency List
Saksham Agrawal
Basic Graph Theory
Introduction
Adjacency Matrix
Figure: Adjacency Matrix Of Shown Graph
Saksham Agrawal
Basic Graph Theory
Introduction
Adjacency List
Figure: Adjacency List Of Shown Graph
Saksham Agrawal
Basic Graph Theory
Introduction
Breadth first Search
In BFS,we use a queue and we push the current vertex in the
queue and the vertices which are adjacent to the current vertex
using the adjacency list.We also maintain a visited array in which
we record the visited vertices so as to prevent revisiting the same
vertex.After we have pushed the adjacent vertices of a vertex we
pop it out of the queue.
Saksham Agrawal
Basic Graph Theory
Introduction
BFS algorithm
Saksham Agrawal
Basic Graph Theory
Introduction
Application of BFS
BFS is mainly used in a connected graph in which we want to find
the shortest path between 2 vertices.In this we also maintain a
level array.We start from one of the 2 vertices and set its level as 0
and the set level of the adjacent vertices as level of parent+1 and
traverse the graph in this until we reach the other vertex.The level
of the vertex represents the shortest path between the two vertices.
Saksham Agrawal
Basic Graph Theory
Introduction
Depth First Search
Algorithm:- When we see a maze in a newspaper or a magazine
or anywhere else, the way we solve it is we take a path and go
through it. If we find any junction or a crossroad, where we have a
choice of paths to choose, we mark that junction, take up a path
and traverse the whole route in your brain. If we see a dead end,
we realize that this leads we now where so we come back to the
junction we marked before and take up another path of the
junction. See if that is also a dead end, else we continue to explore
the, puzzle as this route contributes in reaching our destination.In
code, we do this by recursion.
Saksham Agrawal
Basic Graph Theory
Introduction
DFS step-by-step process
For a given set of vertices V = V1, V2,V3. . . , start with V1,
and explore all the vertices that can possibly be reached from V1.
Then go to the next vertex V2, if it hasn’t been visited, explore
all the nodes reachable from V2, if not, go for V3.
Similarly, go on picking up all the vertices one-by-one and
explore as much as possible if it wasn’t visited at all.
Saksham Agrawal
Basic Graph Theory
Introduction
Saksham Agrawal
Basic Graph Theory
Introduction
Application of DFS
DFS is also used for finding the shortest path between two
vertices.It is also used to do topological sorting.
Topological Sorting:-
It represents the logical order of doing
something. For instance,we wear socks before shoes and after we
tie laces.In the similar way in topological sorting a vertex appears
only when all its adjacent vertices have already appeared.It is
logical that topological sorting is done in only a directed
graph.Obviously, the vertex with no child is one which appears in
front.This is done using a stack and DFS on a graph.
Saksham Agrawal
Basic Graph Theory

More Related Content

PPTX
Graph Theory
PPTX
Introduction to Graph Theory
PPTX
Graph theory
PPTX
Introduction to Graph Theory
PDF
Cs6702 graph theory and applications 2 marks questions and answers
PPT
Graph isomorphism
PPT
Chapter 5 Graphs (1).ppt
PPTX
Matrix Representation Of Graph
Graph Theory
Introduction to Graph Theory
Graph theory
Introduction to Graph Theory
Cs6702 graph theory and applications 2 marks questions and answers
Graph isomorphism
Chapter 5 Graphs (1).ppt
Matrix Representation Of Graph

What's hot (20)

PPT
Lec 17 heap data structure
PPTX
Graph theory
PPTX
Euler graph
PPTX
Design and Analysis of Algorithms.pptx
PPT
Graph theory
PPTX
Applications of Discrete Structures
PPT
Integration and its basic rules and function.
PPTX
Isomorphic graph
PDF
Shortest Path in Graph
PPTX
Slides Chapter10.1 10.2
PPT
Graph-theory.ppt
PDF
PPT
Numerical Analysis And Linear Algebra
PPT
Set in discrete mathematics
PDF
Runge kutta 2nd Order
PPTX
Modular arithmetic
PPTX
Fuzzy Set
PPTX
Graph theory Eulerian graph
PPT
DM-unit-3.ppt
PPTX
Integration
Lec 17 heap data structure
Graph theory
Euler graph
Design and Analysis of Algorithms.pptx
Graph theory
Applications of Discrete Structures
Integration and its basic rules and function.
Isomorphic graph
Shortest Path in Graph
Slides Chapter10.1 10.2
Graph-theory.ppt
Numerical Analysis And Linear Algebra
Set in discrete mathematics
Runge kutta 2nd Order
Modular arithmetic
Fuzzy Set
Graph theory Eulerian graph
DM-unit-3.ppt
Integration
Ad

Viewers also liked (20)

PPT
Survey on Frequent Pattern Mining on Graph Data - Slides
PDF
Graph
PPTX
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
PPTX
graph theory
PDF
CS6702 graph theory and applications notes pdf book
PPTX
Interesting applications of graph theory
PPTX
Introduction to Graph Theory
PDF
Financial planning in the brain scanner slidecast
PDF
Neuronvisio Intro
PPT
gSpan algorithm
PPTX
Presentation Internship Brain Connectivity Graph 2014 (ENG)
PPT
Graph theory
PPTX
Introduction to graph theory (All chapter)
PPT
burton_discrete_graph theory
PPTX
The Graph Structure of the Web - Aggregated by Pay-Level Domain
PDF
How to read academic research (beginner's guide)
PPT
Discreet_Set Theory
PPTX
Talking Planned Giving: Words that Work
PPT
Trends In Graph Data Management And Mining
PPT
Class 1 f_mri_intro
Survey on Frequent Pattern Mining on Graph Data - Slides
Graph
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
graph theory
CS6702 graph theory and applications notes pdf book
Interesting applications of graph theory
Introduction to Graph Theory
Financial planning in the brain scanner slidecast
Neuronvisio Intro
gSpan algorithm
Presentation Internship Brain Connectivity Graph 2014 (ENG)
Graph theory
Introduction to graph theory (All chapter)
burton_discrete_graph theory
The Graph Structure of the Web - Aggregated by Pay-Level Domain
How to read academic research (beginner's guide)
Discreet_Set Theory
Talking Planned Giving: Words that Work
Trends In Graph Data Management And Mining
Class 1 f_mri_intro
Ad

Similar to Graph Theory (20)

PPTX
UNIT IV NON LINEAR DATA STRUCTURES - GRAPH
PPTX
PPTX
UNIT IV NON LINEAR DATA STRUCTURES - GRAPH.pptx
PPTX
UNIT III.pptx
PPTX
Topological Sort and BFS
PPTX
Data structure note
PPTX
Graphs data structures
PDF
graph representation.pdf
PDF
Daa chpater 12
PPTX
data structures and algorithms Unit 2
PPTX
logic.pptx
PPSX
Unit-6 Graph.ppsx ppt
PPTX
Depth First Search (DFS) pada Graph
PPTX
DATA STRUCTURES.pptx
PPTX
Graph Data Structure
PDF
Unit-10 Graphs .pdf
PPTX
Breadth First Search (BFS) pada Graph
PPTX
Graph data structures for ppt for understanding.pptx
PPTX
VANU no sql ppt.pptx
UNIT IV NON LINEAR DATA STRUCTURES - GRAPH
UNIT IV NON LINEAR DATA STRUCTURES - GRAPH.pptx
UNIT III.pptx
Topological Sort and BFS
Data structure note
Graphs data structures
graph representation.pdf
Daa chpater 12
data structures and algorithms Unit 2
logic.pptx
Unit-6 Graph.ppsx ppt
Depth First Search (DFS) pada Graph
DATA STRUCTURES.pptx
Graph Data Structure
Unit-10 Graphs .pdf
Breadth First Search (BFS) pada Graph
Graph data structures for ppt for understanding.pptx
VANU no sql ppt.pptx

More from Shivam Singh (7)

PDF
Stacks
PDF
PPTX
What If Microsoft sold diapers!? MS Diapers!
PDF
Search Algprithms
PDF
Binary Search Tree
PDF
Linked List
PDF
Sorting Algorithms
Stacks
What If Microsoft sold diapers!? MS Diapers!
Search Algprithms
Binary Search Tree
Linked List
Sorting Algorithms

Recently uploaded (20)

PPTX
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx
PPTX
introduction to high performance computing
PPTX
Management Information system : MIS-e-Business Systems.pptx
PDF
distributed database system" (DDBS) is often used to refer to both the distri...
PPTX
Fundamentals of Mechanical Engineering.pptx
PDF
737-MAX_SRG.pdf student reference guides
PPTX
Module 8- Technological and Communication Skills.pptx
PPTX
CyberSecurity Mobile and Wireless Devices
PPTX
Feature types and data preprocessing steps
PPT
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
PPTX
"Array and Linked List in Data Structures with Types, Operations, Implementat...
PPTX
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PPTX
Current and future trends in Computer Vision.pptx
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PDF
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf
PPTX
Information Storage and Retrieval Techniques Unit III
PDF
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx
introduction to high performance computing
Management Information system : MIS-e-Business Systems.pptx
distributed database system" (DDBS) is often used to refer to both the distri...
Fundamentals of Mechanical Engineering.pptx
737-MAX_SRG.pdf student reference guides
Module 8- Technological and Communication Skills.pptx
CyberSecurity Mobile and Wireless Devices
Feature types and data preprocessing steps
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
"Array and Linked List in Data Structures with Types, Operations, Implementat...
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
Exploratory_Data_Analysis_Fundamentals.pdf
Current and future trends in Computer Vision.pptx
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf
Information Storage and Retrieval Techniques Unit III
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx

Graph Theory

  • 1. Introduction Basic Graph Theory Saksham Agrawal August 30, 2015 Saksham Agrawal Basic Graph Theory
  • 2. Introduction List Of Contents 1- Introduction To Graph 2- Definitions And Terminology 3- Graph Representation 4- Breadth First Search 5- Depth first search Saksham Agrawal Basic Graph Theory
  • 3. Introduction Introduction To Graphs In mathematics and computer science, graph theory is the study of graphs, which are mathematical structures used to model pairwise relations between objects. A ”graph” in this context is made up of ”vertices” or ”nodes” and lines called edges that connect them. 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. Graphs are one of the prime objects of study in discrete mathematics. Saksham Agrawal Basic Graph Theory
  • 4. Introduction Figure: A Typical Graph Saksham Agrawal Basic Graph Theory
  • 5. Introduction Definitions And Terminology Graphs are much clear when defined in mathematical terms. A Graph G (V, E), consists of two sets, Set of Vertices, V Set of Edges, E As the name suggest, V, is the set of vertices or, the set of all nodes in a given graph and E, is the set of all the edges between these nodes, or the associations between them. So, V denotes the number of nodes in a graph and E denotes the number of edges Saksham Agrawal Basic Graph Theory
  • 6. Introduction Figure: Types Of Graph Saksham Agrawal Basic Graph Theory
  • 7. Introduction Graph Representations ⇒ Adjacency Matrix Adjacency List Saksham Agrawal Basic Graph Theory
  • 8. Introduction Adjacency Matrix Figure: Adjacency Matrix Of Shown Graph Saksham Agrawal Basic Graph Theory
  • 9. Introduction Adjacency List Figure: Adjacency List Of Shown Graph Saksham Agrawal Basic Graph Theory
  • 10. Introduction Breadth first Search In BFS,we use a queue and we push the current vertex in the queue and the vertices which are adjacent to the current vertex using the adjacency list.We also maintain a visited array in which we record the visited vertices so as to prevent revisiting the same vertex.After we have pushed the adjacent vertices of a vertex we pop it out of the queue. Saksham Agrawal Basic Graph Theory
  • 12. Introduction Application of BFS BFS is mainly used in a connected graph in which we want to find the shortest path between 2 vertices.In this we also maintain a level array.We start from one of the 2 vertices and set its level as 0 and the set level of the adjacent vertices as level of parent+1 and traverse the graph in this until we reach the other vertex.The level of the vertex represents the shortest path between the two vertices. Saksham Agrawal Basic Graph Theory
  • 13. Introduction Depth First Search Algorithm:- When we see a maze in a newspaper or a magazine or anywhere else, the way we solve it is we take a path and go through it. If we find any junction or a crossroad, where we have a choice of paths to choose, we mark that junction, take up a path and traverse the whole route in your brain. If we see a dead end, we realize that this leads we now where so we come back to the junction we marked before and take up another path of the junction. See if that is also a dead end, else we continue to explore the, puzzle as this route contributes in reaching our destination.In code, we do this by recursion. Saksham Agrawal Basic Graph Theory
  • 14. Introduction DFS step-by-step process For a given set of vertices V = V1, V2,V3. . . , start with V1, and explore all the vertices that can possibly be reached from V1. Then go to the next vertex V2, if it hasn’t been visited, explore all the nodes reachable from V2, if not, go for V3. Similarly, go on picking up all the vertices one-by-one and explore as much as possible if it wasn’t visited at all. Saksham Agrawal Basic Graph Theory
  • 16. Introduction Application of DFS DFS is also used for finding the shortest path between two vertices.It is also used to do topological sorting. Topological Sorting:- It represents the logical order of doing something. For instance,we wear socks before shoes and after we tie laces.In the similar way in topological sorting a vertex appears only when all its adjacent vertices have already appeared.It is logical that topological sorting is done in only a directed graph.Obviously, the vertex with no child is one which appears in front.This is done using a stack and DFS on a graph. Saksham Agrawal Basic Graph Theory