SlideShare a Scribd company logo
Graph Representation
What is Graph ?

          A graph G consists of a finite set of
ordered pairs, called edges E, of certain
entities called vertices V.
   Edges are also called as arcs or links.
   Vertices are also called as nodes or points.
G=(V,E)

• A graph is a set of vertices and edges. A
  vertex may represent a state or a condition
  while the edge may represent a relation
  between two vertices.
Graph representation
Types of Representation
      Two ways are there for representing graph
  in the memory of a computer.
They are:-
  – Sequential Representation
  – Linked Representation
Sequential Representation
        Graphs can be represented through matrix
in system’s memory. This is sequential in nature.
This type of representation is called sequential
representation of graphs.
Types of Sequential Representation
•   Adjacency Matrix Representation
•   Incidence Matrix Representation
•   Circuit Matrix Representation
•   Cut Set Matrix Representation
•   Path Matrix Representation
Linked Representation
• Graphs can be represented through Linked List
  in system’s memory. This is Linked in nature.
  This type of representation is called Linked
  representation of graphs.
Types of Linked Representation
• Adjacency List Representation
Adjacency Matrix Representation

         The Adjacency matrix of a graph G
with n vertices is N x N. It is given by A=[aij].

   aij =1 if ith and jth vertices are adjacent.
       =0 if ith and jth vertices are not adjacent.
Examples
Graph representation
Incidence Matrix Representation
• The Incidence matrix of a graph G with N
  vertices and E edges is N x E.

     mij = 1 if ej is incident on vi
         = 0 otherwise
Examples



           e1 e2 e3 e4

       1
       2
       3
       4
Circuit Matrix Representation
• Circuit Matrix is represented by the number of
  different circuits T and the number of edges E
  is T x E in the graph. The Circuit Matrix C=Cij.

      Cij=1 if ith circuit includes jth edge.
         = 0 otherwise.
Examples
Cut Set Matrix Representation
• A Matrix S = Sij Rows correspond to cut sets
  and columns correspond to edges of the graph
  is defined to be a cut set matrix.

     Sij = 1 if the ith cut set contains the jth edge
         = 0 otherwise
Examples
Path Matrix Representation
• A path matrix is generally defined for a
  specific pair of vertices then the path matrix
  denoted as P(u,v) = Pij .

  Pij = 1 if the jth edge lies in the ith path
     = 0 otherwise
Examples
Adjacency List representation
• Adjacency List representation is one of the
  alternatives to adjacency matrix. It requires
  less amount of memory. For every vertex
  adjacency list stores a list of vertices, which
  are adjacent to current one.
Example
Graph representation
In Computer’s
• Even there are many mathematical
  representations…
           adjacency matrix
                 and
           adjacency lists
  are only used for representing graphs in
  computers.
Dense Graphs and Sparse Graphs

• Dense graph is a graph in which the number
  of edges is close to the maximal number of
  edges. The opposite, a graph with only a few
  edges, is a sparse graph.
Dense Graph
Sparse Graph
Advantages of adjacency matrix

Adjacency matrix is very convenient to work
with. Add (remove) an edge can be done in
O(1) time, the same time is required to check,
if there is an edge between two vertices.
Disadvantages of adjacency matrix
• Adjacency matrix consumes huge amount of
  memory for storing big graphs.
• Adjacency matrix requires huge efforts for
  adding/removing a vertex.
• In many algorithms you need to know the edges,
  adjacent to the current vertex. To draw out such
  an information from the adjacency matrix you
  have to scan over the corresponding row, which
  results in O(|V|) complexity.
Advantages of adjacency lists
• Adjacent list allows us to store graph in more
  compact form, than adjacency matrix.
• Adjacent list allows to get the list
  of adjacent vertices in O(1) time, which is a big
  advantage for some algorithms.
Disadvantages of adjacency lists
• Adding/removing an edge to/from adjacent list is
  not so easy as for adjacency matrix. It requires,
  on the average,O(|E| / |V|) time, which may
  result in cubical complexity for dense graphs to
  add all edges.
• If there is an edge between two vertices can be
  done in O(|E| / |V|) when list of adjacent
  vertices is unordered or O(log2(|E| / |V|)) when
  it is sorted. This operation stays quite cheap.
Disadvantages of adjacency lists (cont…)
• Adjacent list doesn't allow us to make an
  efficient implementation, if dynamically
  change of vertices number is required. Adding
  new vertex can be done in O(V), but removal
  results in O(E) complexity.
Conclusion
• Adjacency matrix is good for dense graphs.
• Adjacency lists is good for sparse graphs and
  also for changing the no of nodes.
Thank You!

More Related Content

PPTX
Graph data structure and algorithms
PPTX
Graphs in data structure
PPT
Graph isomorphism
PDF
Graph Data Structure
PPTX
Kruskal & Prim's Algorithm
PPTX
Spanning trees & applications
PPT
Graph algorithm
PPT
Prim's Algorithm on minimum spanning tree
Graph data structure and algorithms
Graphs in data structure
Graph isomorphism
Graph Data Structure
Kruskal & Prim's Algorithm
Spanning trees & applications
Graph algorithm
Prim's Algorithm on minimum spanning tree

What's hot (20)

PPT
Graphs In Data Structure
PPTX
Threaded Binary Tree
PPTX
Tree Traversal
PDF
Red black tree
PPT
Spanning trees
PPTX
Graph in data structure
PPTX
Data structure - Graph
PDF
All pairs shortest path algorithm
PPTX
Binary Tree Traversal
PPTX
Linked list
PPTX
Doubly Linked List
PPTX
Binary Tree in Data Structure
PPT
Trees
PPTX
Introduction to data structure ppt
PPTX
Balanced Tree (AVL Tree & Red-Black Tree)
PPTX
Hashing Technique In Data Structures
PDF
Algorithms Lecture 7: Graph Algorithms
PPT
Red black tree
PDF
Graphs In Data Structure
Threaded Binary Tree
Tree Traversal
Red black tree
Spanning trees
Graph in data structure
Data structure - Graph
All pairs shortest path algorithm
Binary Tree Traversal
Linked list
Doubly Linked List
Binary Tree in Data Structure
Trees
Introduction to data structure ppt
Balanced Tree (AVL Tree & Red-Black Tree)
Hashing Technique In Data Structures
Algorithms Lecture 7: Graph Algorithms
Red black tree
Ad

Viewers also liked (20)

PPTX
Matrix Representation Of Graph
PPT
Data structure computer graphs
PPTX
Data Structures - Lecture 10 [Graphs]
PPTX
Graph data structure
PPT
Graphs
PPT
Graph theory
PPT
Graphs in Data Structure
PPTX
Trees data structure
PDF
The Graph Traversal Programming Pattern
PPT
DATA STRUCTURES
PDF
Skiena algorithm 2007 lecture10 graph data strctures
PPTX
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
PPTX
Trees (data structure)
PPT
Hashing
PDF
Network topology
DOCX
PPT
Lecture 5b graphs and hashing
PPTX
2.4 Other Types of Graphs
Matrix Representation Of Graph
Data structure computer graphs
Data Structures - Lecture 10 [Graphs]
Graph data structure
Graphs
Graph theory
Graphs in Data Structure
Trees data structure
The Graph Traversal Programming Pattern
DATA STRUCTURES
Skiena algorithm 2007 lecture10 graph data strctures
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Trees (data structure)
Hashing
Network topology
Lecture 5b graphs and hashing
2.4 Other Types of Graphs
Ad

Similar to Graph representation (20)

PPTX
Representation of graph.pptx
PPTX
Graphs data structures
PPTX
BRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptx
PPTX
Unit II_Graph.pptxkgjrekjgiojtoiejhgnltegjte
PPTX
UNIT-VIQueueQueueQueueQueueQueueQueueQueueQueue.pptx
PPTX
Semantic Data Management in Graph Databases
PPT
Graph Introduction.ppt
PPTX
Graph theory ppt.pptx
PPTX
graphs presentation .pptx
PDF
Depth First Search and Breadth First Search
PPTX
Adjacency list
PDF
adjacencylist-130803205210-phpapp02 (1).pdf
PDF
The Graph Abstract Data Type-DATA STRUCTURE.pdf
PPTX
Semantic Data Management in Graph Databases: ESWC 2014 Tutorial
PDF
unit-3-dsa-graph introduction to grapgh and graph type
PPT
PDF
graph representation.pdf
PPTX
Representation of Graphs in Adjacency and Incidence Matrix.pptx
PPT
Basics of graph
PPTX
DATA STRUCTURES unit 4.pptx
Representation of graph.pptx
Graphs data structures
BRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptx
Unit II_Graph.pptxkgjrekjgiojtoiejhgnltegjte
UNIT-VIQueueQueueQueueQueueQueueQueueQueueQueue.pptx
Semantic Data Management in Graph Databases
Graph Introduction.ppt
Graph theory ppt.pptx
graphs presentation .pptx
Depth First Search and Breadth First Search
Adjacency list
adjacencylist-130803205210-phpapp02 (1).pdf
The Graph Abstract Data Type-DATA STRUCTURE.pdf
Semantic Data Management in Graph Databases: ESWC 2014 Tutorial
unit-3-dsa-graph introduction to grapgh and graph type
graph representation.pdf
Representation of Graphs in Adjacency and Incidence Matrix.pptx
Basics of graph
DATA STRUCTURES unit 4.pptx

More from Tech_MX (20)

PPTX
Virtual base class
PPTX
Uid
PPTX
Theory of estimation
PPTX
Templates in C++
PPT
String & its application
PPTX
Statistical quality__control_2
PPTX
Stack data structure
PPT
Stack Data Structure & It's Application
PPTX
Spss
PPTX
Set data structure 2
PPTX
Set data structure
PPTX
Real time Operating System
PPTX
Parsing
PPTX
Mouse interrupts (Assembly Language & C)
PPT
Motherboard of a pc
PPTX
More on Lex
PPTX
MultiMedia dbms
PPTX
Merging files (Data Structure)
PPTX
Memory dbms
PPTX
Linkers
Virtual base class
Uid
Theory of estimation
Templates in C++
String & its application
Statistical quality__control_2
Stack data structure
Stack Data Structure & It's Application
Spss
Set data structure 2
Set data structure
Real time Operating System
Parsing
Mouse interrupts (Assembly Language & C)
Motherboard of a pc
More on Lex
MultiMedia dbms
Merging files (Data Structure)
Memory dbms
Linkers

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPT
Teaching material agriculture food technology
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
Transforming Manufacturing operations through Intelligent Integrations
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
Empathic Computing: Creating Shared Understanding
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
MYSQL Presentation for SQL database connectivity
Reach Out and Touch Someone: Haptics and Empathic Computing
Advanced methodologies resolving dimensionality complications for autism neur...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
madgavkar20181017ppt McKinsey Presentation.pdf
cuic standard and advanced reporting.pdf
Advanced Soft Computing BINUS July 2025.pdf
Machine learning based COVID-19 study performance prediction
Teaching material agriculture food technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
GamePlan Trading System Review: Professional Trader's Honest Take
Transforming Manufacturing operations through Intelligent Integrations
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Mobile App Security Testing_ A Comprehensive Guide.pdf
20250228 LYD VKU AI Blended-Learning.pptx

Graph representation

  • 2. What is Graph ? A graph G consists of a finite set of ordered pairs, called edges E, of certain entities called vertices V. Edges are also called as arcs or links. Vertices are also called as nodes or points.
  • 3. G=(V,E) • A graph is a set of vertices and edges. A vertex may represent a state or a condition while the edge may represent a relation between two vertices.
  • 5. Types of Representation Two ways are there for representing graph in the memory of a computer. They are:- – Sequential Representation – Linked Representation
  • 6. Sequential Representation Graphs can be represented through matrix in system’s memory. This is sequential in nature. This type of representation is called sequential representation of graphs.
  • 7. Types of Sequential Representation • Adjacency Matrix Representation • Incidence Matrix Representation • Circuit Matrix Representation • Cut Set Matrix Representation • Path Matrix Representation
  • 8. Linked Representation • Graphs can be represented through Linked List in system’s memory. This is Linked in nature. This type of representation is called Linked representation of graphs.
  • 9. Types of Linked Representation • Adjacency List Representation
  • 10. Adjacency Matrix Representation The Adjacency matrix of a graph G with n vertices is N x N. It is given by A=[aij]. aij =1 if ith and jth vertices are adjacent. =0 if ith and jth vertices are not adjacent.
  • 13. Incidence Matrix Representation • The Incidence matrix of a graph G with N vertices and E edges is N x E. mij = 1 if ej is incident on vi = 0 otherwise
  • 14. Examples e1 e2 e3 e4 1 2 3 4
  • 15. Circuit Matrix Representation • Circuit Matrix is represented by the number of different circuits T and the number of edges E is T x E in the graph. The Circuit Matrix C=Cij. Cij=1 if ith circuit includes jth edge. = 0 otherwise.
  • 17. Cut Set Matrix Representation • A Matrix S = Sij Rows correspond to cut sets and columns correspond to edges of the graph is defined to be a cut set matrix. Sij = 1 if the ith cut set contains the jth edge = 0 otherwise
  • 19. Path Matrix Representation • A path matrix is generally defined for a specific pair of vertices then the path matrix denoted as P(u,v) = Pij . Pij = 1 if the jth edge lies in the ith path = 0 otherwise
  • 21. Adjacency List representation • Adjacency List representation is one of the alternatives to adjacency matrix. It requires less amount of memory. For every vertex adjacency list stores a list of vertices, which are adjacent to current one.
  • 24. In Computer’s • Even there are many mathematical representations… adjacency matrix and adjacency lists are only used for representing graphs in computers.
  • 25. Dense Graphs and Sparse Graphs • Dense graph is a graph in which the number of edges is close to the maximal number of edges. The opposite, a graph with only a few edges, is a sparse graph.
  • 28. Advantages of adjacency matrix Adjacency matrix is very convenient to work with. Add (remove) an edge can be done in O(1) time, the same time is required to check, if there is an edge between two vertices.
  • 29. Disadvantages of adjacency matrix • Adjacency matrix consumes huge amount of memory for storing big graphs. • Adjacency matrix requires huge efforts for adding/removing a vertex. • In many algorithms you need to know the edges, adjacent to the current vertex. To draw out such an information from the adjacency matrix you have to scan over the corresponding row, which results in O(|V|) complexity.
  • 30. Advantages of adjacency lists • Adjacent list allows us to store graph in more compact form, than adjacency matrix. • Adjacent list allows to get the list of adjacent vertices in O(1) time, which is a big advantage for some algorithms.
  • 31. Disadvantages of adjacency lists • Adding/removing an edge to/from adjacent list is not so easy as for adjacency matrix. It requires, on the average,O(|E| / |V|) time, which may result in cubical complexity for dense graphs to add all edges. • If there is an edge between two vertices can be done in O(|E| / |V|) when list of adjacent vertices is unordered or O(log2(|E| / |V|)) when it is sorted. This operation stays quite cheap.
  • 32. Disadvantages of adjacency lists (cont…) • Adjacent list doesn't allow us to make an efficient implementation, if dynamically change of vertices number is required. Adding new vertex can be done in O(V), but removal results in O(E) complexity.
  • 33. Conclusion • Adjacency matrix is good for dense graphs. • Adjacency lists is good for sparse graphs and also for changing the no of nodes.