Skip to main content
ProductsDesktop toolsTASTECADDrawing reviewTASTEFILESFile managementTASTEFTPFile transferTASTESSHRemote workspaceTASTEZIPCompression and extractionTASTEWINMFile managementDeveloper toolsTASTECODERust integrated development environmentTASTESTUDIOIntegrated development and test environmentTASTEETLData integration (ETL)ServersTASTEREMOTERemote desktop serverTASTEGEOGeospatial serverTASTEMAILMail workspaceInvestingTASTESTOCKStock auto-trading desktop appGet startedDownloadsDocumentationBuyAll products
Marketplace
News
TechNewsToday's dev newsDeveloper docsProgramming languagesRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp & desktop frameworksTauriFlutterReact NativeElectronAlgorithmsAlgorithm basicsCore algorithmsAdvanced algorithmsPractical algorithms
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcaseCommunity guide
Work with usTech transferWebsite buildDesktop app buildRelease and payment pipelineSales partnerContact
ServicesRemote desktopCustom installer packages
TASTEDEV
Products

Desktop tools

TASTECADComplex drawings, opened with easeTASTEFILESJust the files you need, as fast as possibleTASTEFTPThe tidiest path for your filesTASTESSHA stronger link between you and your serversTASTEZIPPack faster, unpack saferTASTEWINMA keyboard-first file manager with two panes

Developer tools

TASTECODEEdit, build, debug and test Rust apps in one windowTASTESTUDIOFrom editing to remote tests and approved AI fixesTASTEETLMove data while you watch the values

Servers

TASTEREMOTEA remote desktop you run on your own serverTASTEGEORebuilding a GeoServer-compatible geospatial server in RustTASTEMAILTake back control of your email

Investing

TASTESTOCKStock auto-trading that follows the rules you set: when, and what

Get started

DownloadsLatest builds of every productDocsHow to use each productBuySubscriptions and perpetual licencesAll productsEvery product at a glance
All products
MarketplaceNews
Tech

News

Today's dev newsOfficial announcements on languages, frameworks, GitHub and AIDeveloper docsGuides to languages, frameworks and algorithms

Programming languages

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App & desktop frameworksTauriFlutterReact NativeElectron

Algorithms

Algorithm basicsComplexity analysis · Sorting · Searching · Basic data structures · Trees and heapsCore algorithmsGraph traversal · Shortest paths & minimum spanning trees · Dynamic programming · Greedy algorithms · Divide and conquer · BacktrackingAdvanced algorithmsString algorithms · Math and number theory · Bit manipulation · Segment trees · Union-findPractical algorithmsCoding interview strategy · LRU cache · Rate limiting · Consistent hashing
All development docs
Community
ProjectsDiscover builders and their workDevelopment logsDecisions and lessons learnedPromptsReusable instructionsAI tool issuesProblems and workarounds for Claude, Codex, GeminiShowcaseFinished resultsCommunity guideHow we build in the open
Work with us
Tech transferNative apps in Rust and eguiWebsite build10 languages, accounts, docs and downloadsDesktop app buildRust and egui, no WebViewRelease and payment pipelineSigning, MSI, deb, rpm, AppImage, hashesSales partnerRecommend us and earn 30%ContactBuilds, partnerships and investment
Services
Remote desktopReach your computer from a browserCustom installer packagesOnly the features you need, settings preloaded
Buy
EN
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Log in
Log in
TASTEDEV

From small tools to better development.

support@tastedev.netSupport TASTEDEV
ProductsProduct lineupBuyDocsDownloadsMarketplaceSupport
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcase
PoliciesAbout usPrivacy policyTerms of serviceSubscription termsRefund policyCommunity guidelines
AccountLog inSign up
Visitors
Today
Yesterday
Total views
Company
GXSOFT
Representative
CHOI YOUNG GU
Business registration number
853-44-00368
Address
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Phone
+82-10-4404-1523
Email
whitecalvin@tastedev.net
Privacy officer
CHOI YOUNG GU

© 2026 TASTEDEVProduct information is based on verified development sources.Released · improving

Graph traversal docs
Graph traversal
Graph Traversal ConceptsHow It WorksImplementationComplexityPractice ProblemsReal-World Use
Discussions

Graph traversal guide · 6/6

Real-World Use

Graph traversal is not just an interview topic. Build tools, package managers, garbage collectors, web crawlers and the paint-bucket tool in an image editor all run on the BFS, DFS and topological sorting covered in this guide. This chapter looks at real systems, standard libraries and common mistakes.

Where traversal shows up

  • Build systems and task runners: Make, Bazel, Gradle and CI pipelines model task dependencies as a DAG and run tasks in topological order. Tasks with in-degree 0 can run at the same time, which is what makes parallel builds possible.
  • Package managers: npm, pip and Cargo walk the dependency graph to decide installation order and report circular dependencies.
  • Garbage collectors: mark-and-sweep collectors traverse references from the roots (globals, stack frames), mark every reachable object, and reclaim the rest.
  • Web crawlers: starting from seed pages, a crawler expands links breadth-first, using a depth limit and a visited set so it never fetches a page twice.
  • Flood fill: the paint-bucket tool finds the connected region of same-colored pixels with a grid BFS or DFS.
  • Spreadsheets: cell formulas form a dependency graph; a topological order decides recalculation order, and a cycle is reported as a circular reference.
  • Deadlock detection: databases build a wait-for graph of which transaction waits on which lock; a cycle means deadlock.

Libraries and tools

Since Python 3.9 the standard library ships a topological sorter in graphlib. Each dictionary value lists a node's predecessors, the things that must come first.

from graphlib import TopologicalSorter, CycleError

deps = {"app": {"ui", "net"}, "ui": {"core"}, "net": {"core"}}
print(list(TopologicalSorter(deps).static_order()))
# e.g. ['core', 'ui', 'net', 'app'] (order within a level is not guaranteed)

try:
    list(TopologicalSorter({"a": {"b"}, "b": {"a"}}).static_order())
except CycleError as error:
    print("cycle:", error.args[1])

TopologicalSorter also supports parallel execution through prepare(), get_ready() and done(), handing ready tasks to workers as their prerequisites finish. For heavier graph work, NetworkX provides BFS, DFS, components and topological sorting out of the box.

import networkx as nx

grid = nx.grid_2d_graph(3, 3)                       # a 3 x 3 grid graph
print(nx.shortest_path_length(grid, (0, 0), (2, 2)))  # 4, BFS when unweighted
print(nx.number_connected_components(nx.Graph([(0, 1), (2, 3)])))  # 2
print(list(nx.topological_sort(nx.DiGraph([("core", "ui"), ("ui", "app")]))))

The mark phase of a garbage collector is an iterative DFS in disguise.

def mark(roots, refs):
    live, stack = set(), list(roots)
    while stack:
        obj = stack.pop()
        if obj in live:
            continue
        live.add(obj)
        stack.extend(refs.get(obj, []))
    return live

refs = {"main": ["a"], "a": ["b"], "b": ["a"], "c": ["d"]}
print(mark(["main"], refs))  # {'main', 'a', 'b'}: c and d get collected

The cycle between a and b does not cause an infinite loop because of the visited set, and c and d are collected because nothing reachable points to them, regardless of their reference counts.

Common mistakes

  • Marking too late: marking on dequeue in BFS lets one vertex be queued many times, wasting memory and time. Mark on enqueue.
  • A list as a queue: list.pop(0) in Python and shift() in JavaScript are O(n).
  • Recursion depth: recursive DFS overflows the stack on long chains with tens of thousands of vertices.
  • Cycle checks in directed graphs: reaching an already visited vertex is not a cycle; reaching an in-progress (GRAY) one is. In undirected graphs, do not mistake the edge back to the immediate parent for a cycle.
  • Unbounded implicit graphs: crawlers and state-space searches can be infinite, so always cap depth or count.
  • Unreachable vertices: check for a distance of -1 before using it in arithmetic.

Summary

Wherever there are dependencies there is a topological sort, and wherever there is a reachability question there is a BFS or DFS. In production, reach for proven implementations like graphlib or NetworkX first; when you write your own, double-check when you mark vertices, which queue you use, how deep you recurse, and how you define a cycle.

Further reading

  • Breadth-first search (Wikipedia)
  • Depth-first search (Wikipedia)
  • Topological sorting (Wikipedia)
  • Breadth-first search (cp-algorithms)
  • Depth First Search (cp-algorithms)
  • graphlib (Python docs)
  • collections.deque (Python docs)
  • Graph Traversal (VisuAlgo)
Questions about this chapter?
Previous chapterPractice Problems

0 comments

Top commentsNewest first

Sign in · Sign in to leave a comment.