Graph Algorithms

Run BFS, DFS, shortest path, topological sort, or cycle detection on a graph you paste in. Directed or undirected, weighted or unweighted. Runs entirely in your browser — no server, no sign-up.

Result

What this tool does

Run a classic graph algorithm on a graph you describe yourself. Paste an edge list, choose an algorithm, and get the answer instantly — right in your browser. Nothing is uploaded to a server; it runs locally, works offline, and needs no sign-up.

How to describe your graph

Put one edge per line. The separator is flexible — all of these mean an edge between a and b:

a -> b
a - b
a b
a,b

A line with a single label (like z) adds an isolated node. Blank lines and lines starting with # are ignored, so you can comment your graph.

For a weighted graph, turn on Weighted and add a number at the end of the line:

a -> b : 3
a -> c 5
b -> c 1

Turn on Directed to treat each edge as one-way (a → b only). Leave it off for an undirected graph, where every edge goes both ways.

Algorithms

AlgorithmWhat it computes
BFS (breadth-first search)Visit order exploring the graph level by level from a start node.
DFS (depth-first search)Visit order exploring as deep as possible before backtracking.
Shortest pathThe cheapest route from a start node to an end node (Dijkstra when weighted, fewest hops when not).
Topological sortA linear ordering of a directed acyclic graph so every edge points forward. Requires a directed graph.
Cycle detectionReports whether the graph contains a cycle, and shows an example.

BFS, DFS, and shortest path need a Start node; shortest path also needs an End node.

Examples

Edge listAlgorithmResult
a - b, a - c, b - dBFS from aa → b → c → d
a - b, a - c, b - dDFS from aa → b → d → c
a→b:1, a→c:5, b→c:1 (directed, weighted)Shortest path aca → b → c, distance 2
a→b, a→c, b→d, c→d (directed)Topological sorta → b → c → d
a→b, b→c, c→a (directed)Cycle detectioncycle found: a → b → c → a

FAQ

Is it free and private?

Yes — your graph never leaves your device, and the tool keeps working offline once the page has loaded.

Directed or undirected?

Use Directed for one-way relationships (task dependencies, web links, follower graphs). Leave it off for symmetric relationships (roads, friendships). Topological sort only makes sense on a directed graph.

What does “weighted” do?

It tells the parser to read a trailing number on each edge as a distance/cost. Shortest path then uses Dijkstra’s algorithm. Weights must be non-negative.

Why does shortest path not take the direct edge?

Dijkstra finds the cheapest route by total weight — a longer chain of small edges can beat one expensive direct edge.

What if a node can’t be reached?

BFS/DFS report how many nodes they reached; shortest path says no path exists when the end node is unreachable from the start.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool graph-algorithms "a -> b
a -> c
b -> d"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/graph-algorithms/?edges=a%20-%3E%20b%0Aa%20-%3E%20c%0Ab%20-%3E%20d&algorithm=bfs&directed=true&weighted=true&start=a&end=d

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.