{"id":12988,"date":"2021-06-02T11:46:03","date_gmt":"2021-06-02T06:16:03","guid":{"rendered":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/?p=12988"},"modified":"2021-06-14T15:11:30","modified_gmt":"2021-06-14T09:41:30","slug":"adjacency-list-python","status":"publish","type":"post","link":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/","title":{"rendered":"An In-depth Guide To Adjacency List in Python"},"content":{"rendered":"\n<p>A graph is a data structure consisting of nodes and edges. The nodes are the vertices sets in a graph representing the objects, and the edges are the connections between two nodes. We use graphs to represent communication in a network. <\/p>\n\n\n\n<p>The main purpose of a graph is to find the shortest route between two given nodes where each node represents an entity. There are two ways to represent a graph &#8211; 1. Using Adjacent Matrix and 2. Using Adjacency List. In this article, we will be focusing on the representation of graphs using an adjacency list.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_65 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 \" >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\/adjacency-list-python\/#What_is_an_adjacency_list\" title=\"What is an adjacency list?\">What is an adjacency list?<\/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\/adjacency-list-python\/#Representation_of_an_adjacency_list\" title=\"Representation of an adjacency list\">Representation of an adjacency list<\/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\/adjacency-list-python\/#Creating_an_adjacency_list_Using_Python\" title=\"Creating an adjacency list Using Python\">Creating an adjacency list Using Python<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#Directed_Unweighted_Graph\" title=\"Directed Unweighted Graph\">Directed Unweighted Graph<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#Directed_Weighted_Graph\" title=\"Directed Weighted Graph\">Directed Weighted Graph<\/a><\/li><\/ul><\/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\/adjacency-list-python\/#Must_Read\" title=\"Must Read:\">Must Read:<\/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\/adjacency-list-python\/#Dijkstras_Algorithm_using_Adjacency_list\" title=\"Dijkstra&#8217;s Algorithm using Adjacency list\">Dijkstra&#8217;s Algorithm using Adjacency list<\/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\/adjacency-list-python\/#FAQs\" title=\"FAQ&#8217;s\">FAQ&#8217;s<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-what-is-an-adjacency-list\"><span class=\"ez-toc-section\" id=\"What_is_an_adjacency_list\"><\/span>What is an adjacency list?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>An adjacency list in python is a way for representing a graph. This form of representation is efficient in terms of space because we only have to store the edges for a given node. <\/p>\n\n\n\n<p><strong>In python, we can use dictionaries to store an adjacency list. The dictionary&#8217;s keys will be the nodes, and their values will be the edges for each node. <\/strong><\/p>\n\n\n\n<p>With the help of an adjacency list, we can find for a particular node all the nodes connected to it. Let us understand the representation of an adjacency list with the help of an example.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-representation-of-an-adjacency-list\"><span class=\"ez-toc-section\" id=\"Representation_of_an_adjacency_list\"><\/span>Representation of an adjacency list<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Lets us consider an undirected and an unweighted graph for our understanding. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-1024x727.png\" alt=\"Adjacency List Python \" class=\"wp-image-12997\" width=\"473\" height=\"335\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-1024x727.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-300x213.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-768x545.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-1536x1090.png 1536w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image.png 1747w\" sizes=\"(max-width: 473px) 100vw, 473px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-left\"><strong> In the above graph, we have five nodes &#8211; 0, 1, 2, 3 and 4 and five edges &#8211; (0,1), (1,2), (2,3), (3,0) and (4,0). We will construct an adjacency list for the above graph. <\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-1-1024x727.png\" alt=\"Adjacency List Python \" class=\"wp-image-12999\" width=\"525\" height=\"372\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-1-1024x727.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-1-300x213.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-1-768x545.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-1-1536x1090.png 1536w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-1.png 1747w\" sizes=\"(max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p>In the above image, the adjacency list has been represented in the form of a linked list. We have all the nodes mentioned on the left-hand side of the image. On the right side of the arrow, we have a list of all the adjacent nodes for the node given on the left. <\/p>\n\n\n\n<p>The size of the list in the above case is the number of nodes, i.e., 5. If the graph had weights, then each edge would be represented in the form of a pair value: <strong><em>(node_no , weight)<\/em> <\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Lets us consider the weighted form of the above graph:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"727\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-2-1024x727.png\" alt=\"Adjacency List Python \" class=\"wp-image-13001\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-2-1024x727.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-2-300x213.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-2-768x545.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-2-1536x1090.png 1536w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-2.png 1747w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>Then, we would represent each edge as a pair. <\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"727\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-3-1024x727.png\" alt=\"edge as a pair.\" class=\"wp-image-13003\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-3-1024x727.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-3-300x213.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-3-768x545.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-3-1536x1090.png 1536w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/image-3.png 1747w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>For node 0, it is connected to node 1, 3 and 4. The weight of each edge for <em>1, 3 and 4<\/em> is <em>2, 5 and 1 <\/em>respectively. <\/p>\n\n\n\n<p><strong>So, we will represent each node-weight pair as <em>(1,2), (3,5) and (4,1)<\/em>. We will store each node in a similar way.   <\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-creating-an-adjacency-list-using-python\"><span class=\"ez-toc-section\" id=\"Creating_an_adjacency_list_Using_Python\"><\/span>Creating an adjacency list Using Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here, we will be creating an adjacency list from a graph using python. We will store our list in a python dictionary. Also, we will be creating an adjacency list for both &#8211; directed unweighted graph and directed weighted graph.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-directed-unweighted-graph\"><span class=\"ez-toc-section\" id=\"Directed_Unweighted_Graph\"><\/span>Directed Unweighted Graph<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/0-6-2-1024x727.jpg\" alt=\"Directed Unweighted Graph\" class=\"wp-image-13018\" width=\"549\" height=\"389\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/0-6-2-1024x727.jpg 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/0-6-2-300x213.jpg 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/0-6-2-768x545.jpg 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/0-6-2-1536x1090.jpg 1536w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/0-6-2.jpg 1747w\" sizes=\"(max-width: 549px) 100vw, 549px\" \/><\/figure>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nadj_list = {}\nmylist = &#x5B;]\ndef add_node(node):\n  if node not in mylist:\n    mylist.append(node)\n  else:\n    print(&quot;Node &quot;,node,&quot; already exists!&quot;)\n\ndef add_edge(node1, node2):\n  temp = &#x5B;]\n  if node1 in mylist and node2 in mylist:\n    if node1 not in adj_list:\n      temp.append(node2)\n      adj_list&#x5B;node1] = temp\n  \n    elif node1 in adj_list:\n      temp.extend(adj_list&#x5B;node1])\n      temp.append(node2)\n      adj_list&#x5B;node1] = temp\n      \n  else:\n    print(&quot;Nodes don't exist!&quot;)\n\ndef graph():\n  for node in adj_list:\n    print(node, &quot; ---&gt; &quot;, &#x5B;i for i in adj_list&#x5B;node]])\n\n#Adding nodes\nadd_node(0)\nadd_node(1)\nadd_node(2)\nadd_node(3)\nadd_node(4)\n#Adding edges\nadd_edge(0,1)\nadd_edge(1,2)\nadd_edge(2,3)\nadd_edge(3,0)\nadd_edge(3,4)\nadd_edge(4,0)\n\n#Printing the graph\ngraph()\n\n#Printing the adjacency list\nprint(adj_list)\n<\/pre><\/div>\n\n\n<p><strong>In the above code, we have three user defined functions &#8211; <em>add_node()<\/em>, <em>add_edge() <\/em>and <em>graph()<\/em><\/strong><\/p>\n\n\n\n<ul><li><strong><em>add_node()<\/em> accepts one parameter which is the name of the node. Before adding any edge, the node should be added through the function <em>add_node()<\/em><\/strong><\/li><li><strong><em>add_edge()<\/em> accepts two parameters &#8211; <em>node1<\/em> and <em>node2<\/em>. These are the two nodes between whom an edge has to be created<\/strong><\/li><li><strong><em>graph() <\/em>accepts no parameters. It simple prints the graph <\/strong><\/li><\/ul>\n\n\n\n<p>We have a list named <em>mylist<\/em>. Inside this list all the nodes will be added first when <em>add_node()<\/em> function is called. Since each node should be unique, the <em>add_node()<\/em> function will print a message saying that &#8216;The node exists&#8217; if it is already present in <em>mylist<\/em>. <\/p>\n\n\n\n<p>In the function <em>add_edge()<\/em>, first we will check if <em>node1<\/em> and <em>node2<\/em> are present in the list. An edge will be created only if the two nodes have been added. <\/p>\n\n\n\n<p>If node1 has no edges present in the graph, then we will create node1 as a new key. If node1 already has some edges present, then we will replace the value of the already existing key. adj_list[0] will have all the nodes which are connected to node &#8216;0&#8217;, adj_list[1] will have all the nodes connected to node &#8216;1&#8217;, and so on. <\/p>\n\n\n\n<p>In the <em>graph()<\/em> function, we are simply print the entire graph. Fibrerst, we will create each node individually by calling <em>add_nobrde()<\/em> function. Then, we will create its edges accordingly. After that, we will print the graph and the dictionary <em>adj_list<\/em> which is the adjacency list. <\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>The output of the above code is:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">0  ---&gt;  [1]\n1  ---&gt;  [2]\n2  ---&gt;  [3]\n3  ---&gt;  [0, 4]\n4  ---&gt;  [0]\n\n{0: [1], 1: [2], 2: [3], 3: [0, 4], 4: [0]}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-directed-weighted-graph\"><span class=\"ez-toc-section\" id=\"Directed_Weighted_Graph\"><\/span>Directed Weighted Graph<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The code we will be executing here will be for a weighted graph. The difference between weighted and unweighted graphs is that the edges in weighted graphs have values to them. <\/p>\n\n\n\n<p>So, the only change in the code will be in the <em>add_edge() <\/em>function. Instead of taking two parameters, it will now take three parameters. <\/p>\n\n\n\n<p>The third parameter will be the weight of the edge. While appending to the dictionary, we will append the node-weight pair as a list. <\/p>\n\n\n\n<p>While accessing the list, we will be passing three parameters &#8211; <em>node1, node2<\/em> and the <em>weight<\/em>. <\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>The weighted directed graph is:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/0-8-1024x727.jpg\" alt=\"The weighted directed graph\" class=\"wp-image-13022\" width=\"572\" height=\"406\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/0-8-1024x727.jpg 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/0-8-300x213.jpg 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/0-8-768x545.jpg 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/0-8-1536x1090.jpg 1536w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/0-8.jpg 1747w\" sizes=\"(max-width: 572px) 100vw, 572px\" \/><\/figure>\n\n\n\n<p><strong>The code for weighted directed graph is:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nadj_list = {}\nmylist = &#x5B;]\ndef add_node(node):\n  if node not in mylist:\n    mylist.append(node)\n  else:\n    print(&quot;Node &quot;,node,&quot; already exists!&quot;)\n\ndef add_edge(node1, node2, weight):\n  temp = &#x5B;]\n  if node1 in mylist and node2 in mylist:\n    if node1 not in adj_list:\n      temp.append(&#x5B;node2,weight])\n      adj_list&#x5B;node1] = temp\n  \n    elif node1 in adj_list:\n      temp.extend(adj_list&#x5B;node1])\n      temp.append(&#x5B;node2,weight])\n      adj_list&#x5B;node1] = temp\n      \n  else:\n    print(&quot;Nodes don't exist!&quot;)\n\ndef graph():\n  for node in adj_list:\n    print(node, &quot; ---&gt; &quot;, &#x5B;i for i in adj_list&#x5B;node]])\n\n#Adding nodes\nadd_node(0)\nadd_node(1)\nadd_node(2)\nadd_node(3)\nadd_node(4)\n#Adding edges\nadd_edge(0,1,2)\nadd_edge(1,2,2)\nadd_edge(2,3,4)\nadd_edge(3,0,5)\nadd_edge(3,4,3)\nadd_edge(4,0,1)\n\n#Printing the graph\ngraph()\n\n#Printing the adjacency list\nprint(adj_list)\n<\/pre><\/div>\n\n\n<p><strong>The output will be:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">0  ---&gt;  [[1, 2]]\n1  ---&gt;  [[2, 2]]\n2  ---&gt;  [[3, 4]]\n3  ---&gt;  [[0, 5], [4, 3]]\n4  ---&gt;  [[0, 1]]\n\n{0: [[1, 2]], 1: [[2, 2]], 2: [[3, 4]], 3: [[0, 5], [4, 3]], 4: [[0, 1]]}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-must-read\"><span class=\"ez-toc-section\" id=\"Must_Read\"><\/span>Must Read:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-yoast-seo-related-links\"><li><a href=\"https:\/\/www.pythonpool.com\/kruskals-algorithm-python\/\">Kruskal&#8217;s algorithm: Implementation in Python<\/a><\/li><li><a href=\"https:\/\/www.pythonpool.com\/dijkstras-algorithm-python\/\">Implementing Dijkstra&#8217;s Algorithm in Python<\/a><\/li><li><a href=\"https:\/\/www.pythonpool.com\/doubly-linked-list-in-python\/\">Doubly Linked List in Python &#8211; Advanced Data Structure<\/a><\/li><li><a href=\"https:\/\/www.pythonpool.com\/bfs-python\/\">How to Implement Breadth-First Search (BFS) using Python<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-dijkstra-s-algorithm-using-adjacency-list\"><span class=\"ez-toc-section\" id=\"Dijkstras_Algorithm_using_Adjacency_list\"><\/span>Dijkstra&#8217;s Algorithm using Adjacency list<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><span style=\"text-decoration: underline;\"><a href=\"https:\/\/www.pythonpool.com\/dijkstras-algorithm-python\/\" target=\"_blank\" rel=\"noreferrer noopener\">Dijkstra&#8217;s algorithm<\/a><\/span> is used to find the shortest path between two nodes of a weighted graph. We can use an adjacency list for representing the graph while implementing Dijkstra&#8217;s algorithm. <\/p>\n\n\n\n<p>The adjacency list will contain a pair of adjacent nodes for any given node and their respective weights. When implemented with python dictionary, each <a href=\"https:\/\/en.wikipedia.org\/wiki\/Associative_array\" target=\"_blank\" rel=\"noreferrer noopener\">dictionary<\/a> key would represent all the paths possible from that node along with its path cost.<\/p>\n\n\n\n<p>Instead of checking if an edge exists between two given nodes, with an adjacency matrix, each node will have a list of all the nodes with which it is connected. <\/p>\n\n\n\n<p><strong>To check all the connected nodes for a particular node, we won&#8217;t have to check all the nodes. <\/strong>While storing the weights of two edges with different values, adjacency lists come in handy. <\/p>\n\n\n\n<p>Suppose the cost to go from node &#8216;0&#8217; to node &#8216;1&#8217; is different from the cost to go from node &#8216;1&#8217; to node &#8216;0&#8217;, we can use adjacency lists to store different edge costs under different keys of the dictionary. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-faq-s\"><span class=\"ez-toc-section\" id=\"FAQs\"><\/span>FAQ&#8217;s<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1622542284534\"><strong class=\"schema-faq-question\">Which is better &#8211; adjacency matrix or adjacency list?<br\/><\/strong> <p class=\"schema-faq-answer\">Adjacency list has the upper hand over the adjacency matrix because of its efficiency. An adjacency list occupies less memory space than an adjacency matrix. In addition, it is easier to <a href=\"https:\/\/www.pythonpool.com\/python-iterate-through-list\/\" target=\"_blank\" rel=\"noreferrer noopener\">iterate<\/a> over the edges in the adjacency list because the neighboring nodes for a given node can be accessed easily. Also, creating edges and nodes in a list is efficient compared to creating edges and nodes in a matrix. <\/p> <\/div> <\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>This covers Adjacency List in python. Do let us know your views on adjacency lists  in the comments below.<\/p>\n\n\n\n<p><em>Until then, Keep learning!<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A graph is a data structure consisting of nodes and edges. The nodes are the vertices sets in a graph representing the objects, and the &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"An In-depth Guide To Adjacency List in Python\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#more-12988\" aria-label=\"More on An In-depth Guide To Adjacency List in Python\">Read more<\/a><\/p>\n","protected":false},"author":20,"featured_media":13052,"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":[4147,4146,4145],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v22.4) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>An In-depth Guide To Adjacency List in Python - Python Pool<\/title>\n<meta name=\"description\" content=\"An adjacency list in python is a way for representation of graphs. It is efficient in terms of space compared to adjacency matrix.\" \/>\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\/adjacency-list-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"An In-depth Guide To Adjacency List in Python\" \/>\n<meta property=\"og:description\" content=\"A graph is a data structure consisting of nodes and edges. The nodes are the vertices sets in a graph representing the objects, and the edges are the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/adjacency-list-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-02T06:16:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-14T09:41:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/An-In-depth-Guide-To-Adjacency-List-in-Python-.jpg\" \/>\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\/jpeg\" \/>\n<meta name=\"author\" content=\"Dhruvi Vikma\" \/>\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=\"Dhruvi Vikma\" \/>\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:\/\/www.pythonpool.com\/adjacency-list-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/adjacency-list-python\/\"},\"author\":{\"name\":\"Dhruvi Vikma\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/bed8fc40c7b71baf7d76b1cfefd79f23\"},\"headline\":\"An In-depth Guide To Adjacency List in Python\",\"datePublished\":\"2021-06-02T06:16:03+00:00\",\"dateModified\":\"2021-06-14T09:41:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/adjacency-list-python\/\"},\"wordCount\":1142,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/An-In-depth-Guide-To-Adjacency-List-in-Python-.jpg\",\"keywords\":[\"adjacency list in python\",\"python adjacency list\",\"python create adjacency list\"],\"articleSection\":[\"Algorithm\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#respond\"]}]},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/www.pythonpool.com\/adjacency-list-python\/\",\"url\":\"https:\/\/www.pythonpool.com\/adjacency-list-python\/\",\"name\":\"An In-depth Guide To Adjacency List in Python - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/An-In-depth-Guide-To-Adjacency-List-in-Python-.jpg\",\"datePublished\":\"2021-06-02T06:16:03+00:00\",\"dateModified\":\"2021-06-14T09:41:30+00:00\",\"description\":\"An adjacency list in python is a way for representation of graphs. It is efficient in terms of space compared to adjacency matrix.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#faq-question-1622542284534\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/adjacency-list-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/An-In-depth-Guide-To-Adjacency-List-in-Python-.jpg\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/An-In-depth-Guide-To-Adjacency-List-in-Python-.jpg\",\"width\":1350,\"height\":650,\"caption\":\"adjacency list python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"An In-depth Guide To Adjacency List 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\":\"required name=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\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"https:\/\/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:\/\/twitter.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/bed8fc40c7b71baf7d76b1cfefd79f23\",\"name\":\"Dhruvi Vikma\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/be16ea990b460da532c2b8cc5b8b658c?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/be16ea990b460da532c2b8cc5b8b658c?s=96&d=wavatar&r=g\",\"caption\":\"Dhruvi Vikma\"}},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#faq-question-1622542284534\",\"position\":1,\"url\":\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#faq-question-1622542284534\",\"name\":\"Which is better - adjacency matrix or adjacency list?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Adjacency list has the upper hand over the adjacency matrix because of its efficiency. An adjacency list occupies less memory space than an adjacency matrix. In addition, it is easier to iterate over the edges in the adjacency list because the neighboring nodes for a given node can be accessed easily. Also, creating edges and nodes in a list is efficient compared to creating edges and nodes in a matrix. \",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"An In-depth Guide To Adjacency List in Python - Python Pool","description":"An adjacency list in python is a way for representation of graphs. It is efficient in terms of space compared to adjacency matrix.","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:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/","og_locale":"en_US","og_type":"article","og_title":"An In-depth Guide To Adjacency List in Python","og_description":"A graph is a data structure consisting of nodes and edges. The nodes are the vertices sets in a graph representing the objects, and the edges are the","og_url":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/","og_site_name":"Python Pool","article_published_time":"2021-06-02T06:16:03+00:00","article_modified_time":"2021-06-14T09:41:30+00:00","og_image":[{"width":1350,"height":650,"url":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/An-In-depth-Guide-To-Adjacency-List-in-Python-.jpg","type":"image\/jpeg"}],"author":"Dhruvi Vikma","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Dhruvi Vikma","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/#article","isPartOf":{"@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/"},"author":{"name":"Dhruvi Vikma","@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/#\/schema\/person\/bed8fc40c7b71baf7d76b1cfefd79f23"},"headline":"An In-depth Guide To Adjacency List in Python","datePublished":"2021-06-02T06:16:03+00:00","dateModified":"2021-06-14T09:41:30+00:00","mainEntityOfPage":{"@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/"},"wordCount":1142,"commentCount":0,"publisher":{"@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/#primaryimage"},"thumbnailUrl":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/An-In-depth-Guide-To-Adjacency-List-in-Python-.jpg","keywords":["adjacency list in python","python adjacency list","python create adjacency list"],"articleSection":["Algorithm","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/#respond"]}]},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/","url":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/","name":"An In-depth Guide To Adjacency List in Python - Python Pool","isPartOf":{"@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/#primaryimage"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/#primaryimage"},"thumbnailUrl":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/An-In-depth-Guide-To-Adjacency-List-in-Python-.jpg","datePublished":"2021-06-02T06:16:03+00:00","dateModified":"2021-06-14T09:41:30+00:00","description":"An adjacency list in python is a way for representation of graphs. It is efficient in terms of space compared to adjacency matrix.","breadcrumb":{"@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/#faq-question-1622542284534"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/#primaryimage","url":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/An-In-depth-Guide-To-Adjacency-List-in-Python-.jpg","contentUrl":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/06\/An-In-depth-Guide-To-Adjacency-List-in-Python-.jpg","width":1350,"height":650,"caption":"adjacency list python"},{"@type":"BreadcrumbList","@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"An In-depth Guide To Adjacency List in Python"}]},{"@type":"WebSite","@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/#website","url":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/twitter.com\/pythonpool","https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/#\/schema\/person\/bed8fc40c7b71baf7d76b1cfefd79f23","name":"Dhruvi Vikma","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/secure.gravatar.com\/avatar\/be16ea990b460da532c2b8cc5b8b658c?s=96&d=wavatar&r=g","contentUrl":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/secure.gravatar.com\/avatar\/be16ea990b460da532c2b8cc5b8b658c?s=96&d=wavatar&r=g","caption":"Dhruvi Vikma"}},{"@type":"Question","@id":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/#faq-question-1622542284534","position":1,"url":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/adjacency-list-python\/#faq-question-1622542284534","name":"Which is better - adjacency matrix or adjacency list?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Adjacency list has the upper hand over the adjacency matrix because of its efficiency. An adjacency list occupies less memory space than an adjacency matrix. In addition, it is easier to iterate over the edges in the adjacency list because the neighboring nodes for a given node can be accessed easily. Also, creating edges and nodes in a list is efficient compared to creating edges and nodes in a matrix. ","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/12988"}],"collection":[{"href":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=12988"}],"version-history":[{"count":25,"href":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/12988\/revisions"}],"predecessor-version":[{"id":13518,"href":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/12988\/revisions\/13518"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/13052"}],"wp:attachment":[{"href":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=12988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=12988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=12988"}],"curies":[{"name":"wp","href":"https:\/\/web.archive.org\/web\/20240926032626\/https:\/\/api.w.org\/{rel}","templated":true}]}}