{"id":9676,"date":"2021-03-05T06:42:21","date_gmt":"2021-03-05T01:12:21","guid":{"rendered":"http:\/\/www.pythonpool.com\/?p=9676"},"modified":"2024-01-01T14:57:22","modified_gmt":"2024-01-01T09:27:22","slug":"a-star-algorithm-python","status":"publish","type":"post","link":"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/","title":{"rendered":"The Insider&#8217;s Guide to A* Algorithm in Python"},"content":{"rendered":"\n<p>A* Algorithm in Python or in general is basically an artificial intelligence problem used for the pathfinding (from point A to point B) and the Graph traversals. This algorithm is flexible and can be used in a wide range of contexts. The A* search algorithm uses the heuristic path cost, the starting point&#8217;s cost, and the ending point. This algorithm was first published by Peter Hart,&nbsp;Nils Nilsson,&nbsp;and&nbsp;<strong>Bertram Raphael<\/strong> in 1968.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-why-a-algorithm\">Why A* Algorithm?<\/h3>\n\n\n\n<p>This Algorithm is the advanced form of the BFS algorithm (Breadth-first search), which searches for the shorter path first than, the longer paths. It is a complete as well as an <strong>optimal<\/strong> solution for solving path and grid problems.<\/p>\n\n\n\n<p><strong>Optimal<\/strong> &#8211; find the least cost from the starting point to the ending point. Complete &#8211; It means that it will find all the available paths from start to end.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#Basic_concepts_of_A\" >Basic concepts of A*<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#Algorithm\" >Algorithm<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#Advantages_of_A_Algorithm_in_Python\" >Advantages of A* Algorithm in Python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#Disadvantages_of_A_Algorithm_in_Python\" >Disadvantages of A* Algorithm in Python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#Pseudo-code_of_A_algorithm\" >Pseudo-code of A* algorithm<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#A_Algorithm_code_for_Graph\" >A* Algorithm code for Graph<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#Also_Read\" >Also, Read<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-basic-concepts-of-a\"><span class=\"ez-toc-section\" id=\"Basic_concepts_of_A\"><\/span>Basic concepts of A*<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Where<\/p>\n\n\n\n<p>g&nbsp; (n) : The actual cost path from the start node to the current node.&nbsp;<\/p>\n\n\n\n<p>h&nbsp;( n) : The actual cost path from the current node to goal node.<\/p>\n\n\n\n<p>f&nbsp; (n) : The actual cost path from the start node to the goal node.<\/p>\n\n\n\n<p>For the implementation of A* algorithm we have to use two arrays namely OPEN and CLOSE.<\/p>\n\n\n\n<p><strong>OPEN:<\/strong><\/p>\n\n\n\n<p>An array that contains the nodes that have been generated but have not been yet examined till yet.<\/p>\n\n\n\n<p><strong>CLOSE:<\/strong><\/p>\n\n\n\n<p>An array which contains the nodes which are examined.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-algorithm\"><span class=\"ez-toc-section\" id=\"Algorithm\"><\/span>Algorithm<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>1:&nbsp;<\/strong>Firstly, Place the starting node into OPEN and find its f (n) value.<\/p>\n\n\n\n<p><strong>2:&nbsp;<\/strong>Then remove the node from OPEN, having the smallest f (n) value. If it is a goal node, then stop and return to success.<\/p>\n\n\n\n<p><strong>3:&nbsp;<\/strong>Else remove the node from OPEN, and find all its successors.<\/p>\n\n\n\n<p><strong>4:&nbsp;<\/strong>Find the f (n) value of all the successors, place them into OPEN, and place the removed node into CLOSE.<\/p>\n\n\n\n<p><strong>5:&nbsp;<\/strong>Goto Step-2.<\/p>\n\n\n\n<p><strong>6:&nbsp;<\/strong>Exit.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-advantages-of-a-algorithm-in-python\"><span class=\"ez-toc-section\" id=\"Advantages_of_A_Algorithm_in_Python\"><\/span>Advantages of A* Algorithm in Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It is fully complete and optimal.<\/li>\n\n\n\n<li>This is the best one of all the other techniques. We use to solve all the complex problems through this algorithm.<\/li>\n\n\n\n<li>The algorithm is optimally efficient, i.e., there is no other optimal algorithm that is guaranteed to expand fewer nodes than A*.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-disadvantages-of-a-algorithm-in-python\"><span class=\"ez-toc-section\" id=\"Disadvantages_of_A_Algorithm_in_Python\"><\/span>Disadvantages of A* Algorithm in Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>This algorithm is complete if the branching factor is finite of the algorithm and every action has a fixed cost.<\/li>\n\n\n\n<li>The speed execution of A* search is highly dependant on the accuracy of the heuristic algorithm that is used to compute h (n) and is a bit slower than other algorithms.<\/li>\n\n\n\n<li>It is having complex problems.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-pseudo-code-of-a-algorithm\"><span class=\"ez-toc-section\" id=\"Pseudo-code_of_A_algorithm\"><\/span>Pseudo-code of A* algorithm <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>let openList equal empty list of nodes\nlet closedList equal empty list of nodes\nput startNode on the openList (leave it's f at zero)\nwhile openList is not empty\n    let currentNode equal the node with the least f value\n    remove currentNode from the openList\n    add currentNode to the closedList\n    if currentNode is the goal\n        You've found the exit!\n    let children of the currentNode equal the adjacent nodes\n    for each child in the children\n        if child is in the closedList\n            continue to beginning of for loop\n        child.g = currentNode.g + distance b\/w child and current\n        child.h = distance from child to end\n        child.f = child.g + child.h\n        if child.position is in the openList's nodes positions\n            if child.g is higher than the openList node's g\n                continue to beginning of for loop\n        add the child to the openList<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-a-algorithm-code-for-graph\"><span class=\"ez-toc-section\" id=\"A_Algorithm_code_for_Graph\"><\/span>A* Algorithm code for Graph<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>A* algorithm is best when it comes to finding paths from one place to another. It always makes sure that the founded path is the most efficient. This is the implementation of A* on a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Graph_theory\" target=\"_blank\" rel=\"noreferrer noopener\">graph<\/a> structure<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"596\" height=\"561\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/Capture1545-1.png\" alt=\"A* AlgorithmPython code for Graph\" class=\"wp-image-9799\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/Capture1545-1.png 596w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/Capture1545-1-300x282.png 300w\" sizes=\"(max-width: 596px) 100vw, 596px\" \/><\/figure><\/div>\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\"><div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom collections import deque\n\nclass Graph:\n    def __init__(self, adjac_lis):\n        self.adjac_lis = adjac_lis\n\n    def get_neighbors(self, v):\n        return self.adjac_lis&#x5B;v]\n\n    # This is heuristic function which is having equal values for all nodes\n    def h(self, n):\n        H = {\n            'A': 1,\n            'B': 1,\n            'C': 1,\n            'D': 1\n        }\n\n        return H&#x5B;n]\n\n    def a_star_algorithm(self, start, stop):\n        # In this open_lst is a lisy of nodes which have been visited, but who's \n        # neighbours haven't all been always inspected, It starts off with the start \n  #node\n        # And closed_lst is a list of nodes which have been visited\n        # and who's neighbors have been always inspected\n        open_lst = set(&#x5B;start])\n        closed_lst = set(&#x5B;])\n\n        # poo has present distances from start to all other nodes\n        # the default value is +infinity\n        poo = {}\n        poo&#x5B;start] = 0\n\n        # par contains an adjac mapping of all nodes\n        par = {}\n        par&#x5B;start] = start\n\n        while len(open_lst) &gt; 0:\n            n = None\n\n            # it will find a node with the lowest value of f() -\n            for v in open_lst:\n                if n == None or poo&#x5B;v] + self.h(v) &lt; poo&#x5B;n] + self.h(n):\n                    n = v;\n\n            if n == None:\n                print('Path does not exist!')\n                return None\n\n            # if the current node is the stop\n            # then we start again from start\n            if n == stop:\n                reconst_path = &#x5B;]\n\n                while par&#x5B;n] != n:\n                    reconst_path.append(n)\n                    n = par&#x5B;n]\n\n                reconst_path.append(start)\n\n                reconst_path.reverse()\n\n                print('Path found: {}'.format(reconst_path))\n                return reconst_path\n\n            # for all the neighbors of the current node do\n            for (m, weight) in self.get_neighbors(n):\n              # if the current node is not presentin both open_lst and closed_lst\n                # add it to open_lst and note n as it's par\n                if m not in open_lst and m not in closed_lst:\n                    open_lst.add(m)\n                    par&#x5B;m] = n\n                    poo&#x5B;m] = poo&#x5B;n] + weight\n\n                # otherwise, check if it's quicker to first visit n, then m\n                # and if it is, update par data and poo data\n                # and if the node was in the closed_lst, move it to open_lst\n                else:\n                    if poo&#x5B;m] &gt; poo&#x5B;n] + weight:\n                        poo&#x5B;m] = poo&#x5B;n] + weight\n                        par&#x5B;m] = n\n\n                        if m in closed_lst:\n                            closed_lst.remove(m)\n                            open_lst.add(m)\n\n            # remove n from the open_lst, and add it to closed_lst\n            # because all of his neighbors were inspected\n            open_lst.remove(n)\n            closed_lst.add(n)\n\n        print('Path does not exist!')\n        return None\n<\/pre><\/div><\/div>\n<\/div>\n\n\n\n<p><strong>INPUT:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nadjac_lis = {\n    'A': &#x5B;('B', 1), ('C', 3), ('D', 7)],\n    'B': &#x5B;('D', 5)],\n    'C': &#x5B;('D', 12)]\n}\ngraph1 = Graph(adjac_lis)\ngraph1.a_star_algorithm('A', 'D')\n<\/pre><\/div>\n\n\n<p><strong>OUTPUT:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Path found: &#91;'A', 'B', 'D']\n&#91;'A', 'B', 'D']<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-explanation\"><strong>Explanation:<\/strong><\/h3>\n\n\n\n<p>In this code, we have made the class named Graph, where multiple functions perform different operations. There is written with all the functions what all operations that function is performing. Then some conditional statements will perform the required operations to get the minimum path for traversal from one node to another node. Finally, we will get the output as the shortest path to travel from one node to another.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-vivid-purple-color has-text-color\" id=\"h-also-read\"><span class=\"ez-toc-section\" id=\"Also_Read\"><\/span>Also, Read<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-yoast-seo-related-links\"><li><a href=\"http:\/\/www.pythonpool.com\/10-machine-learning-algorithms-for-beginners\/\">10 Machine Learning Algorithms For Beginners<\/a><\/li><li><a href=\"http:\/\/www.pythonpool.com\/python-average-of-list\/\">How to Find Average of the List in Python<\/a><\/li><li><a href=\"http:\/\/www.pythonpool.com\/dijkstras-algorithm-python\/\">Implementing Dijkstra&#8217;s Algorithm in Python<\/a><\/li><li><a href=\"http:\/\/www.pythonpool.com\/python-find\/\">How to use Python find() | Python find() String Method<\/a><\/li><li><a href=\"http:\/\/www.pythonpool.com\/doubly-linked-list-in-python\/\">Doubly Linked List in Python &#8211; Advanced Data Structure<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>A* in Python is a powerful and beneficial algorithm with all the potential. However, it is only as good as its heuristic function, which is highly variable considering a problem&#8217;s nature. It has found its applications in software systems in machine learning and search optimization to game development.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A* Algorithm in Python or in general is basically an artificial intelligence problem used for the pathfinding (from point A to point B) and the &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"The Insider&#8217;s Guide to A* Algorithm in Python\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#more-9676\" aria-label=\"More on The Insider&#8217;s Guide to A* Algorithm in Python\">Read more<\/a><\/p>\n","protected":false},"author":17,"featured_media":9817,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1654,15],"tags":[3675,3674,3673,3676,3677],"class_list":["post-9676","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-algorithm","category-tutorials","tag-a-star-algorithm-python","tag-a-star-algorithm-python-code","tag-a-search-algorithm-python","tag-python-a-star-algorithm","tag-python-a-algorithm","infinite-scroll-item"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v25.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>The Insider&#039;s Guide to A* Algorithm in Python - Python Pool<\/title>\n<meta name=\"description\" content=\"A* Algorithm in Python or general is an artificial intelligence problem used forpath finding and Graph traversals as this algorithm is flexible.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The Insider&#039;s Guide to A* Algorithm in Python\" \/>\n<meta property=\"og:description\" content=\"A* Algorithm in Python or in general is basically an artificial intelligence problem used for the pathfinding (from point A to point B) and the Graph\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-05T01:12:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-01T09:27:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/a-star-algorithm-python.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1350\" \/>\n\t<meta property=\"og:image:height\" content=\"650\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Siddharth Jain\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Siddharth Jain\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/\"},\"author\":{\"name\":\"Siddharth Jain\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/75a3240fabe5ea90200777a9d8d3b4fa\"},\"headline\":\"The Insider&#8217;s Guide to A* Algorithm in Python\",\"datePublished\":\"2021-03-05T01:12:21+00:00\",\"dateModified\":\"2024-01-01T09:27:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/\"},\"wordCount\":651,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/a-star-algorithm-python.png\",\"keywords\":[\"a star algorithm python\",\"a star algorithm python code\",\"a* search algorithm python\",\"python a star algorithm\",\"python a* algorithm\"],\"articleSection\":[\"Algorithm\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/\",\"url\":\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/\",\"name\":\"The Insider's Guide to A* Algorithm in Python - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/a-star-algorithm-python.png\",\"datePublished\":\"2021-03-05T01:12:21+00:00\",\"dateModified\":\"2024-01-01T09:27:22+00:00\",\"description\":\"A* Algorithm in Python or general is an artificial intelligence problem used forpath finding and Graph traversals as this algorithm is flexible.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/a-star-algorithm-python.png\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/a-star-algorithm-python.png\",\"width\":1350,\"height\":650,\"caption\":\"a* algorithm python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The Insider&#8217;s Guide to A* Algorithm in Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/75a3240fabe5ea90200777a9d8d3b4fa\",\"name\":\"Siddharth Jain\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/152b0ac2e5fa2e6328f374499fff4a7a6299477b9cf7bbb15ebc01a88f8f673f?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/152b0ac2e5fa2e6328f374499fff4a7a6299477b9cf7bbb15ebc01a88f8f673f?s=96&d=wavatar&r=g\",\"caption\":\"Siddharth Jain\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"The Insider's Guide to A* Algorithm in Python - Python Pool","description":"A* Algorithm in Python or general is an artificial intelligence problem used forpath finding and Graph traversals as this algorithm is flexible.","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:\/\/www.pythonpool.com\/a-star-algorithm-python\/","og_locale":"en_US","og_type":"article","og_title":"The Insider's Guide to A* Algorithm in Python","og_description":"A* Algorithm in Python or in general is basically an artificial intelligence problem used for the pathfinding (from point A to point B) and the Graph","og_url":"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/","og_site_name":"Python Pool","article_published_time":"2021-03-05T01:12:21+00:00","article_modified_time":"2024-01-01T09:27:22+00:00","og_image":[{"width":1350,"height":650,"url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/a-star-algorithm-python.png","type":"image\/png"}],"author":"Siddharth Jain","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Siddharth Jain","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#article","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/"},"author":{"name":"Siddharth Jain","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/75a3240fabe5ea90200777a9d8d3b4fa"},"headline":"The Insider&#8217;s Guide to A* Algorithm in Python","datePublished":"2021-03-05T01:12:21+00:00","dateModified":"2024-01-01T09:27:22+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/"},"wordCount":651,"commentCount":1,"publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/a-star-algorithm-python.png","keywords":["a star algorithm python","a star algorithm python code","a* search algorithm python","python a star algorithm","python a* algorithm"],"articleSection":["Algorithm","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/","url":"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/","name":"The Insider's Guide to A* Algorithm in Python - Python Pool","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#primaryimage"},"image":{"@id":"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/a-star-algorithm-python.png","datePublished":"2021-03-05T01:12:21+00:00","dateModified":"2024-01-01T09:27:22+00:00","description":"A* Algorithm in Python or general is an artificial intelligence problem used forpath finding and Graph traversals as this algorithm is flexible.","breadcrumb":{"@id":"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pythonpool.com\/a-star-algorithm-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#primaryimage","url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/a-star-algorithm-python.png","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/a-star-algorithm-python.png","width":1350,"height":650,"caption":"a* algorithm python"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pythonpool.com\/a-star-algorithm-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"The Insider&#8217;s Guide to A* Algorithm in Python"}]},{"@type":"WebSite","@id":"https:\/\/www.pythonpool.com\/#website","url":"https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/pythonpool","https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/75a3240fabe5ea90200777a9d8d3b4fa","name":"Siddharth Jain","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/152b0ac2e5fa2e6328f374499fff4a7a6299477b9cf7bbb15ebc01a88f8f673f?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/152b0ac2e5fa2e6328f374499fff4a7a6299477b9cf7bbb15ebc01a88f8f673f?s=96&d=wavatar&r=g","caption":"Siddharth Jain"}}]}},"_links":{"self":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/9676","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=9676"}],"version-history":[{"count":24,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/9676\/revisions"}],"predecessor-version":[{"id":31574,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/9676\/revisions\/31574"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/9817"}],"wp:attachment":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=9676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=9676"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=9676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}