SlideShare a Scribd company logo
Graphs Part-II
Topics in discussion

   Introduction to graphs
   Directed and undirected graphs
   Paths
   Connected graphs
   Trees
   Degree
   Isomorphic graphs
   Cut set
   Labeled graphs
   Hamiltonian circuit
Introduction to graphs


• Graph is a mathematical structure used to model pair wise
  relations between objects from a certain collection.




              Vertices

               Edges
Directed and undirected graphs
• A graph is said as directed graph whose definition makes
  reference to edges which are directed. Ie,
  edges which are ordered pair of vertices.



• A graph is said as undirected graph whose definition makes
  reference to unordered pairs of vertices as edges is known as
  an undirected graph.
Paths
• A path in a graph is a sequence of vertices such that from
  each of its vertices there is an edge to the next vertex in the
  sequence.




• The length of a path is the number of edges on it. The
  length can be zero for the case of a single vertex.
• A path may be infinite.
• A finite path always has a first vertex, called its start vertex,
  and a last vertex, called its end vertex.
• Both of them are called terminal vertices
  of the path.
• The other vertices in the path are internal vertices.

                   B
   A
            E                             Path= A B D C E

                   D
    C                                     A- Start vertex
                                          E- End vertex
Simple path
• A graph with no loops or multiple edges is called a simple graph.
• A path with no repeated vertices is called a simple path.
• The path from v1 to v4 is said to be simple path as
  vertices is touched more than once.
• The path from v1 to v4 is not simple as
   v1 is touched twice or looped.
  cycle:
• Simple path, except that the last vertex is the same as
  the first vertex. Its also known as a circuit or circular path.

           A                 B

                   E

           C                         Path= A E C A
                            D
Connected graph
• Two vertices vi, vj in a graph G is said to be connected only if
  there is a path in G between vi and vj.

• A undirected graph is said to be connected graph if every pair
  of distinct vertices vi, vj are connected.




                    Connected undirected graph
• In the case of an undirected graph, which is not connected,the
   maximal connected subgraph is called as a connected
   component or simply a component.




 The graph below has 3 connected components.
Connected directed graph

• A directed graph is said to be strongly connected only if every
  pair of distinct vertices vi, vj are connected.
• If there is a directed path from vi to vj then there must be a
  directed path from vj to vi.




              A strongly connected directed graph
• Strongly connected components of directed graph

• The below graph is not strongly connected but is said to
  possess two strongly connected components.
Trees
• A tree is defined to be a connected acyclic graph. The
  following properties are satisfied by a tree:
       There exist a path between any two vetices of the tree
       No cycles must be present in the tree ie, trees are
         acyclic.




         A Tree                            Not a tree
• Terms like parent, child, ancestors,level are missing but both
  the definitions of tree in datastructures and in graph share
  the same properties of connectedness and acyclicity.




      Both have the same properties of connectedness and
      acyclicity.
Degree
• The degree of vertex in an undirected graph is the number of
   edges incident to that vertex.
• A vertex with degree one is called pendent vertex or end
  vertex.
• A vertex with degree zero and hence has no incident edges is
  called an isolated vertex.

                                 A                             V1

                                           B
                                                           Isolated vertex
                                     Pendent vertex



      In the undirected graph vertex v3 has the degree 3
      And vertex v2 has the degree 2
Degree in directed graph

• Degree of directed graph has two types
      i. Indegree
               No of edges with their head towards the vertex.
      ii. Outdegree
               No of edges with their tail towards the vertex.

                                   Indegree of vertex v2 is 2

                                   and

                                   Outdegree of vertex v1 is 1.
Example:                                                   0
                  3
                                                           2
               0                                 1                  2
                                                 3                  3
      3    1              2   3             3          4        5       6
               31
               G                            1          1   G2   1       1
                      3
                                  0    in:1, out: 1
     Directed graph
     in-degree
     out-degree                   1    in: 1, out: 2



                                  2    in: 1, out: 0

                                  G3
Isomorphic graphs
• Isomorphism
   – Two graphs are isomorphic, if they are structurally
     identical, Which means that they correspond in all
     structural details.
   – Formal vertex-to-vertex and edge –to-edge
     correspondence is called isomorphism.

• Two graph are said to be isomorphic if
    They have the same no of vertices.
    They have the same number of edges.
    They have an equal number of vertices with a given
     degree.
Verifying Isomorphic graph



                                      Graph B



                       Graph A


 Vertices(A) :   a        b      c              d     e


 Vertices(B):    q        p       r              s     t
  Degree of      2        3      3              3     1
  vertices:
  Edges(A):      e1      e2      e3             e4    e5    e6
  Edges(B):      e’1     e’4     e’3            e’2   e’5   e’6
Examples for non isomorphic graphs :

  i)

              u2                            v2
                   u3
        u1                             v1             v3


         u5        u4                            v4

  1st graph has more edges than 2nd.
ii) 2nd graph has vertex of degree 1, 1st graph
   doesn't.



            u2                             v2
                 u3                               v3
     u1                             v1


      u5         u4                  v5           v4
iii) 1st graph has 2 degree 1 vertices, 4 degree 2 vertex and 2
          degree 3 vertices.
          2nd graph has 3 degree 1 vertices, 3 degree 2 vertex and 3
          degree 3 vertices.


u1     u2    u3      u4    u5    u6     v1    v2    v3     v4     v5   v6



       u7     u8           u9                 v7           v8     v9
Cut set
• Cut set is a connected graph G is the set of edges whose
  removal from G leaves G disconnected, Provided the removal
  of no proper sebset of these edges disconnects the graph G.
• Cut set are also called proper cut set or minimal cut set.
• If one can remove a vertex (and all incident edges) and
  produce a graph with more components, the vertex is called a
   cut vertex or articulation point.
• Similarly if removal of an edge creates more components the
  edge is called a cut edge or bridge.
• The cut-set of the cut is the set of edges whose end points are
   in different subsets of the partition.
   Edges are said to be crossing the cut if they are in its cut-set.
Labeled graph
• A graph G is called a labeled graph if its edges and/or vertices
  are assigned some data.

• A graph labeling is the assignment of labels, traditionally
  represented by integers, to the edges or vertices, or both, of a
  graph.

• If the edge e is assigned a non-negative number then it is
  called the weight or length of the edge e.
• Vertex-labeled graph
      • If all the vertices in a graph are given a label then it is
        vertex-labeled graph




• Edge-labeled graph
      • If all the Edges in a graph are given a label then it is
        Edge-labeled graph
Hamiltonian circuit
• Hamiltonian paths and circuits are named after the
   mathematician ,William Rowan Hamilton.
• A Hamiltonian circuit in a connected graph is defined as a
   closed walk that traverses every vertex of G exactly once.
   also called Hamiltonian cycles.
• It is called as circuit if it includes every vertex of G. If any edge
   is removed then it is Hamiltonian path.


                               Hamiltonian circuit:
                               {v1,v3,v4,v2,v6,v5,v1}
                    The above is a Hamiltonian circuit
            as each and every vertex is traversed once
   And completes the circuit by ending in starting point.
• A Hamiltonian path or traceable path is a path that visits each
  vertex exactly once. Its also called as a traceable graph.


                   a                b

                                        Hamiltonian path


                   d                c

• A graph is Hamiltonian-connected if for every pair of vertices
  there is a Hamiltonian path between the two vertices.
Thank you
Ad

More Related Content

What's hot (20)

Trees data structure
Trees data structureTrees data structure
Trees data structure
Sumit Gupta
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
Abrish06
 
Bottom up parser
Bottom up parserBottom up parser
Bottom up parser
Akshaya Arunan
 
Graph representation
Graph representationGraph representation
Graph representation
Tech_MX
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
Julie Iskander
 
Red black tree
Red black treeRed black tree
Red black tree
Rajendran
 
Matrix Representation Of Graph
Matrix Representation Of GraphMatrix Representation Of Graph
Matrix Representation Of Graph
Abhishek Pachisia
 
Graph Data Structure
Graph Data StructureGraph Data Structure
Graph Data Structure
Keno benti
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
sagar yadav
 
AVL Tree Data Structure
AVL Tree Data StructureAVL Tree Data Structure
AVL Tree Data Structure
Afaq Mansoor Khan
 
17. Trees and Graphs
17. Trees and Graphs17. Trees and Graphs
17. Trees and Graphs
Intro C# Book
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
Krish_ver2
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
Hossain Md Shakhawat
 
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
Anandhasilambarasan D
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structure
Vardhil Patel
 
Data Structures : hashing (1)
Data Structures : hashing (1)Data Structures : hashing (1)
Data Structures : hashing (1)
Home
 
Data Structures - Lecture 10 [Graphs]
Data Structures - Lecture 10 [Graphs]Data Structures - Lecture 10 [Graphs]
Data Structures - Lecture 10 [Graphs]
Muhammad Hammad Waseem
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
MAHALAKSHMI P
 
Binary Tree in Data Structure
Binary Tree in Data StructureBinary Tree in Data Structure
Binary Tree in Data Structure
Meghaj Mallick
 
INTERNAL STRUCTURE OF 8086 MICROPROCESSOR
INTERNAL STRUCTURE OF  8086 MICROPROCESSORINTERNAL STRUCTURE OF  8086 MICROPROCESSOR
INTERNAL STRUCTURE OF 8086 MICROPROCESSOR
Md. Hasnat Shoheb
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
Sumit Gupta
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
Abrish06
 
Graph representation
Graph representationGraph representation
Graph representation
Tech_MX
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
Julie Iskander
 
Red black tree
Red black treeRed black tree
Red black tree
Rajendran
 
Matrix Representation Of Graph
Matrix Representation Of GraphMatrix Representation Of Graph
Matrix Representation Of Graph
Abhishek Pachisia
 
Graph Data Structure
Graph Data StructureGraph Data Structure
Graph Data Structure
Keno benti
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
sagar yadav
 
17. Trees and Graphs
17. Trees and Graphs17. Trees and Graphs
17. Trees and Graphs
Intro C# Book
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
Krish_ver2
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structure
Vardhil Patel
 
Data Structures : hashing (1)
Data Structures : hashing (1)Data Structures : hashing (1)
Data Structures : hashing (1)
Home
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
MAHALAKSHMI P
 
Binary Tree in Data Structure
Binary Tree in Data StructureBinary Tree in Data Structure
Binary Tree in Data Structure
Meghaj Mallick
 
INTERNAL STRUCTURE OF 8086 MICROPROCESSOR
INTERNAL STRUCTURE OF  8086 MICROPROCESSORINTERNAL STRUCTURE OF  8086 MICROPROCESSOR
INTERNAL STRUCTURE OF 8086 MICROPROCESSOR
Md. Hasnat Shoheb
 

Viewers also liked (20)

Lecture8 data structure(graph)
Lecture8 data structure(graph)Lecture8 data structure(graph)
Lecture8 data structure(graph)
Taibah University, College of Computer Science & Engineering
 
Data structure computer graphs
Data structure computer graphsData structure computer graphs
Data structure computer graphs
Kumar
 
Graph theory 1
Graph theory 1Graph theory 1
Graph theory 1
Tech_MX
 
Problem Solving with Algorithms and Data Structure - Graphs
Problem Solving with Algorithms and Data Structure - GraphsProblem Solving with Algorithms and Data Structure - Graphs
Problem Solving with Algorithms and Data Structure - Graphs
Yi-Lung Tsai
 
Graph theory
Graph theoryGraph theory
Graph theory
Kumar
 
Introduction to Graph Theory
Introduction to Graph TheoryIntroduction to Graph Theory
Introduction to Graph Theory
Premsankar Chakkingal
 
Minimum spanning Tree
Minimum spanning TreeMinimum spanning Tree
Minimum spanning Tree
Narendra Singh Patel
 
Graphs in Data Structure
 Graphs in Data Structure Graphs in Data Structure
Graphs in Data Structure
hafsa komal
 
graph theory
graph theory graph theory
graph theory
ganith2k13
 
introduction to graph theory
introduction to graph theoryintroduction to graph theory
introduction to graph theory
Chuckie Balbuena
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
bca2010
 
Connectivity of graph
Connectivity of graphConnectivity of graph
Connectivity of graph
Shameer P Hamsa
 
Unit ix graph
Unit   ix    graph Unit   ix    graph
Unit ix graph
Tribhuvan University
 
Analysis and design of algorithms part 3
Analysis and design of algorithms part 3Analysis and design of algorithms part 3
Analysis and design of algorithms part 3
Deepak John
 
7. intersection of two graphs touchpad
7. intersection of two graphs touchpad7. intersection of two graphs touchpad
7. intersection of two graphs touchpad
Media4math
 
Constants
ConstantsConstants
Constants
Tech_MX
 
Trends and technologies in system softwares
Trends and technologies in system softwaresTrends and technologies in system softwares
Trends and technologies in system softwares
Tech_MX
 
14.jun.2012
14.jun.201214.jun.2012
14.jun.2012
Tech_MX
 
09 binary-trees
09 binary-trees09 binary-trees
09 binary-trees
Tech_MX
 
Mutable and immutable classes
Mutable and  immutable classesMutable and  immutable classes
Mutable and immutable classes
Tech_MX
 
Data structure computer graphs
Data structure computer graphsData structure computer graphs
Data structure computer graphs
Kumar
 
Graph theory 1
Graph theory 1Graph theory 1
Graph theory 1
Tech_MX
 
Problem Solving with Algorithms and Data Structure - Graphs
Problem Solving with Algorithms and Data Structure - GraphsProblem Solving with Algorithms and Data Structure - Graphs
Problem Solving with Algorithms and Data Structure - Graphs
Yi-Lung Tsai
 
Graph theory
Graph theoryGraph theory
Graph theory
Kumar
 
Graphs in Data Structure
 Graphs in Data Structure Graphs in Data Structure
Graphs in Data Structure
hafsa komal
 
introduction to graph theory
introduction to graph theoryintroduction to graph theory
introduction to graph theory
Chuckie Balbuena
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
bca2010
 
Analysis and design of algorithms part 3
Analysis and design of algorithms part 3Analysis and design of algorithms part 3
Analysis and design of algorithms part 3
Deepak John
 
7. intersection of two graphs touchpad
7. intersection of two graphs touchpad7. intersection of two graphs touchpad
7. intersection of two graphs touchpad
Media4math
 
Constants
ConstantsConstants
Constants
Tech_MX
 
Trends and technologies in system softwares
Trends and technologies in system softwaresTrends and technologies in system softwares
Trends and technologies in system softwares
Tech_MX
 
14.jun.2012
14.jun.201214.jun.2012
14.jun.2012
Tech_MX
 
09 binary-trees
09 binary-trees09 binary-trees
09 binary-trees
Tech_MX
 
Mutable and immutable classes
Mutable and  immutable classesMutable and  immutable classes
Mutable and immutable classes
Tech_MX
 
Ad

Similar to Graph data structure (20)

graphssssssssssssssssssssssssssssss.pptx
graphssssssssssssssssssssssssssssss.pptxgraphssssssssssssssssssssssssssssss.pptx
graphssssssssssssssssssssssssssssss.pptx
FarhanAli766749
 
Graphs in c language
Graphs in c languageGraphs in c language
Graphs in c language
SARITHA REDDY
 
Unit 2: All
Unit 2: AllUnit 2: All
Unit 2: All
Hector Zenil
 
Graph
GraphGraph
Graph
sakthisree
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data Structure
Anuj Modi
 
Lecture 1--Graph Algorithms -- Basics.pptx
Lecture 1--Graph Algorithms -- Basics.pptxLecture 1--Graph Algorithms -- Basics.pptx
Lecture 1--Graph Algorithms -- Basics.pptx
ChandanGiri21
 
Graphs (Models & Terminology)
Graphs (Models & Terminology)Graphs (Models & Terminology)
Graphs (Models & Terminology)
zunaira saleem
 
CS-102 Data Structure lectures on Graphs
CS-102 Data Structure lectures on GraphsCS-102 Data Structure lectures on Graphs
CS-102 Data Structure lectures on Graphs
ssuser034ce1
 
CS-102 Data Structure lectures on Graphs
CS-102 Data Structure lectures on GraphsCS-102 Data Structure lectures on Graphs
CS-102 Data Structure lectures on Graphs
ssuser034ce1
 
ppt 1.pptx
ppt 1.pptxppt 1.pptx
ppt 1.pptx
ShasidharaniD
 
Chapter 6-DS(Introduction to Graph and its terminologies).pptx
Chapter 6-DS(Introduction to Graph and its terminologies).pptxChapter 6-DS(Introduction to Graph and its terminologies).pptx
Chapter 6-DS(Introduction to Graph and its terminologies).pptx
nasalapurepallavi272
 
Graph theory
Graph theoryGraph theory
Graph theory
grahamwell
 
Introduction to Graph Theory
Introduction to Graph  TheoryIntroduction to Graph  Theory
Introduction to Graph Theory
Manash Kumar Mondal
 
Class01_Computer_Contest_Level_3_Notes_Sep_07 - Copy.pdf
Class01_Computer_Contest_Level_3_Notes_Sep_07 - Copy.pdfClass01_Computer_Contest_Level_3_Notes_Sep_07 - Copy.pdf
Class01_Computer_Contest_Level_3_Notes_Sep_07 - Copy.pdf
ChristianKapsales1
 
Ass. (3)graph d.m
Ass. (3)graph d.mAss. (3)graph d.m
Ass. (3)graph d.m
Syed Umair
 
An introduction to the graph theory in discrete mathematics
An introduction to the graph theory in discrete mathematicsAn introduction to the graph theory in discrete mathematics
An introduction to the graph theory in discrete mathematics
hassanbokhari14
 
Isomorphic graph
Isomorphic graphIsomorphic graph
Isomorphic graph
umair khan
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
Pooja Bhojwani
 
Graphs in data structures
Graphs in data structuresGraphs in data structures
Graphs in data structures
Savit Chandra
 
Elements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptxElements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptx
miki304759
 
graphssssssssssssssssssssssssssssss.pptx
graphssssssssssssssssssssssssssssss.pptxgraphssssssssssssssssssssssssssssss.pptx
graphssssssssssssssssssssssssssssss.pptx
FarhanAli766749
 
Graphs in c language
Graphs in c languageGraphs in c language
Graphs in c language
SARITHA REDDY
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data Structure
Anuj Modi
 
Lecture 1--Graph Algorithms -- Basics.pptx
Lecture 1--Graph Algorithms -- Basics.pptxLecture 1--Graph Algorithms -- Basics.pptx
Lecture 1--Graph Algorithms -- Basics.pptx
ChandanGiri21
 
Graphs (Models & Terminology)
Graphs (Models & Terminology)Graphs (Models & Terminology)
Graphs (Models & Terminology)
zunaira saleem
 
CS-102 Data Structure lectures on Graphs
CS-102 Data Structure lectures on GraphsCS-102 Data Structure lectures on Graphs
CS-102 Data Structure lectures on Graphs
ssuser034ce1
 
CS-102 Data Structure lectures on Graphs
CS-102 Data Structure lectures on GraphsCS-102 Data Structure lectures on Graphs
CS-102 Data Structure lectures on Graphs
ssuser034ce1
 
Chapter 6-DS(Introduction to Graph and its terminologies).pptx
Chapter 6-DS(Introduction to Graph and its terminologies).pptxChapter 6-DS(Introduction to Graph and its terminologies).pptx
Chapter 6-DS(Introduction to Graph and its terminologies).pptx
nasalapurepallavi272
 
Class01_Computer_Contest_Level_3_Notes_Sep_07 - Copy.pdf
Class01_Computer_Contest_Level_3_Notes_Sep_07 - Copy.pdfClass01_Computer_Contest_Level_3_Notes_Sep_07 - Copy.pdf
Class01_Computer_Contest_Level_3_Notes_Sep_07 - Copy.pdf
ChristianKapsales1
 
Ass. (3)graph d.m
Ass. (3)graph d.mAss. (3)graph d.m
Ass. (3)graph d.m
Syed Umair
 
An introduction to the graph theory in discrete mathematics
An introduction to the graph theory in discrete mathematicsAn introduction to the graph theory in discrete mathematics
An introduction to the graph theory in discrete mathematics
hassanbokhari14
 
Isomorphic graph
Isomorphic graphIsomorphic graph
Isomorphic graph
umair khan
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
Pooja Bhojwani
 
Graphs in data structures
Graphs in data structuresGraphs in data structures
Graphs in data structures
Savit Chandra
 
Elements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptxElements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptx
miki304759
 
Ad

More from Tech_MX (20)

Virtual base class
Virtual base classVirtual base class
Virtual base class
Tech_MX
 
Uid
UidUid
Uid
Tech_MX
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimation
Tech_MX
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
Tech_MX
 
String & its application
String & its applicationString & its application
String & its application
Tech_MX
 
Statistical quality__control_2
Statistical  quality__control_2Statistical  quality__control_2
Statistical quality__control_2
Tech_MX
 
Stack data structure
Stack data structureStack data structure
Stack data structure
Tech_MX
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application
Tech_MX
 
Spss
SpssSpss
Spss
Tech_MX
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
Tech_MX
 
Set data structure 2
Set data structure 2Set data structure 2
Set data structure 2
Tech_MX
 
Set data structure
Set data structure Set data structure
Set data structure
Tech_MX
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
Tech_MX
 
Parsing
ParsingParsing
Parsing
Tech_MX
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)
Tech_MX
 
Motherboard of a pc
Motherboard of a pcMotherboard of a pc
Motherboard of a pc
Tech_MX
 
More on Lex
More on LexMore on Lex
More on Lex
Tech_MX
 
MultiMedia dbms
MultiMedia dbmsMultiMedia dbms
MultiMedia dbms
Tech_MX
 
Merging files (Data Structure)
Merging files (Data Structure)Merging files (Data Structure)
Merging files (Data Structure)
Tech_MX
 
Memory dbms
Memory dbmsMemory dbms
Memory dbms
Tech_MX
 
Virtual base class
Virtual base classVirtual base class
Virtual base class
Tech_MX
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimation
Tech_MX
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
Tech_MX
 
String & its application
String & its applicationString & its application
String & its application
Tech_MX
 
Statistical quality__control_2
Statistical  quality__control_2Statistical  quality__control_2
Statistical quality__control_2
Tech_MX
 
Stack data structure
Stack data structureStack data structure
Stack data structure
Tech_MX
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application
Tech_MX
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
Tech_MX
 
Set data structure 2
Set data structure 2Set data structure 2
Set data structure 2
Tech_MX
 
Set data structure
Set data structure Set data structure
Set data structure
Tech_MX
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
Tech_MX
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)
Tech_MX
 
Motherboard of a pc
Motherboard of a pcMotherboard of a pc
Motherboard of a pc
Tech_MX
 
More on Lex
More on LexMore on Lex
More on Lex
Tech_MX
 
MultiMedia dbms
MultiMedia dbmsMultiMedia dbms
MultiMedia dbms
Tech_MX
 
Merging files (Data Structure)
Merging files (Data Structure)Merging files (Data Structure)
Merging files (Data Structure)
Tech_MX
 
Memory dbms
Memory dbmsMemory dbms
Memory dbms
Tech_MX
 

Recently uploaded (20)

Middle East and Africa Cybersecurity Market Trends and Growth Analysis
Middle East and Africa Cybersecurity Market Trends and Growth Analysis Middle East and Africa Cybersecurity Market Trends and Growth Analysis
Middle East and Africa Cybersecurity Market Trends and Growth Analysis
Preeti Jha
 
Top Hyper-Casual Game Studio Services
Top  Hyper-Casual  Game  Studio ServicesTop  Hyper-Casual  Game  Studio Services
Top Hyper-Casual Game Studio Services
Nova Carter
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
AI and Gender: Decoding the Sociological Impact
AI and Gender: Decoding the Sociological ImpactAI and Gender: Decoding the Sociological Impact
AI and Gender: Decoding the Sociological Impact
SaikatBasu37
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
How Top Companies Benefit from Outsourcing
How Top Companies Benefit from OutsourcingHow Top Companies Benefit from Outsourcing
How Top Companies Benefit from Outsourcing
Nascenture
 
DNF 2.0 Implementations Challenges in Nepal
DNF 2.0 Implementations Challenges in NepalDNF 2.0 Implementations Challenges in Nepal
DNF 2.0 Implementations Challenges in Nepal
ICT Frame Magazine Pvt. Ltd.
 
Secondary Storage for a microcontroller system
Secondary Storage for a microcontroller systemSecondary Storage for a microcontroller system
Secondary Storage for a microcontroller system
fizarcse
 
Google DeepMind’s New AI Coding Agent AlphaEvolve.pdf
Google DeepMind’s New AI Coding Agent AlphaEvolve.pdfGoogle DeepMind’s New AI Coding Agent AlphaEvolve.pdf
Google DeepMind’s New AI Coding Agent AlphaEvolve.pdf
derrickjswork
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
UXPA Boston
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
OpenAI Just Announced Codex: A cloud engineering agent that excels in handlin...
OpenAI Just Announced Codex: A cloud engineering agent that excels in handlin...OpenAI Just Announced Codex: A cloud engineering agent that excels in handlin...
OpenAI Just Announced Codex: A cloud engineering agent that excels in handlin...
SOFTTECHHUB
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Alan Dix
 
Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025
Damco Salesforce Services
 
Cybersecurity Tools and Technologies - Microsoft Certificate
Cybersecurity Tools and Technologies - Microsoft CertificateCybersecurity Tools and Technologies - Microsoft Certificate
Cybersecurity Tools and Technologies - Microsoft Certificate
VICTOR MAESTRE RAMIREZ
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
Middle East and Africa Cybersecurity Market Trends and Growth Analysis
Middle East and Africa Cybersecurity Market Trends and Growth Analysis Middle East and Africa Cybersecurity Market Trends and Growth Analysis
Middle East and Africa Cybersecurity Market Trends and Growth Analysis
Preeti Jha
 
Top Hyper-Casual Game Studio Services
Top  Hyper-Casual  Game  Studio ServicesTop  Hyper-Casual  Game  Studio Services
Top Hyper-Casual Game Studio Services
Nova Carter
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
AI and Gender: Decoding the Sociological Impact
AI and Gender: Decoding the Sociological ImpactAI and Gender: Decoding the Sociological Impact
AI and Gender: Decoding the Sociological Impact
SaikatBasu37
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
How Top Companies Benefit from Outsourcing
How Top Companies Benefit from OutsourcingHow Top Companies Benefit from Outsourcing
How Top Companies Benefit from Outsourcing
Nascenture
 
Secondary Storage for a microcontroller system
Secondary Storage for a microcontroller systemSecondary Storage for a microcontroller system
Secondary Storage for a microcontroller system
fizarcse
 
Google DeepMind’s New AI Coding Agent AlphaEvolve.pdf
Google DeepMind’s New AI Coding Agent AlphaEvolve.pdfGoogle DeepMind’s New AI Coding Agent AlphaEvolve.pdf
Google DeepMind’s New AI Coding Agent AlphaEvolve.pdf
derrickjswork
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
UXPA Boston
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
OpenAI Just Announced Codex: A cloud engineering agent that excels in handlin...
OpenAI Just Announced Codex: A cloud engineering agent that excels in handlin...OpenAI Just Announced Codex: A cloud engineering agent that excels in handlin...
OpenAI Just Announced Codex: A cloud engineering agent that excels in handlin...
SOFTTECHHUB
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Alan Dix
 
Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025
Damco Salesforce Services
 
Cybersecurity Tools and Technologies - Microsoft Certificate
Cybersecurity Tools and Technologies - Microsoft CertificateCybersecurity Tools and Technologies - Microsoft Certificate
Cybersecurity Tools and Technologies - Microsoft Certificate
VICTOR MAESTRE RAMIREZ
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 

Graph data structure

  • 2. Topics in discussion  Introduction to graphs  Directed and undirected graphs  Paths  Connected graphs  Trees  Degree  Isomorphic graphs  Cut set  Labeled graphs  Hamiltonian circuit
  • 3. Introduction to graphs • Graph is a mathematical structure used to model pair wise relations between objects from a certain collection. Vertices Edges
  • 4. Directed and undirected graphs • A graph is said as directed graph whose definition makes reference to edges which are directed. Ie, edges which are ordered pair of vertices. • A graph is said as undirected graph whose definition makes reference to unordered pairs of vertices as edges is known as an undirected graph.
  • 5. Paths • A path in a graph is a sequence of vertices such that from each of its vertices there is an edge to the next vertex in the sequence. • The length of a path is the number of edges on it. The length can be zero for the case of a single vertex.
  • 6. • A path may be infinite. • A finite path always has a first vertex, called its start vertex, and a last vertex, called its end vertex. • Both of them are called terminal vertices of the path. • The other vertices in the path are internal vertices. B A E Path= A B D C E D C A- Start vertex E- End vertex
  • 7. Simple path • A graph with no loops or multiple edges is called a simple graph. • A path with no repeated vertices is called a simple path. • The path from v1 to v4 is said to be simple path as vertices is touched more than once. • The path from v1 to v4 is not simple as v1 is touched twice or looped. cycle: • Simple path, except that the last vertex is the same as the first vertex. Its also known as a circuit or circular path. A B E C Path= A E C A D
  • 8. Connected graph • Two vertices vi, vj in a graph G is said to be connected only if there is a path in G between vi and vj. • A undirected graph is said to be connected graph if every pair of distinct vertices vi, vj are connected. Connected undirected graph
  • 9. • In the case of an undirected graph, which is not connected,the maximal connected subgraph is called as a connected component or simply a component. The graph below has 3 connected components.
  • 10. Connected directed graph • A directed graph is said to be strongly connected only if every pair of distinct vertices vi, vj are connected. • If there is a directed path from vi to vj then there must be a directed path from vj to vi. A strongly connected directed graph
  • 11. • Strongly connected components of directed graph • The below graph is not strongly connected but is said to possess two strongly connected components.
  • 12. Trees • A tree is defined to be a connected acyclic graph. The following properties are satisfied by a tree: There exist a path between any two vetices of the tree No cycles must be present in the tree ie, trees are acyclic. A Tree Not a tree
  • 13. • Terms like parent, child, ancestors,level are missing but both the definitions of tree in datastructures and in graph share the same properties of connectedness and acyclicity. Both have the same properties of connectedness and acyclicity.
  • 14. Degree • The degree of vertex in an undirected graph is the number of edges incident to that vertex. • A vertex with degree one is called pendent vertex or end vertex. • A vertex with degree zero and hence has no incident edges is called an isolated vertex. A V1 B Isolated vertex Pendent vertex In the undirected graph vertex v3 has the degree 3 And vertex v2 has the degree 2
  • 15. Degree in directed graph • Degree of directed graph has two types i. Indegree No of edges with their head towards the vertex. ii. Outdegree No of edges with their tail towards the vertex. Indegree of vertex v2 is 2 and Outdegree of vertex v1 is 1.
  • 16. Example: 0 3 2 0 1 2 3 3 3 1 2 3 3 4 5 6 31 G 1 1 G2 1 1 3 0 in:1, out: 1 Directed graph in-degree out-degree 1 in: 1, out: 2 2 in: 1, out: 0 G3
  • 17. Isomorphic graphs • Isomorphism – Two graphs are isomorphic, if they are structurally identical, Which means that they correspond in all structural details. – Formal vertex-to-vertex and edge –to-edge correspondence is called isomorphism. • Two graph are said to be isomorphic if  They have the same no of vertices.  They have the same number of edges.  They have an equal number of vertices with a given degree.
  • 18. Verifying Isomorphic graph Graph B Graph A Vertices(A) : a b c d e Vertices(B): q p r s t Degree of 2 3 3 3 1 vertices: Edges(A): e1 e2 e3 e4 e5 e6 Edges(B): e’1 e’4 e’3 e’2 e’5 e’6
  • 19. Examples for non isomorphic graphs : i) u2 v2 u3 u1 v1 v3 u5 u4 v4 1st graph has more edges than 2nd.
  • 20. ii) 2nd graph has vertex of degree 1, 1st graph doesn't. u2 v2 u3 v3 u1 v1 u5 u4 v5 v4
  • 21. iii) 1st graph has 2 degree 1 vertices, 4 degree 2 vertex and 2 degree 3 vertices. 2nd graph has 3 degree 1 vertices, 3 degree 2 vertex and 3 degree 3 vertices. u1 u2 u3 u4 u5 u6 v1 v2 v3 v4 v5 v6 u7 u8 u9 v7 v8 v9
  • 22. Cut set • Cut set is a connected graph G is the set of edges whose removal from G leaves G disconnected, Provided the removal of no proper sebset of these edges disconnects the graph G. • Cut set are also called proper cut set or minimal cut set.
  • 23. • If one can remove a vertex (and all incident edges) and produce a graph with more components, the vertex is called a cut vertex or articulation point. • Similarly if removal of an edge creates more components the edge is called a cut edge or bridge. • The cut-set of the cut is the set of edges whose end points are in different subsets of the partition. Edges are said to be crossing the cut if they are in its cut-set.
  • 24. Labeled graph • A graph G is called a labeled graph if its edges and/or vertices are assigned some data. • A graph labeling is the assignment of labels, traditionally represented by integers, to the edges or vertices, or both, of a graph. • If the edge e is assigned a non-negative number then it is called the weight or length of the edge e.
  • 25. • Vertex-labeled graph • If all the vertices in a graph are given a label then it is vertex-labeled graph • Edge-labeled graph • If all the Edges in a graph are given a label then it is Edge-labeled graph
  • 26. Hamiltonian circuit • Hamiltonian paths and circuits are named after the mathematician ,William Rowan Hamilton. • A Hamiltonian circuit in a connected graph is defined as a closed walk that traverses every vertex of G exactly once. also called Hamiltonian cycles. • It is called as circuit if it includes every vertex of G. If any edge is removed then it is Hamiltonian path. Hamiltonian circuit: {v1,v3,v4,v2,v6,v5,v1} The above is a Hamiltonian circuit as each and every vertex is traversed once And completes the circuit by ending in starting point.
  • 27. • A Hamiltonian path or traceable path is a path that visits each vertex exactly once. Its also called as a traceable graph. a b Hamiltonian path d c • A graph is Hamiltonian-connected if for every pair of vertices there is a Hamiltonian path between the two vertices.
  翻译: