{"id":11978,"date":"2023-01-30T07:34:50","date_gmt":"2023-01-30T07:34:50","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=11978"},"modified":"2023-02-02T05:37:30","modified_gmt":"2023-02-02T05:37:30","slug":"graph-in-data-structure","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/","title":{"rendered":"Graph in Data Structure: Definition, Types and Application"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167354-Graph%20in%20Data%20Structure.jpg\" alt=\"\" \/><\/p>\n<p>In this article, we are going to study what is graph in data structure, the types of graph in data structure, the application of graph in data structure and also the techniques to perform graph traversal in data structure in the types of graph in data structure.<\/p>\n<p>We will start by looking out to define graph in data structure and progress step by step with all the sections discussed in a graph, which proves to be one of the most important data structures in terms of the application of graph in data structure.<\/p>\n<h2>What is Graph in Data Structure?<\/h2>\n<p>We can define a graph in data structure that represents relationships between the objects that are a part of the graph data structure. It can be assumed as a flow structure that has networks in between them with the help of vertices and edges.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167480-Graph%20in%20Data%20Structure1.png\" alt=\"\" \/><\/p>\n<p>Now vertices and edges might be jargon that can be confusing to beginners so the definition of the two can be said:<\/p>\n<p><strong>1. Vertex:<\/strong> Also referred to as Node, represents the entity or object that is a part of the network that builds a graph data structure.<br \/>\n<strong>2. Edge:<\/strong> The connection between the vertex, or nodes, can be defined as an edge. A graph has multiple edges joining or connecting the vertices to each other.<\/p>\n<p>A general example can be Facebook where two individuals can befriend each other making it a two-way mutual connection that can be relative to an Undirected Graph unlike in Twitter or Instagram where an individual can follow the other individual irrespective of the other individual following which resembles a directed graph.<\/p>\n<h3>Terminologies &#8211; Graph Data Structure<\/h3>\n<p>Now that we have some idea of seeing what is graph in data structure and how we can define a graph in data structure. Let us look at some of the important terminologies in a graph.<\/p>\n<p><strong>Multiple Edges:<\/strong> If two vertices are joined by two or more edges.  <\/p>\n<p><strong>Self-Loop:<\/strong> Edge whose endpoints are a single vertex. A vertex being joined with itself result in a self-loop.<\/p>\n<p><strong>Adjacent Nodes:<\/strong> Vertices that are both endpoints of the same edge.<\/p>\n<p><strong>Adjacent Edges:<\/strong> Adjacent edges are two distinct edges that share an end vertex.<\/p>\n<p><strong>Edge Cost:<\/strong> The value that an edge holds to travel to another vertex. It is also known as Edge Weight.<br \/>\n<strong>Degree of a Node:<\/strong> The degree of a node states the number of vertexes connected to it.<br \/>\n<strong>In-degree of a Node:<\/strong> The number of edges directing inwards on a vertex is called the in-degree of the vertex<\/p>\n<p><strong>Out-degree of a Node:<\/strong> The number of edges directing outwards from a node is called the out-degree of a vertex.<br \/>\n<strong>Path:<\/strong> A sequence of nodes connected through edges in a graph data structure is known as a path.<br \/>\n<strong>Cycles:<\/strong>  A cycle is a path in the graph data structure, that ends at the node right from where it starts.<\/p>\n<h2>Representation of Graph Data Structure<\/h2>\n<p>Graphs can be represented in multiple ways. In case the nodes are sparse, an adjacency list or adjacency set seems to be a good option else an adjacency matrix can be used to store the connections in an n*n matrix denoting all the nodes that are connected.<\/p>\n<p>To store the weight of edges, the adjacency matrix can store the weight in A[i][j] between adjacent nodes where A is the matrix and i,j being the nodes that are connected to each other.<\/p>\n<p>In the case of an adjacency list, a tuple consisting of weight as well as the connected node can be an alternative to simply connected nodes being stored in the adjacency list.<\/p>\n<p>Thus the two ways to store and represent the graph data structure can be deduced as<\/p>\n<ol>\n<li>Adjacency List<\/li>\n<li>Adjacency Matrix<\/li>\n<\/ol>\n<h2>Types of Graph in Data Structure<\/h2>\n<p>Getting the necessary terminologies and understanding what is graph in data structure, for this section, we proceed to look at the different types of graph in data structure. As we explore our way of looking at them below:-<\/p>\n<p><strong>Simple Graph<\/strong><br \/>\nA graph having no more than a single edge between all the adjacent nodes of the graph data structure.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167480-Graph%20in%20Data%20Structure1.png\" alt=\"\" \/><\/p>\n<p><strong>Multigraph<\/strong><br \/>\nA graph having multiple edges to join the same vertices or nodes.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167480-Graph%20in%20Data%20Structure2.png\" alt=\"\" \/><\/p>\n<p><strong>Undirected Graph<\/strong><br \/>\nA graph where the adjacent nodes are not directed towards each other. <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167480-Graph%20in%20Data%20Structure3.png\" alt=\"\" \/><\/p>\n<p><strong>Directed Graph<\/strong><br \/>\nA graph where the adjacent nodes are directed towards each other. Also known as Digraph.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167480-Graph%20in%20Data%20Structure4.png\" alt=\"\" \/><\/p>\n<p><strong>Weighted Graph<\/strong><br \/>\nA graph where the edges or connections between its nodes have an edge cost or weight.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167480-Graph%20in%20Data%20Structure5.png\" alt=\"\" \/><\/p>\n<p><strong>Unweighted Graph<\/strong><br \/>\nA graph where the edges or connections between its nodes do not have an edge cost or weight.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167481-Graph%20in%20Data%20Structure6.png\" alt=\"\" \/><\/p>\n<p><strong>Connected Graph<\/strong><br \/>\nA graph in which all the nodes are connected to each other with edges with a single component.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167481-Graph%20in%20Data%20Structure7.png\" alt=\"\" \/><\/p>\n<p><strong>Disconnected Graph<\/strong><br \/>\nA graph in which all the nodes are not connected to each other with edges making multiple components present in the graph data structure.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167481-Graph%20in%20Data%20Structure8.png\" alt=\"\" \/><\/p>\n<p><strong>Cyclic Graph<\/strong><br \/>\nA graph that constitutes any cycle where we reach an already visited vertex.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167499-Graph%20in%20Data%20Structure9.png\" alt=\"\" \/><\/p>\n<h2>Graph Traversal in Data Structure<\/h2>\n<p>Graph Traversal in Data Structure can be performed in certain ways available at our disposal. We can use a breadth-first traversal that is based on a queue data structure or a depth-first traversal based on the stack-based data structure.<\/p>\n<p>The major tweak between the tree and graph is that we maintain a visited set in the graph to avoid revisiting a node. A node in a tree is free from being revisited as there are no cycles in it.<\/p>\n<h3>Depth-First Search &#8211; Graph Data Structure:<\/h3>\n<p>Let us perform a depth-first search step by step on a tree using a stack, we print the values one by one along with the algorithm used to perform the technique.<\/p>\n<p><strong>Algorithm:<\/strong><\/p>\n<ol>\n<li>Execute recursive function dfs(node):<\/li>\n<li>Add node to visited set<\/li>\n<li>If the node already visited:<br \/>\na. Print node<\/li>\n<li>while node has neighbours<br \/>\na. Set temp as adjacent node<br \/>\nb. If temp not in visited set<\/p>\n<ul>\n<li>Repeat Step 1<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>We will be looking in a step-by-step manner to trace the working of depth first traversal in this article on what is graph data structure in data structure.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167499-Graph%20in%20Data%20Structure10.png\" alt=\"\" \/><\/p>\n<p>Here we have an undirected graph to travel.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167499-Graph%20in%20Data%20Structure11.png\" alt=\"\" \/><\/p>\n<p>Now A is visited after being popped from the stack and its unvisited neighbour is added to the stack i.e. B<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167500-Graph%20in%20Data%20Structure12.png\" alt=\"\" \/><\/p>\n<p>With A already visited by B, we only add the C node to our stack maintained to tackle the graph traversal in data structure.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167500-Graph%20in%20Data%20Structure13.png\" alt=\"\" \/><\/p>\n<p>Now we have covered a majority portion of the network, we add the nodes left to be traversed, E and D.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167500-Graph%20in%20Data%20Structure14.png\" alt=\"\" \/><\/p>\n<p>E being at the top of the stack will be popped and printed once it is added to the set.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167500-Graph%20in%20Data%20Structure15.png\" alt=\"\" \/><\/p>\n<p>As the last node in the stack, D is popped and the stack becomes empty, we have printed the required result leading to the termination and successful traversal.<\/p>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_11980 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_11980 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_11980 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_11980 .wpsm_nav-tabs > li.active > a, #tab_container_11980 .wpsm_nav-tabs > li.active > a:hover, #tab_container_11980 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_11980 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_11980 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_11980 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_11980 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_11980 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_11980 .wpsm_nav-tabs > li > a:hover , #tab_container_11980 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_11980 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_11980 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_11980 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_11980 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_11980 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_11980 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_11980 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_11980 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_11980 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_11980 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_11980 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_11980\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_11980\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_11980_1\" aria-controls=\"tabs_desc_11980_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Python<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_11980\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_11980_1\">\r\n\t\t\t\t\t\t\t\t<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">def dfs(graph, source,stack,visited):\r\n    visited.add(source)\r\n    print(source)\r\n    while stack:\r\n        cur = stack.pop()\r\n\r\n        for i in graph[cur]:\r\n            if i not in visited:\r\n                stack.append(i)\r\n                dfs(graph,i,stack,visited)\r\n    return True\r\n            \r\n\r\ngraph = {\r\n    'a':['b','e'],\r\n    'b':['a','c'],\r\n    'c':['b','e','d'],\r\n    'd':['c','e'],\r\n    'e':['a','e','d'],\r\n\r\n}\r\nprint(dfs(graph,'a',['a'],set()))<\/pre>\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_11980 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_11980 a\"),jQuery(\"#tab-content_11980\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Output:<\/strong><\/p>\n<pre><code>a\nb\nc\ne\nd\nTrue<\/code><\/pre>\n<h3>Breadth-First Search &#8211; Graph Data Structure:<\/h3>\n<p>Another form of search traversal we perform using a queue and move level by level to traverse through the nodes.<\/p>\n<p><strong>Algorithm:<\/strong><\/p>\n<ol>\n<li>Execute recursive function bfs(node):<\/li>\n<li>Add node to queue <\/li>\n<li>Add node to visited set<\/li>\n<li>while the queue is not empty:\n<ol>\n<li>Pop front of the queue and assign it to cur<\/li>\n<li>If neighbours of cur are left unvisited\n<ol>\n<li>Append neighbour to the rear of queue<\/li>\n<li>Mark neighbour or neighbours as unvisited<\/li>\n<\/ol>\n<\/li>\n<li>Print data kept in cur node<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>Now, we will be tracing step-by-step how to graph traversal is performed. We add A, the initial node to our queue and pass it to the function.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167500-Graph%20in%20Data%20Structure16.png\" alt=\"\" \/><\/p>\n<p>The source node will be added to the visited set,<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167516-Graph%20in%20Data%20Structure17.png\" alt=\"\" \/><\/p>\n<p>With A being popped from the queue to seek its adjacent nodes.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167516-Graph%20in%20Data%20Structure18.png\" alt=\"\" \/><\/p>\n<p>As we pop and add the adjacent nodes, we will print the current node in our output result.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167517-Graph%20in%20Data%20Structure19.png\" alt=\"\" \/><\/p>\n<p>Now, On applying the step to other nodes of the graph data structure.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167517-Graph%20in%20Data%20Structure20.png\" alt=\"\" \/><\/p>\n<p>The remaining nodes C and D will be popped with all the elements being visited in the set. Thus, in this manner, we will end up traversing all the nodes using a breadth-first search.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167517-Graph%20in%20Data%20Structure21.png\" alt=\"\" \/><\/p>\n<p>With this, we get all the nodes in our output successfully.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167517-Graph%20in%20Data%20Structure22.png\" alt=\"\" \/><\/p>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_11981 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_11981 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_11981 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_11981 .wpsm_nav-tabs > li.active > a, #tab_container_11981 .wpsm_nav-tabs > li.active > a:hover, #tab_container_11981 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_11981 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_11981 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_11981 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_11981 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_11981 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_11981 .wpsm_nav-tabs > li > a:hover , #tab_container_11981 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_11981 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_11981 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_11981 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_11981 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_11981 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_11981 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_11981 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_11981 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_11981 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_11981 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_11981 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_11981\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_11981\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_11981_1\" aria-controls=\"tabs_desc_11981_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Python<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_11981\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_11981_1\">\r\n\t\t\t\t\t\t\t\t<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">from collections import deque\r\ndef bfs(graph, source,stack,visited):\r\n    visited.add(source)\r\n    q = deque([source])\r\n    while q:\r\n        cur = q.popleft()\r\n        for i in graph[cur]:\r\n            if i not in visited:\r\n                visited.add(i)\r\n                q.append(i)\r\n        print(cur)\r\n\r\n    return True\r\n            \r\n\r\ngraph = {\r\n    'a':['b','e'],\r\n    'b':['a','c'],\r\n    'c':['b','e','d'],\r\n    'd':['c','e'],\r\n    'e':['a','e','d'],\r\n\r\n}\r\nprint(bfs(graph,'a',['a'],set()))<\/pre>\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_11981 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_11981 a\"),jQuery(\"#tab-content_11981\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Output:<\/strong><\/p>\n<pre><code>a\nb\ne\nc\nd\nTrue<\/code><\/pre>\n<h2>Application of Graph in Data Structure<\/h2>\n<p>As of now, we have, we have covered a vast portion of graph data structure. Some of the most important application of graph in data structure is as follow- <\/p>\n<p>1.<strong> Internet Maps and GPS Services:-<\/strong> Maps are made possible with real-world application of graph data structure. Djikstra Algorithm is used to find the shortest path to reach the destination.<\/p>\n<ol start=\"2\">\n<li>\n<p><strong>Web Search Engine:-<\/strong> The Internet and web search engine are linked with each other with the help of hyperlinks that can be framed as the application of a graph. <\/p>\n<\/li>\n<li>\n<p><strong>Biochemical Applications:-<\/strong> Graph data structure has expanded its use in chemical research and biological applications such as protein, signal transduction etc.<\/p>\n<\/li>\n<li>\n<p><strong>Social Media:-<\/strong> The use case of Facebook friends and Twitter users is dependent on the usage of graph data structure that defines a relationship between two vertices.<\/p>\n<\/li>\n<li>\n<p><strong>Discrete Mathematics:-<\/strong> Graph Data Structure has multiple use cases with Graph Theory being an important subject comprising graph concepts.<\/p>\n<\/li>\n<li>\n<p><strong>Solve Puzzle:-<\/strong>  Graph data structure is used to solve complex problems that have a single solution such as maze problems.<\/p>\n<\/li>\n<\/ol>\n<p><strong>Conclusion<\/strong><br \/>\nIn this article, we started by looking at how to define graph in data structure and proceeded further looking at the types of graph in data structure, application of graph in data structure, and graph traversal in data structure giving us clarity to the topic.<\/p>\n<p>We hope you liked this article on what is graph in data structure and expect to see you again at PrepBytes with another informative article from our side.<\/p>\n<h2>FAQs Related to Graph Data Structure<\/h2>\n<p><strong>1. Define graph in data structure \/ What is graph in data structure?<\/strong><br \/>\nGraph data structure represents the relationship between nodes connected with the help of edges in a network.<\/p>\n<p><strong>2. What are the two ways to represent Graph Data Structure?<\/strong><br \/>\nGraph Data Structure can be represented by an adjacency list and adjacency matrix.<\/p>\n<p><strong>3. What are the methods to perform graph traversal in data structure?<\/strong><br \/>\nDepth First Search and Breadth First are the two methods of graph traversal in data structure.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we are going to study what is graph in data structure, the types of graph in data structure, the application of graph in data structure and also the techniques to perform graph traversal in data structure in the types of graph in data structure. We will start by looking out to define [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[166],"tags":[],"class_list":["post-11978","post","type-post","status-publish","format-standard","hentry","category-graphs"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Graph in Data Structure: Definition, Types and Application<\/title>\n<meta name=\"description\" content=\"Understanding what is graph in data structure, types of graph, application of graph and also the techniques to perform graph traversal in data structure.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Graph in Data Structure: Definition, Types and Application\" \/>\n<meta property=\"og:description\" content=\"Understanding what is graph in data structure, types of graph, application of graph and also the techniques to perform graph traversal in data structure.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-30T07:34:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-02-02T05:37:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167354-Graph%20in%20Data%20Structure.jpg\" \/>\n<meta name=\"author\" content=\"Prepbytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prepbytes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Graph in Data Structure: Definition, Types and Application\",\"datePublished\":\"2023-01-30T07:34:50+00:00\",\"dateModified\":\"2023-02-02T05:37:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/\"},\"wordCount\":1707,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167354-Graph%20in%20Data%20Structure.jpg\",\"articleSection\":[\"Graphs\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/\",\"name\":\"Graph in Data Structure: Definition, Types and Application\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167354-Graph%20in%20Data%20Structure.jpg\",\"datePublished\":\"2023-01-30T07:34:50+00:00\",\"dateModified\":\"2023-02-02T05:37:30+00:00\",\"description\":\"Understanding what is graph in data structure, types of graph, application of graph and also the techniques to perform graph traversal in data structure.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167354-Graph%20in%20Data%20Structure.jpg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167354-Graph%20in%20Data%20Structure.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Graphs\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/graphs\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Graph in Data Structure: Definition, Types and Application\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\",\"name\":\"Prepbytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"caption\":\"Prepbytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Graph in Data Structure: Definition, Types and Application","description":"Understanding what is graph in data structure, types of graph, application of graph and also the techniques to perform graph traversal in data structure.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/","og_locale":"en_US","og_type":"article","og_title":"Graph in Data Structure: Definition, Types and Application","og_description":"Understanding what is graph in data structure, types of graph, application of graph and also the techniques to perform graph traversal in data structure.","og_url":"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2023-01-30T07:34:50+00:00","article_modified_time":"2023-02-02T05:37:30+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167354-Graph%20in%20Data%20Structure.jpg","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Graph in Data Structure: Definition, Types and Application","datePublished":"2023-01-30T07:34:50+00:00","dateModified":"2023-02-02T05:37:30+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/"},"wordCount":1707,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167354-Graph%20in%20Data%20Structure.jpg","articleSection":["Graphs"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/","url":"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/","name":"Graph in Data Structure: Definition, Types and Application","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167354-Graph%20in%20Data%20Structure.jpg","datePublished":"2023-01-30T07:34:50+00:00","dateModified":"2023-02-02T05:37:30+00:00","description":"Understanding what is graph in data structure, types of graph, application of graph and also the techniques to perform graph traversal in data structure.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167354-Graph%20in%20Data%20Structure.jpg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1675063167354-Graph%20in%20Data%20Structure.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/graph-in-data-structure\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"Graphs","item":"https:\/\/prepbytes.com\/blog\/category\/graphs\/"},{"@type":"ListItem","position":3,"name":"Graph in Data Structure: Definition, Types and Application"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e","name":"Prepbytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","caption":"Prepbytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/11978","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=11978"}],"version-history":[{"count":4,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/11978\/revisions"}],"predecessor-version":[{"id":12290,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/11978\/revisions\/12290"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=11978"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=11978"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=11978"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}