本文へスキップ
製品デスクトップツールTASTECAD図面の確認TASTEFILESファイル管理TASTEFTPファイル転送TASTESSHリモートワークスペースTASTEZIP圧縮と展開TASTEWINMファイル管理開発ツールTASTECODERust 統合開発環境TASTESTUDIO統合開発・テスト環境TASTEETLデータ統合(ETL)サーバーTASTEREMOTEリモートデスクトップサーバーTASTEGEO空間情報サーバーTASTEMAILメールワークスペース投資TASTESTOCK株式自動売買デスクトップアプリはじめるダウンロードドキュメント購入すべての製品
マーケットプレイス
ニュース
技術ニュース今日の開発ニュース開発ドキュメントプログラミング言語RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWebフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngularサーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Expressアプリ・デスクトップ フレームワークTauriFlutterReact NativeElectronアルゴリズムアルゴリズムの基礎主要アルゴリズム発展アルゴリズム実務のアルゴリズム
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケースコミュニティガイド
協業技術移転ウェブサイト構築デスクトップアプリ構築リリース・決済パイプライン販売パートナーお問い合わせ
サービスリモートデスクトップインストールパッケージのカスタマイズ
TASTEDEV
製品

デスクトップツール

TASTECAD複雑な図面を、軽やかにひらくTASTEFILES必要なファイルだけを、最速でTASTEFTPファイルが行き交う、いちばん端正な道TASTESSHサーバーとあなたを、より確かにつなぐTASTEZIPより速くまとめ、より安全にひらくTASTEWINM2つの画面で整理する、キーボード中心のファイルマネージャー

開発ツール

TASTECODERust アプリの編集・ビルド・デバッグ・テストまでひとつのウィンドウでTASTESTUDIO編集からリモートテスト、承認した AI 修正までTASTEETL値を見ながら、データを運ぶ

サーバー

TASTEREMOTE自社サーバーで運用するリモートデスクトップTASTEGEOGeoServer 互換の空間情報サーバーを Rust で作り直しますTASTEMAILメールの主導権を、もう一度自分の手に

投資

TASTESTOCKいつ・何を。自分で決めたルールどおりに動く株式自動売買

はじめる

ダウンロード全製品の最新版ドキュメント各製品の使い方購入サブスクリプション・永久ライセンスすべての製品全製品を一覧で
すべての製品
マーケットプレイスニュース
技術

ニュース

今日の開発ニュース言語・フレームワーク・GitHub・AI の公式発表開発ドキュメント言語・フレームワーク・アルゴリズムのガイド

プログラミング言語

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

フレームワーク

Webフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngular
サーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
アプリ・デスクトップ フレームワークTauriFlutterReact NativeElectron

アルゴリズム

アルゴリズムの基礎計算量解析 · ソート · 探索 · 基本データ構造 · 木構造とヒープ主要アルゴリズムグラフ探索 · 最短経路と最小全域木 · 動的計画法 · 貪欲法 · 分割統治法 · バックトラッキング発展アルゴリズム文字列アルゴリズム · 数学と整数論 · ビット演算 · セグメント木 · Union-Find実務のアルゴリズムコーディング面接対策 · LRUキャッシュ · レート制限 · コンシステントハッシュ法
開発ドキュメントをすべて見る
コミュニティ
プロジェクトビルダーと作品を探す開発ログ決定と試行錯誤プロンプト再利用できる指示AIツールの問題Claude・Codex・Gemini の問題と回避策ショーケース完成した成果コミュニティガイドオープンにつくる方法
協業
技術移転Rust・egui でネイティブアプリを作るウェブサイト構築10言語、アカウント、ドキュメントとダウンロードデスクトップアプリ構築Rust・egui、WebView なしリリース・決済パイプライン署名・MSI・deb・rpm・AppImage・ハッシュ販売パートナー紹介して決済額の30%お問い合わせ構築・提携・投資のご相談
サービス
リモートデスクトップブラウザから自分のパソコンへインストールパッケージのカスタマイズ必要な機能だけ、設定は事前に
購入
JA
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
ログイン
ログイン
TASTEDEV

小さなツールから、より良い開発へ。

support@tastedev.netTASTEDEVを支援
製品製品ラインナップ購入ドキュメントダウンロードマーケットプレイスサポート
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケース
ポリシー会社概要プライバシーポリシー利用規約サブスクリプション規約返金ポリシーコミュニティガイドライン
アカウントログイン新規登録
訪問者
今日
昨日
累計閲覧
商号
GXSOFT
代表者
CHOI YOUNG GU
事業者登録番号
853-44-00368
所在地
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
電話
+82-10-4404-1523
メール
whitecalvin@tastedev.net
個人情報保護責任者
CHOI YOUNG GU

© 2026 TASTEDEV製品情報は検証済みの開発ソースに基づいています。リリース・改善中

グラフ探索 ドキュメント
グラフ探索
Graph Traversal ConceptsHow It WorksImplementationComplexityPractice ProblemsReal-World Use
ディスカッション

グラフ探索 ガイド · 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.

この章について質問がありますか?
前の章Practice Problems
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)

コメント 0件

人気のコメント順新しい順

ログイン · ログインするとコメントできます。