{"id":12988,"date":"2021-06-02T11:46:03","date_gmt":"2021-06-02T06:16:03","guid":{"rendered":"http:\/\/www.pythonpool.com\/?p=12988"},"modified":"2026-07-13T12:34:39","modified_gmt":"2026-07-13T07:04:39","slug":"adjacency-list-python","status":"publish","type":"post","link":"https:\/\/www.pythonpool.com\/adjacency-list-python\/","title":{"rendered":"Adjacency List in Python: Directed, Weighted, BFS, and DFS Graphs"},"content":{"rendered":"<p><strong>Quick answer:<\/strong> An adjacency list maps each graph node to its neighbors, usually with a dictionary. Lists preserve insertion order and can represent duplicate edges, sets enforce unique neighbors, and nested dictionaries can store weights or other edge data. Add both directions for an undirected edge, then use a queue for BFS or a stack for DFS while tracking visited nodes.<\/p>\n<figure class=\"pythonpool-article-visual\"><img src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/adjacency-list-python.png\" alt=\"Python Pool infographic showing adjacency list graph nodes edges directed weighted representation and BFS DFS traversal\" width=\"1536\" height=\"1024\" loading=\"lazy\" decoding=\"async\"><figcaption>An adjacency list stores each node&#8217;s neighbors; choose list, set, or weighted dictionaries based on duplicates, edge data, and traversal needs.<\/figcaption><\/figure>\n<p>An adjacency list is a graph representation where each node stores the nodes connected to it. In Python, this usually means a dictionary whose keys are nodes and whose values are lists, sets, or dictionaries of neighbors.<\/p>\n<p>Adjacency lists are compact for sparse graphs because they store only existing edges. They are also natural for traversal algorithms such as breadth-first search, depth-first search, shortest paths, and minimum spanning tree algorithms.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 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\/adjacency-list-python\/#Basic_adjacency_list_in_Python\" >Basic adjacency list in Python<\/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\/#Directed_vs_undirected_adjacency_lists\" >Directed vs undirected adjacency lists<\/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\/#Use_sets_to_avoid_duplicate_neighbors\" >Use sets to avoid duplicate neighbors<\/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\/adjacency-list-python\/#Create_an_adjacency_list_with_defaultdict\" >Create an adjacency list with defaultdict<\/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\/adjacency-list-python\/#Weighted_adjacency_list\" >Weighted adjacency list<\/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\/adjacency-list-python\/#BFS_with_an_adjacency_list\" >BFS with an adjacency list<\/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\/#Adjacency_list_vs_adjacency_matrix\" >Adjacency list vs adjacency matrix<\/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\/#Using_graph_libraries\" >Using graph libraries<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#Common_mistakes\" >Common mistakes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#Build_Directed_And_Undirected_Edges\" >Build Directed And Undirected Edges<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#Store_Weighted_Neighbors\" >Store Weighted Neighbors<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#Traverse_With_Breadth_First_Search\" >Traverse With Breadth First Search<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#Traverse_With_Depth_First_Search\" >Traverse With Depth First Search<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#Frequently_Asked_Questions\" >Frequently Asked Questions<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#What_is_an_adjacency_list_in_Python\" >What is an adjacency list in Python?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#How_do_I_represent_an_undirected_edge\" >How do I represent an undirected edge?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#Should_adjacency-list_neighbors_be_lists_or_sets\" >Should adjacency-list neighbors be lists or sets?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/www.pythonpool.com\/adjacency-list-python\/#How_do_BFS_and_DFS_use_an_adjacency_list\" >How do BFS and DFS use an adjacency list?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Basic_adjacency_list_in_Python\"><\/span>Basic adjacency list in Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>For an unweighted graph, a dictionary of lists is the simplest structure. Each key is a node, and each list contains neighboring nodes.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">graph = {\n    \"A\": [\"B\", \"C\"],\n    \"B\": [\"D\"],\n    \"C\": [\"D\"],\n    \"D\": [],\n}\n\nprint(graph[\"A\"])<\/code><\/pre>\n<\/div>\n<p>This representation is easy to read and works well for small examples. The Python tutorial section on <a href=\"https:\/\/docs.python.org\/3\/tutorial\/datastructures.html#dictionaries\">dictionaries<\/a> explains the mapping behavior behind this pattern.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Directed_vs_undirected_adjacency_lists\"><\/span>Directed vs undirected adjacency lists<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In a directed graph, an edge from <code>A<\/code> to <code>B<\/code> is stored only under <code>A<\/code>. In an undirected graph, the edge is stored in both directions.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">def add_undirected_edge(graph, left, right):\n    graph.setdefault(left, []).append(right)\n    graph.setdefault(right, []).append(left)\n\ngraph = {}\nadd_undirected_edge(graph, \"A\", \"B\")\nadd_undirected_edge(graph, \"A\", \"C\")\n\nprint(graph)<\/code><\/pre>\n<\/div>\n<p>Use a directed list for one-way relationships such as dependencies, routes, or state transitions. Use an undirected list for mutual relationships such as friendships, two-way roads, or simple network connections.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Use_sets_to_avoid_duplicate_neighbors\"><\/span>Use sets to avoid duplicate neighbors<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>If duplicate edges are possible, store neighbors in a set instead of a list. A set keeps each neighbor only once and gives fast membership checks.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">graph = {\n    \"A\": {\"B\", \"C\"},\n    \"B\": {\"A\", \"D\"},\n    \"C\": {\"A\"},\n    \"D\": {\"B\"},\n}\n\nif \"C\" in graph[\"A\"]:\n    print(\"A is connected to C\")<\/code><\/pre>\n<\/div>\n<p>Lists preserve insertion order and are convenient for examples. Sets are better when you care more about uniqueness and membership tests than neighbor order.<\/p>\n<p><!-- Python Pool visual layout repair 2026-07-13 --><\/p>\n<figure class=\"pythonpool-article-visual pythonpool-supporting-visual\"><img src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/adjacency-list-python-model-b126.png\" alt=\"Python Pool infographic showing adjacency-list vertices, neighbors, weights, and direction\" width=\"1536\" height=\"1054\" loading=\"lazy\" decoding=\"async\"><figcaption>List model: Adjacency-list vertices, neighbors, weights, and direction.<\/figcaption><\/figure>\n<h2><span class=\"ez-toc-section\" id=\"Create_an_adjacency_list_with_defaultdict\"><\/span>Create an adjacency list with defaultdict<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><code>collections.defaultdict<\/code> makes graph construction cleaner because missing keys create an empty neighbor container automatically.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">from collections import defaultdict\n\ngraph = defaultdict(list)\nedges = [(\"A\", \"B\"), (\"A\", \"C\"), (\"B\", \"D\")]\n\nfor source, target in edges:\n    graph.append(target)\n\nprint(dict(graph))<\/code><\/pre>\n<\/div>\n<p>The official <a href=\"https:\/\/docs.python.org\/3\/library\/collections.html#collections.defaultdict\">defaultdict documentation<\/a> covers the container. For nested mapping patterns, see Python Pool&#8217;s <a href=\"https:\/\/www.pythonpool.com\/nested-dictionary-python\/\">nested dictionary in Python<\/a> guide.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Weighted_adjacency_list\"><\/span>Weighted adjacency list<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Weighted graphs need to store both the neighbor and the edge weight. A dictionary of dictionaries is a clear representation.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">weighted_graph = {\n    \"A\": {\"B\": 4, \"C\": 2},\n    \"B\": {\"D\": 5},\n    \"C\": {\"B\": 1, \"D\": 8},\n    \"D\": {},\n}\n\nprint(weighted_graph[\"A\"][\"C\"])<\/code><\/pre>\n<\/div>\n<p>This structure is common in shortest-path code because you can iterate over each neighbor and weight together.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">for neighbor, weight in weighted_graph[\"A\"].items():\n    print(neighbor, weight)<\/code><\/pre>\n<\/div>\n<p>For a complete shortest-path implementation, see Python Pool&#8217;s <a href=\"https:\/\/www.pythonpool.com\/dijkstras-algorithm-python\/\">Dijkstra&#8217;s algorithm in Python<\/a>. Python&#8217;s official <a href=\"https:\/\/docs.python.org\/3\/library\/heapq.html\">heapq documentation<\/a> is also useful because priority queues are often used with weighted adjacency lists.<\/p>\n<figure class=\"pythonpool-article-visual pythonpool-supporting-visual\"><img src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/adjacency-list-python-build-b126.png\" alt=\"Python Pool infographic showing adjacency-list edges, duplicate links, keys, and insertion\" width=\"1536\" height=\"1054\" loading=\"lazy\" decoding=\"async\"><figcaption>Build graph: Adjacency-list edges, duplicate links, keys, and insertion.<\/figcaption><\/figure>\n<h2><span class=\"ez-toc-section\" id=\"BFS_with_an_adjacency_list\"><\/span>BFS with an adjacency list<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Breadth-first search works naturally with an adjacency list because each step asks for the current node&#8217;s neighbors.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">from collections import deque\n\ndef bfs(graph, start):\n    visited = {start}\n    queue = deque([start])\n    order = []\n\n    while queue:\n        node = queue.popleft()\n        order.append(node)\n\n        for neighbor in graph.get(node, []):\n            if neighbor not in visited:\n                visited.add(neighbor)\n                queue.append(neighbor)\n\n    return order\n\nprint(bfs(graph, \"A\"))<\/code><\/pre>\n<\/div>\n<p>Python Pool&#8217;s <a href=\"https:\/\/www.pythonpool.com\/bfs-python\/\">BFS in Python<\/a> guide covers traversal in more detail. If your algorithm needs a priority queue rather than a FIFO queue, see <a href=\"https:\/\/www.pythonpool.com\/python-priority-queue\/\">Python priority queue<\/a>.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Adjacency_list_vs_adjacency_matrix\"><\/span>Adjacency list vs adjacency matrix<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>An adjacency matrix stores a grid of all possible node pairs. That can be useful for dense graphs or matrix-based algorithms, but it uses more space when most pairs are not connected. An adjacency list stores only existing edges, so it is usually better for sparse graphs.<\/p>\n<p>Use an adjacency list when you need to iterate through neighbors quickly. Use a matrix when the graph is small, dense, or when constant-time edge lookup across every possible pair is more important than memory use.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Using_graph_libraries\"><\/span>Using graph libraries<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>For production graph analysis, a library can save time. NetworkX uses graph objects with methods for nodes, edges, neighbors, and many algorithms. The NetworkX <a href=\"https:\/\/networkx.org\/documentation\/stable\/reference\/classes\/graph.html\">Graph reference<\/a> is a good starting point when your graph grows beyond a few helper functions.<\/p>\n<p>For minimum spanning tree examples, see Python Pool&#8217;s <a href=\"https:\/\/www.pythonpool.com\/kruskals-algorithm-python\/\">Kruskal&#8217;s algorithm in Python<\/a>. For pointer-based data structures, the <a href=\"https:\/\/www.pythonpool.com\/doubly-linked-list-in-python\/\">doubly linked list<\/a> guide is related but solves a different problem than graph adjacency.<\/p>\n<figure class=\"pythonpool-article-visual pythonpool-supporting-visual\"><img src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/adjacency-list-python-traverse-b126.png\" alt=\"Python Pool infographic showing adjacency-list BFS, DFS, visited set, and frontier\" width=\"1536\" height=\"1054\" loading=\"lazy\" decoding=\"async\"><figcaption>Traverse: Adjacency-list BFS, DFS, visited set, and frontier.<\/figcaption><\/figure>\n<h2><span class=\"ez-toc-section\" id=\"Common_mistakes\"><\/span>Common mistakes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><strong>Forgetting isolated nodes.<\/strong> Add nodes with empty neighbor lists when they have no outgoing edges but still belong to the graph.<\/p>\n<p><strong>Mixing directed and undirected logic.<\/strong> Decide whether edges should be one-way or two-way before building helper functions.<\/p>\n<p><strong>Duplicating edges accidentally.<\/strong> Use sets if repeated inserts are possible and duplicates would break your traversal.<\/p>\n<p><strong>Storing weights inconsistently.<\/strong> For weighted graphs, pick one representation and keep it consistent across every edge.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>An adjacency list is the most practical graph representation for many Python programs. Use a dictionary of lists for simple directed graphs, sets for unique neighbors, and dictionaries of dictionaries for weighted edges. This structure keeps graph code readable and works well with BFS, Dijkstra&#8217;s algorithm, and many other graph algorithms.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Build_Directed_And_Undirected_Edges\"><\/span>Build Directed And Undirected Edges<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>A directed edge is stored once, from source to target. An undirected edge is represented twice so traversal can move both ways. setdefault keeps the helper usable when a node has not appeared yet.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">def add_directed_edge(graph, source, target):\n    graph.setdefault(source, set()).add(target)\n\n\ndef add_undirected_edge(graph, left, right):\n    graph.setdefault(left, set()).add(right)\n    graph.setdefault(right, set()).add(left)\n\n\ngraph = {}\nadd_undirected_edge(graph, \"A\", \"B\")\nadd_directed_edge(graph, \"A\", \"C\")\nprint(graph)\n<\/code><\/pre>\n<\/div>\n<figure class=\"pythonpool-article-visual pythonpool-supporting-visual\"><img src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/adjacency-list-python-check-b126.png\" alt=\"Python Pool infographic checking adjacency-list missing nodes, cycles, weights, and tests\" width=\"1536\" height=\"1054\" loading=\"lazy\" decoding=\"async\"><figcaption>Graph checks: Python Pool infographic checking adjacency-list missing nodes, cycles, weights, and tests.<\/figcaption><\/figure>\n<h2><span class=\"ez-toc-section\" id=\"Store_Weighted_Neighbors\"><\/span>Store Weighted Neighbors<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>When an edge has a cost, label, or capacity, a neighbor value can be another dictionary. Keep the representation consistent so algorithms do not have to guess whether a neighbor is a node or an edge record.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">graph = {\n    \"A\": {\"B\": 4, \"C\": 2},\n    \"B\": {\"D\": 3},\n    \"C\": {\"D\": 1},\n    \"D\": {},\n}\n\nfor neighbor, weight in graph[\"A\"].items():\n    print(neighbor, weight)\n<\/code><\/pre>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Traverse_With_Breadth_First_Search\"><\/span>Traverse With Breadth First Search<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>BFS uses a queue and records a node when it is enqueued. Marking it visited at that point prevents duplicate work and gives shortest edge-count distances in an unweighted graph.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">from collections import deque\n\n\ndef bfs(graph, start):\n    queue = deque([start])\n    visited = {start}\n    order = []\n    while queue:\n        node = queue.popleft()\n        order.append(node)\n        for neighbor in graph.get(node, set()):\n            if neighbor not in visited:\n                visited.add(neighbor)\n                queue.append(neighbor)\n    return order\n\nprint(bfs({\"A\": {\"B\", \"C\"}, \"B\": {\"D\"}, \"C\": set(), \"D\": set()}, \"A\"))\n<\/code><\/pre>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Traverse_With_Depth_First_Search\"><\/span>Traverse With Depth First Search<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>DFS can use an explicit stack to avoid recursion-depth surprises. The visited set is still essential when cycles are possible, because a graph is not necessarily a tree.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">def dfs(graph, start):\n    stack = [start]\n    visited = set()\n    order = []\n    while stack:\n        node = stack.pop()\n        if node in visited:\n            continue\n        visited.add(node)\n        order.append(node)\n        stack.extend(reversed(tuple(graph.get(node, set()))))\n    return order\n\nprint(dfs({\"A\": {\"B\", \"C\"}, \"B\": {\"A\"}, \"C\": set()}, \"A\"))\n<\/code><\/pre>\n<\/div>\n<p>Python&#8217;s official <a href=\"https:\/\/docs.python.org\/3\/tutorial\/datastructures.html#dictionaries\">dictionary documentation<\/a> explains the mapping structure commonly used for adjacency lists. Related references include <a href=\"https:\/\/www.pythonpool.com\/bfs-python\/\">breadth-first search<\/a>, <a href=\"https:\/\/www.pythonpool.com\/python-list-intersection\/\">list intersection<\/a>, and <a href=\"2\">sets for unique neighbors<\/a>.<\/p>\n<p>For related graph traversal and neighbor storage, compare <a href=\"https:\/\/www.pythonpool.com\/bfs-python\/\">BFS<\/a>, <a href=\"https:\/\/www.pythonpool.com\/python-list-intersection\/\">list intersection<\/a>, and <a href=\"2\">sets<\/a> when choosing an adjacency-list representation.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Frequently_Asked_Questions\"><\/span>Frequently Asked Questions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"What_is_an_adjacency_list_in_Python\"><\/span>What is an adjacency list in Python?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>It is usually a dictionary mapping each graph node to a collection of neighboring nodes or edge records.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_do_I_represent_an_undirected_edge\"><\/span>How do I represent an undirected edge?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Add each endpoint to the other endpoint&#8217;s neighbor collection so traversal can move in both directions.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Should_adjacency-list_neighbors_be_lists_or_sets\"><\/span>Should adjacency-list neighbors be lists or sets?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Use lists when edge order or duplicate edges matter, and sets when neighbor uniqueness and fast membership checks matter.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_do_BFS_and_DFS_use_an_adjacency_list\"><\/span>How do BFS and DFS use an adjacency list?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>They repeatedly look up the current node&#8217;s neighbors, using a queue for breadth-first traversal or a stack\/recursion for depth-first traversal.<\/p>\n<p><script type=\"application\/ld+json\">{\"@context\":\"https:\/\/schema.org\",\"@type\":\"FAQPage\",\"mainEntity\":[{\"@type\":\"Question\",\"name\":\"What is an adjacency list in Python?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"It is usually a dictionary mapping each graph node to a collection of neighboring nodes or edge records.\"}},{\"@type\":\"Question\",\"name\":\"How do I represent an undirected edge?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Add each endpoint to the other endpoint's neighbor collection so traversal can move in both directions.\"}},{\"@type\":\"Question\",\"name\":\"Should adjacency-list neighbors be lists or sets?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Use lists when edge order or duplicate edges matter, and sets when neighbor uniqueness and fast membership checks matter.\"}},{\"@type\":\"Question\",\"name\":\"How do BFS and DFS use an adjacency list?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"They repeatedly look up the current node's neighbors, using a queue for breadth-first traversal or a stack\/recursion for depth-first traversal.\"}}]}<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Represent Python graphs with adjacency lists, add directed or weighted edges, avoid duplicates, and traverse with BFS or DFS safely.<\/p>\n","protected":false},"author":20,"featured_media":32331,"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],"class_list":["post-12988","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-algorithm","category-tutorials","tag-adjacency-list-in-python","tag-python-adjacency-list","tag-python-create-adjacency-list","infinite-scroll-item"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v28.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Adjacency List in Python: Directed, Weighted, BFS, and DFS Graphs<\/title>\n<meta name=\"description\" content=\"Represent Python graphs with adjacency lists, add directed or weighted edges, avoid duplicates, and traverse with BFS or DFS safely.\" \/>\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=\"Adjacency List in Python: Directed, Weighted, BFS, and DFS Graphs\" \/>\n<meta property=\"og:description\" content=\"Represent Python graphs with adjacency lists, add directed or weighted edges, avoid duplicates, and traverse with BFS or DFS safely.\" \/>\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=\"2026-07-13T07:04:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/adjacency-list-python.png\" \/>\n<meta name=\"author\" content=\"Dhruvi Vikma\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Python Pool\" \/>\n<meta name=\"twitter:description\" content=\"Practical Python tutorials, error fixes, code examples, and project guides.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/adjacency-list-python.png\" \/>\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\":\"Adjacency List in Python: Directed, Weighted, BFS, and DFS Graphs\",\"datePublished\":\"2021-06-02T06:16:03+00:00\",\"dateModified\":\"2026-07-13T07:04:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/adjacency-list-python\\\/\"},\"wordCount\":1119,\"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\\\/2026\\\/07\\\/adjacency-list-python-guide-pythonpool.png\",\"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\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/adjacency-list-python\\\/\",\"url\":\"https:\\\/\\\/www.pythonpool.com\\\/adjacency-list-python\\\/\",\"name\":\"Adjacency List in Python: Directed, Weighted, BFS, and DFS Graphs\",\"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\\\/2026\\\/07\\\/adjacency-list-python-guide-pythonpool.png\",\"datePublished\":\"2021-06-02T06:16:03+00:00\",\"dateModified\":\"2026-07-13T07:04:39+00:00\",\"description\":\"Represent Python graphs with adjacency lists, add directed or weighted edges, avoid duplicates, and traverse with BFS or DFS safely.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/adjacency-list-python\\\/#breadcrumb\"},\"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\\\/2026\\\/07\\\/adjacency-list-python-guide-pythonpool.png\",\"contentUrl\":\"https:\\\/\\\/www.pythonpool.com\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/adjacency-list-python-guide-pythonpool.png\",\"width\":1350,\"height\":650,\"caption\":\"Python adjacency list guide showing graph nodes neighbors dictionary and weighted graph representation\"},{\"@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\":\"Adjacency List in Python: Directed, Weighted, BFS, and DFS Graphs\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#website\",\"url\":\"https:\\\/\\\/www.pythonpool.com\\\/\",\"name\":\"Python Pool\",\"description\":\"Practical Python tutorials, error fixes, code examples, and project guides.\",\"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\":\"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:\\\/\\\/x.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:\\\/\\\/secure.gravatar.com\\\/avatar\\\/520d8a37e8b6ce4e6df57e997dc0d571225f48098bbb02838c3884bb603e886f?s=96&d=wavatar&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/520d8a37e8b6ce4e6df57e997dc0d571225f48098bbb02838c3884bb603e886f?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/520d8a37e8b6ce4e6df57e997dc0d571225f48098bbb02838c3884bb603e886f?s=96&d=wavatar&r=g\",\"caption\":\"Dhruvi Vikma\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Adjacency List in Python: Directed, Weighted, BFS, and DFS Graphs","description":"Represent Python graphs with adjacency lists, add directed or weighted edges, avoid duplicates, and traverse with BFS or DFS safely.","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\/adjacency-list-python\/","og_locale":"en_US","og_type":"article","og_title":"Adjacency List in Python: Directed, Weighted, BFS, and DFS Graphs","og_description":"Represent Python graphs with adjacency lists, add directed or weighted edges, avoid duplicates, and traverse with BFS or DFS safely.","og_url":"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":"2026-07-13T07:04:39+00:00","og_image":[{"url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/adjacency-list-python.png","type":"","width":"","height":""}],"author":"Dhruvi Vikma","twitter_card":"summary_large_image","twitter_title":"Python Pool","twitter_description":"Practical Python tutorials, error fixes, code examples, and project guides.","twitter_image":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/adjacency-list-python.png","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Dhruvi Vikma","Est. reading time":"8 minutes"},"schema":{"@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":"Adjacency List in Python: Directed, Weighted, BFS, and DFS Graphs","datePublished":"2021-06-02T06:16:03+00:00","dateModified":"2026-07-13T07:04:39+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pythonpool.com\/adjacency-list-python\/"},"wordCount":1119,"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\/2026\/07\/adjacency-list-python-guide-pythonpool.png","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","@id":"https:\/\/www.pythonpool.com\/adjacency-list-python\/","url":"https:\/\/www.pythonpool.com\/adjacency-list-python\/","name":"Adjacency List in Python: Directed, Weighted, BFS, and DFS Graphs","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\/2026\/07\/adjacency-list-python-guide-pythonpool.png","datePublished":"2021-06-02T06:16:03+00:00","dateModified":"2026-07-13T07:04:39+00:00","description":"Represent Python graphs with adjacency lists, add directed or weighted edges, avoid duplicates, and traverse with BFS or DFS safely.","breadcrumb":{"@id":"https:\/\/www.pythonpool.com\/adjacency-list-python\/#breadcrumb"},"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\/2026\/07\/adjacency-list-python-guide-pythonpool.png","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/adjacency-list-python-guide-pythonpool.png","width":1350,"height":650,"caption":"Python adjacency list guide showing graph nodes neighbors dictionary and weighted graph representation"},{"@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":"Adjacency List in Python: Directed, Weighted, BFS, and DFS Graphs"}]},{"@type":"WebSite","@id":"https:\/\/www.pythonpool.com\/#website","url":"https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Practical Python tutorials, error fixes, code examples, and project guides.","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":"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:\/\/x.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:\/\/secure.gravatar.com\/avatar\/520d8a37e8b6ce4e6df57e997dc0d571225f48098bbb02838c3884bb603e886f?s=96&d=wavatar&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/520d8a37e8b6ce4e6df57e997dc0d571225f48098bbb02838c3884bb603e886f?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/520d8a37e8b6ce4e6df57e997dc0d571225f48098bbb02838c3884bb603e886f?s=96&d=wavatar&r=g","caption":"Dhruvi Vikma"}}]}},"_links":{"self":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/12988","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\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=12988"}],"version-history":[{"count":32,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/12988\/revisions"}],"predecessor-version":[{"id":41675,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/12988\/revisions\/41675"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/32331"}],"wp:attachment":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=12988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=12988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=12988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}