Vai al contenuto principale
ProdottiStrumenti desktopTASTECADVisualizzazione disegniTASTEFILESGestione fileTASTEFTPTrasferimento fileTASTESSHSpazio di lavoro remotoTASTEZIPCompressione ed estrazioneTASTEWINMGestione fileStrumenti per sviluppatoriTASTECODEAmbiente di sviluppo integrato per RustTASTESTUDIOAmbiente integrato di sviluppo e testTASTEETLIntegrazione dati (ETL)ServerTASTEREMOTEServer di desktop remotoTASTEGEOServer geospazialeTASTEMAILSpazio di lavoro emailInvestimentiTASTESTOCKApp desktop di trading automatico azionarioIniziaDownloadDocumentazioneAcquistaTutti i prodotti
Marketplace
Notizie
TecnologiaNotizieNotizie di sviluppo di oggiDocumentazioneLinguaggi di programmazioneRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartFramework frontend webNext.jsReactVue.js · NuxtSvelteKitAngularFramework serverSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressFramework per app e desktopTauriFlutterReact NativeElectronAlgoritmiBasi degli algoritmiAlgoritmi fondamentaliAlgoritmi avanzatiAlgoritmi pratici
CommunityProgettiLog di sviluppoPromptProblemi degli strumenti di IAVetrinaGuida alla community
CollaboraTrasferimento tecnicoRealizzazione del sito webRealizzazione di app desktopPipeline di rilascio e pagamentoPartner commercialeContatti
ServiziDesktop remotoPacchetti di installazione su misura
TASTEDEV
Prodotti

Strumenti desktop

TASTECADApri con leggerezza anche i disegni più complessiTASTEFILESSolo i file che servono, alla massima velocitàTASTEFTPLa via più ordinata per i tuoi fileTASTESSHUn legame più solido tra te e i tuoi serverTASTEZIPComprimi più veloce, estrai più sicuroTASTEWINMUn file manager a due pannelli pensato per la tastiera

Strumenti per sviluppatori

TASTECODEModifica, compila, esegui il debug e testa app Rust in un'unica finestraTASTESTUDIODalla modifica ai test remoti e alle correzioni IA approvateTASTEETLSposta i dati guardando i valori

Server

TASTEREMOTEUn desktop remoto che gira sul tuo serverTASTEGEOUn server geospaziale compatibile con GeoServer, ricostruito in RustTASTEMAILRiprendi il controllo della tua posta

Investimenti

TASTESTOCKTrading automatico azionario secondo le regole che decidi tu: quando e che cosa

Inizia

DownloadUltime versioni di ogni prodottoDocsCome usare ogni prodottoAcquistaAbbonamenti e licenze perpetueTutti i prodottiTutti i prodotti a colpo d’occhio
Tutti i prodotti
MarketplaceNotizie
Tecnologia

Notizie

Notizie di sviluppo di oggiAnnunci ufficiali su linguaggi, framework, GitHub e IADocumentazioneGuide a linguaggi, framework e algoritmi

Linguaggi di programmazione

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Framework

Framework frontend webNext.jsReactVue.js · NuxtSvelteKitAngular
Framework serverSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
Framework per app e desktopTauriFlutterReact NativeElectron

Algoritmi

Basi degli algoritmiAnalisi della complessità · Ordinamento · Ricerca · Strutture dati di base · Alberi e heapAlgoritmi fondamentaliVisita dei grafi · Cammini minimi e alberi ricoprenti · Programmazione dinamica · Algoritmi greedy · Divide et impera · BacktrackingAlgoritmi avanzatiAlgoritmi sulle stringhe · Matematica e teoria dei numeri · Manipolazione dei bit · Alberi di segmenti · Union-FindAlgoritmi praticiStrategia per colloqui di programmazione · Cache LRU · Rate limiting · Hashing consistente
Tutta la documentazione di sviluppo
Community
ProgettiScopri sviluppatori e lavoriLog di sviluppoDecisioni e lezioni appresePromptIstruzioni riutilizzabiliProblemi degli strumenti di IAProblemi e alternative di Claude, Codex, GeminiVetrinaRisultati completatiGuida alla communityCome sviluppiamo in modo aperto
Collabora
Trasferimento tecnicoApp native in Rust ed eguiRealizzazione del sito web10 lingue, account, documentazione e downloadRealizzazione di app desktopRust ed egui, senza WebViewPipeline di rilascio e pagamentoFirma, MSI, deb, rpm, AppImage, hashPartner commercialeConsigliaci e ricevi il 30%ContattiSviluppo, partnership e investimenti
Servizi
Desktop remotoRaggiungi il tuo computer dal browserPacchetti di installazione su misuraSolo il necessario, impostazioni precaricate
Acquista
IT
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Accedi
Accedi
TASTEDEV

Dai piccoli strumenti a uno sviluppo migliore.

support@tastedev.netSostieni TASTEDEV
ProdottiGamma di prodottiAcquistaDocsDownloadMarketplaceAssistenza
CommunityProgettiLog di sviluppoPromptProblemi degli strumenti di IAVetrina
NormeChi siamoInformativa sulla privacyTermini di servizioCondizioni di abbonamentoRimborsiLinee guida della community
AccountAccediRegistrati
Visitatori
Oggi
Ieri
Visualizzazioni totali
Società
GXSOFT
Rappresentante
CHOI YOUNG GU
Numero di registrazione
853-44-00368
Indirizzo
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Telefono
+82-10-4404-1523
E-mail
whitecalvin@tastedev.net
Responsabile privacy
CHOI YOUNG GU

© 2026 TASTEDEVLe informazioni sui prodotti si basano su fonti di sviluppo verificate.Rilasciato · in miglioramento

Documentazione di Visita dei grafi
Visita dei grafi
Graph Traversal ConceptsHow It WorksImplementationComplexityPractice ProblemsReal-World Use
Discussioni

Guida a Visita dei grafi · 6/6

Real-World Use

Per ora questo capitolo è disponibile solo in inglese.

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.

Domande su questo capitolo?
Capitolo precedentePractice 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 commenti

Commenti principaliPrima i più recenti

Accedi · Accedi per lasciare un commento.