Graph Traversal Algorithms

Fundamental algorithms for navigating graphs.

  • JSON4,390 B
  • YAML3,115 B · −29%
  • TOON2,570 B · −41%

Algorithms for exploring and searching graphs: breadth-first and depth-first search, Dijkstra, Bellman-Ford, A* and Floyd-Warshall, with bidirectional search, iterative deepening, uniform-cost and greedy best-first search, topological sorting and Johnson's all-pairs algorithm.

Use it when

  • You need the right traversal or shortest-path algorithm for a graph.
  • You are comparing informed and uninformed search.

Watch out for

  • Choice depends on edge weights, graph size and whether you need one path or all pairs.
  • A* is only optimal when its heuristic is admissible (never overestimates).

The data

NameTypeDescription
Breadth-First SearchTraversalExplore all neighbors at current depth before deeper vertices.
Depth-First SearchTraversalExplore as far as possible along each branch before backtracking.
DijkstraShortest PathGreedy shortest path from a source with non-negative edges.
Bellman-FordShortest PathHandles negative edge weights and detects negative cycles.
A* SearchHeuristic SearchUses a heuristic to guide pathfinding efficiently.
Floyd-WarshallAll-Pairs Shortest PathDynamic programming shortest paths between every pair of vertices.
Uniform-Cost SearchShortest pathExpands the lowest-cost path first; equivalent to Dijkstra's algorithm on a graph.
Iterative Deepening DFSTraversalRepeats depth-limited DFS with increasing limits, combining DFS memory use with BFS completeness.
Bidirectional SearchShortest pathSearches forward from the start and backward from the goal, meeting in the middle.
Greedy Best-First SearchInformed searchExpands the node that looks closest to the goal by a heuristic; fast but not guaranteed optimal.
Topological SortOrderingOrders the nodes of a directed acyclic graph so every edge points forward.
Johnson's AlgorithmAll-pairs shortest pathReweights edges with Bellman-Ford, then runs Dijkstra from every node; efficient for sparse graphs.

Fields

The shape of this dataset, read from the data itself: every column, its type and a real value. Agents can use this to plan a query without fetching the whole document.

SectionFieldTypeExample
datanamestringBreadth-First Search
datatypestringTraversal
datadescriptionstringExplore all neighbors at current depth before d…

Fetch the same bytes

The static files contain the same reference rows as the API, with no API rate limit. Live metadata, such as view counts, may differ. Use the API for content negotiation; use the static files for a cacheable snapshot.

curl "https://yjtoon.com/api/dataset/graph-traversal-algorithms?format=toon"
const res = await fetch(
  "https://yjtoon.com/static-data/dataset/graph-traversal-algorithms.toon"
);
const toon = await res.text();

Rate limit: 120 requests per minute per IP, no key and no signup. API reference →

Topics

  • algorithms
  • graphs
  • traversal

Search the library

Search by a topic, title, or keyword.

Start with a collection

Browse all 205 datasets