{"id":137,"date":"2025-05-22T18:19:16","date_gmt":"2025-05-22T12:49:16","guid":{"rendered":"https:\/\/codeanddebug.in\/blog\/?p=137"},"modified":"2025-05-23T18:42:51","modified_gmt":"2025-05-23T13:12:51","slug":"depth-first-search-in-graph","status":"publish","type":"post","link":"https:\/\/codeanddebug.in\/blog\/depth-first-search-in-graph\/","title":{"rendered":"DFS Traversal in Graph | Explained using Code"},"content":{"rendered":"\n<p>Learn how to perform a <strong>DFS Traversal in Graph<\/strong> represented by an adjacency list using simple Python recursion. Step by step code, dry run, and complexity analysis included, no prior experience needed!<\/p>\n\n\n<div style=\"max-width: -moz-fit-content; \" class=\"wp-block-ub-table-of-contents-block ub_table-of-contents ub_table-of-contents-collapsed\" id=\"ub_table-of-contents-48492aff-3dcd-4683-ad69-46995e1bc36e\" data-linktodivider=\"false\" data-showtext=\"show\" data-hidetext=\"hide\" data-scrolltype=\"auto\" data-enablesmoothscroll=\"true\" data-initiallyhideonmobile=\"false\" data-initiallyshow=\"false\"><div class=\"ub_table-of-contents-header-container\" style=\"\">\n\t\t\t<div class=\"ub_table-of-contents-header\" style=\"text-align: left; \">\n\t\t\t\t<div class=\"ub_table-of-contents-title\">Content:<\/div>\n\t\t\t\t<div class=\"ub_table-of-contents-header-toggle\">\n\t\t\t<div class=\"ub_table-of-contents-toggle\" style=\"\">\n\t\t\t\u00a0[<a class=\"ub_table-of-contents-toggle-link\" href=\"#\" style=\"\">show<\/a>]\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t<\/div>\n\t\t<\/div><div class=\"ub_table-of-contents-extra-container\" style=\"\">\n\t\t\t<div class=\"ub_table-of-contents-container ub_table-of-contents-1-column ub-hide\">\n\t\t\t\t<ul style=\"\"><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/depth-first-search-in-graph\/#0-what-the-problem-asks\" style=\"\">What the Problem Asks<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/depth-first-search-in-graph\/#1-intuition-amp-approach\" style=\"\">Intuition &amp; Approach<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/depth-first-search-in-graph\/#2-code-implementation\" style=\"\">Code Implementation<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/depth-first-search-in-graph\/#3-code-explanation\" style=\"\">Code Explanation<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/depth-first-search-in-graph\/#4-dry-run-example\" style=\"\">Dry Run Example<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/depth-first-search-in-graph\/#5-time-amp-space-complexity\" style=\"\">Time &amp; Space Complexity<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/depth-first-search-in-graph\/#6-conclusion\" style=\"\">Conclusion<\/a><\/li><\/ul>\n\t\t\t<\/div>\n\t\t<\/div><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"0-what-the-problem-asks\">What the Problem Asks<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>DFS Traversal of Graph<\/strong><br>Given a graph as an adjacency list, start at node <strong>0<\/strong> and perform a DFS. Return the list of nodes in the order they\u2019re first visited.<\/p>\n<\/blockquote>\n\n\n\n<p><strong>Input:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>adj<\/code>: A list of length <code>N<\/code>, where <code>adj[u]<\/code> is a list of neighbors of node <code>u<\/code>.<\/li>\n<\/ul>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A list of node indices in the exact order DFS visits them, starting from <code>0<\/code>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"1-intuition-amp-approach\">Intuition &amp; Approach<\/h2>\n\n\n\n<p><strong>DFS Basics:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You start at a node, mark it visited, then <strong>recursively<\/strong> explore each unvisited neighbor as deeply as possible before backtracking.<\/li>\n<\/ul>\n\n\n\n<p><strong>Why Recursion?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The call stack naturally remembers the path you\u2019ve taken. When you finish one branch, it \u201cpops back\u201d and continues with siblings.<\/li>\n<\/ul>\n\n\n\n<p><strong>Key Steps:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Maintain a <code>visited<\/code> array to avoid revisiting nodes (and infinite loops).<\/li>\n\n\n\n<li>Maintain a <code>result<\/code> list to record the visit order.<\/li>\n\n\n\n<li>Write a helper <code>dfs_algo(node)<\/code> that:\n<ol class=\"wp-block-list\">\n<li>Marks <code>node<\/code> visited and appends it to <code>result<\/code>.<\/li>\n\n\n\n<li>Loops through each neighbor; if it\u2019s unvisited, recurses into that neighbor.<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2-code-implementation\">Code Implementation<\/h2>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"class Solution:\n    def dfs_algo(self, node, adj, visited, result):\n        # 1. Visit this node\n        result.append(node)\n        visited[node] = 1\n\n        # 2. Recurse on each unvisited neighbor\n        for neighbor in adj[node]:\n            if not visited[neighbor]:\n                self.dfs_algo(neighbor, adj, visited, result)\n\n    def dfs(self, adj):\n        total_nodes = len(adj)\n        visited = [0] * total_nodes  # 0 = unvisited, 1 = visited\n        result = []\n\n        # Start DFS from node 0\n        self.dfs_algo(0, adj, visited, result)\n        return result\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">class<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #4EC9B0\">Solution<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">def<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">dfs_algo<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">self<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #9CDCFE\">node<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #9CDCFE\">adj<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #9CDCFE\">visited<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #9CDCFE\">result<\/span><span style=\"color: #D4D4D4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># 1. Visit this node<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        result.append(node)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        visited[node] = <\/span><span style=\"color: #B5CEA8\">1<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># 2. Recurse on each unvisited neighbor<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">for<\/span><span style=\"color: #D4D4D4\"> neighbor <\/span><span style=\"color: #C586C0\">in<\/span><span style=\"color: #D4D4D4\"> adj[node]:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">not<\/span><span style=\"color: #D4D4D4\"> visited[neighbor]:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">                <\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.dfs_algo(neighbor, adj, visited, result)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">def<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">dfs<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">self<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #9CDCFE\">adj<\/span><span style=\"color: #D4D4D4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        total_nodes = <\/span><span style=\"color: #DCDCAA\">len<\/span><span style=\"color: #D4D4D4\">(adj)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        visited = [<\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">] * total_nodes  <\/span><span style=\"color: #6A9955\"># 0 = unvisited, 1 = visited<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        result = []<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># Start DFS from node 0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.dfs_algo(<\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">, adj, visited, result)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> result<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3-code-explanation\">Code Explanation<\/h2>\n\n\n\n<p><strong><code>visited<\/code> list:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Tracks whether each node has already been explored.<\/li>\n<\/ul>\n\n\n\n<p><strong><code>result<\/code> list:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Records the order in which nodes are visited.<\/li>\n<\/ul>\n\n\n\n<p><strong><code>dfs_algo(node, adj, visited, result)<\/code>:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Visit:<\/strong> Append <code>node<\/code> to <code>result<\/code> and mark <code>visited[node] = 1<\/code>.<\/li>\n\n\n\n<li><strong>Explore neighbors:<\/strong> For every neighbor in <code>adj[node]<\/code>, if it\u2019s unvisited, call <code>dfs_algo(neighbor, \u2026)<\/code> recursively.<\/li>\n<\/ul>\n\n\n\n<p><strong><code>dfs(adj)<\/code>:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Initializes <code>visited<\/code> and <code>result<\/code>.<\/li>\n\n\n\n<li>Kicks off recursion at node <code>0<\/code>.<\/li>\n\n\n\n<li>Returns the filled <code>result<\/code> list.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"4-dry-run-example\">Dry Run Example<\/h2>\n\n\n\n<p>Graph:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"0: [1, 2]\n1: [0, 3]\n2: [0, 4]\n3: [1]\n4: [2]\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">: [<\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #B5CEA8\">2<\/span><span style=\"color: #D4D4D4\">]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">: [<\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #B5CEA8\">3<\/span><span style=\"color: #D4D4D4\">]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #B5CEA8\">2<\/span><span style=\"color: #D4D4D4\">: [<\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #B5CEA8\">4<\/span><span style=\"color: #D4D4D4\">]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #B5CEA8\">3<\/span><span style=\"color: #D4D4D4\">: [<\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #B5CEA8\">4<\/span><span style=\"color: #D4D4D4\">: [<\/span><span style=\"color: #B5CEA8\">2<\/span><span style=\"color: #D4D4D4\">]<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Start at 0:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Visit 0 \u2192 <code>result = [0]<\/code>.<\/li>\n\n\n\n<li>Neighbors: 1, 2.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Go to 1:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Visit 1 \u2192 <code>result = [0,1]<\/code>.<\/li>\n\n\n\n<li>Neighbors: 0 (already visited), 3.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Go to 3:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Visit 3 \u2192 <code>result = [0,1,3]<\/code>.<\/li>\n\n\n\n<li>Neighbor: 1 (visited) \u2192 backtrack to 1, then back to 0.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Back at 0, next neighbor 2:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Visit 2 \u2192 <code>result = [0,1,3,2]<\/code>.<\/li>\n\n\n\n<li>Neighbors: 0 (visited), 4.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Go to 4:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Visit 4 \u2192 <code>result = [0,1,3,2,4]<\/code>.<\/li>\n\n\n\n<li>Neighbor: 2 (visited), done.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>Final DFS order: <strong>[0, 1, 3, 2, 4]<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"5-time-amp-space-complexity\">Time &amp; Space Complexity<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Time Complexity:<\/strong>\n<ul class=\"wp-block-list\">\n<li>We visit each node exactly once and examine each edge once \u2192 <strong>O(N + 2E)<\/strong>, where N = nodes, E = edges.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Space Complexity:<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>O(N)<\/strong> for the <code>visited<\/code> and <code>result<\/code> lists, plus <strong>O(N)<\/strong> recursion stack in the worst case (e.g., a long chain).<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"6-conclusion\">Conclusion<\/h2>\n\n\n\n<p>Depth-First Search via recursion is straightforward and intuitive. By marking nodes as visited before recursing, you avoid cycles and capture a clear visit order. Mastering this pattern equips you to tackle many graph problems\u2014from connectivity checks to path finding\u2014both on GeeksforGeeks and in coding interviews. Happy exploring!<\/p>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-16018d1d wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/codeanddebug.in\/course\/master-dsa-with-leetcode\" target=\"_blank\" rel=\"noreferrer noopener\">Join our free DSA COURSE<\/a><\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><em>For any changes to the article, kindly email at <a href=\"mailto:code@codeanddebug.in\">code@codeanddebug.in<\/a> or contact us at <a href=\"tel:+91-9712928220\">+91-9712928220<\/a>.<\/em><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to perform a DFS Traversal in Graph represented by an adjacency list using simple Python recursion. Step by step code, dry run, and complexity analysis included, no prior experience needed! What the Problem Asks DFS Traversal of GraphGiven a graph as an adjacency list, start at node 0 and perform a DFS. Return<\/p>\n","protected":false},"author":1,"featured_media":138,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6],"tags":[17],"class_list":{"0":"post-137","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-data-structures-and-algorithm","8":"category-intermediate","9":"tag-graph"},"featured_image_src":"https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/depth-first-search-in-graph-featured-image.png","author_info":{"display_name":"codeanddebug","author_link":"https:\/\/codeanddebug.in\/blog\/author\/codeanddebug\/"},"_links":{"self":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/comments?post=137"}],"version-history":[{"count":2,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/137\/revisions"}],"predecessor-version":[{"id":141,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/137\/revisions\/141"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/media\/138"}],"wp:attachment":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/media?parent=137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/categories?post=137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/tags?post=137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}