Home / Science / Maths, statistics and computing / Discrete maths and graph theory / Graph editor with algorithmsTool #556

Graph algorithms online: draw a graph or paste an edge list, then shortest path, BFS/DFS, minimum spanning tree, max flow, colouring and centrality

Draw a graph or paste an edge list (weighted, directed or not) and run Dijkstra, Bellman-Ford, breadth- and depth-first search, Kruskal and Prim spanning trees, maximum flow with the minimum cut, greedy and DSatur colouring, degree, betweenness and closeness centrality, or a topological order. Results are highlighted on the drawing. Checked against networkx.

Keep it one tap away for everyday use.

Bookmark Graph editor with algorithms?

Press Ctrl + D now. Your browser opens its own bookmark box, where you choose the name and folder.

  1. Draw graph
  2. Pick method
  3. See result
  4. Download
Nothing is uploadedWorks offline once open

Graph

A line with one name adds a node with no edges. Spaces, tabs, commas or "A -> B" all work. Up to 2,000 nodes and 20,000 edges; the drawing shows up to 300 nodes.

Drawing

Move: drag a node to tidy the picture.

What it does

A graph is a set of points (nodes) joined by lines (edges): towns and roads, computers and cables, tasks and the tasks they depend on, people and who knows whom. This tool lets you draw one or paste it as a list, then run the classic graph algorithms from a discrete maths or algorithms course and see the answer drawn on the graph:

  • Shortest path with Dijkstra (weights of 0 or more) or Bellman-Ford (negative weights allowed; it reports a negative cycle if there is one).
  • Breadth-first and depth-first search from a start node, with the visiting order and the search tree.
  • Minimum spanning tree by Kruskal or Prim: the cheapest set of edges joining every node.
  • Maximum flow (Edmonds-Karp) from a source to a sink, with the minimum cut that proves it.
  • Colouring: greedy (largest degree first) and DSatur, so no two neighbours share a colour.
  • Centrality: degree, betweenness and closeness, normalised to 0–1.
  • Topological order of a directed graph, or the cycle that makes one impossible.

Everything runs in your browser. Nothing is uploaded.

How to use it

  1. Pick an example, or type an edge list: one edge per line as from to weight, for example A B 7. Leave the weight out and it counts as 1. A line with one name adds a node with no edges. You can also open a CSV, TSV, text or Excel file with up to three columns.
  2. Tick Directed if each edge goes one way only (from → to). Leave it unticked for two-way edges.
  3. Or draw: choose Add node and tap an empty spot, Add edge and tap two nodes (the edge gets the weight in the box), Delete to remove a node or an edge, and Move to drag nodes about. The edge list updates as you draw, so you can copy or download it.
  4. Choose the algorithm under Run and, where it needs them, the start and end (or source and sink).
  5. Read the headline answer, the table and the drawing. Download the table as CSV, or the whole result with the picture as an image, PDF or Word file.

What each option does

  • Weights are lengths for shortest paths and centrality, costs for spanning trees and capacities for maximum flow.
  • Spanning trees and colouring ignore the direction of edges. If the graph is in several pieces, you get a spanning forest.
  • Betweenness is the share of shortest routes between other pairs that pass through a node; closeness is based on how far the node is from the rest, scaled for graphs in pieces as networkx does (for a directed graph it counts routes into the node).
  • Topological order takes the earliest-listed node first when several are ready, so the answer is always the same.

Worked example

Load the road network (seven places, weights in km). Dijkstra from A to G gives 22 km along A → D → F → G, and the table lists every place’s distance from A: D 5, B 7, F 11, E 14, C 15, G 22. Kruskal and Prim both give a minimum spanning tree of weight 39 with the edges A–B, A–D, B–E, C–E, D–F and E–G. Both colourings need 3 colours. By betweenness, E is the most central (0.233). Switch to the pipe network: the maximum flow from S to T is 19, and the minimum cut (the dashed red edges) has the same capacity, 19.

What it does not do

It is for learning and for small to medium graphs (up to 2,000 nodes and 20,000 edges, drawn up to 300). It does not handle several edges between the same pair (the last weight is used), loops, or minimum-cost flow. Greedy colouring does not promise the fewest colours possible. For network statistics such as clustering, PageRank and communities, use the network metrics tool.

Frequently asked questions

Why does Dijkstra refuse my graph? It needs weights of 0 or more. Use Bellman-Ford for negative weights.

Why “negative cycle”? If going round a loop adds up to less than zero, every trip round makes a route shorter, so no shortest route exists. In an undirected graph a single negative edge is already such a loop.

Do my answers match networkx? Yes: they were checked against networkx on the examples and on 100 random graphs.

Is my graph stored? No. Nothing is stored or sent anywhere.

Where the numbers come from

  • Standard textbook algorithms (Dijkstra, Bellman-Ford, BFS, DFS, Kruskal, Prim, Edmonds-Karp, greedy and DSatur colouring, Brandes betweenness, Kahn's topological sort, Fruchterman-Reingold layout), written by fibub.
  • Checked against networkx 3.7 (BSD licence) on the examples and on 100 random graphs, directed and undirected: distances, search orders, spanning tree weights, flow values, colourings, centralities and topological orders all equal.
  • The road, pipe and task examples are made up for this tool.

Standard scientific values, such as constants, atomic weights and melting points, are facts found in every textbook; we name where ours were checked. If you are an author or publisher and want a value, a credit or a table changed or removed, tell us and we will act quickly.

Last updated 2026-11-09.

Related tools

CSV profiler and SQL playground #38 Open CSV, TSV or Excel files and get a profile of every column: type, missing values, distinct values, range and most common values. Then query them with SQL (SQLite), join files, and download the result. Nothing is uploaded. Publication plot maker #27 Paste columns or open a CSV or Excel file and get a clean scientific figure with error bars, sized for a journal column. Download vector SVG or PDF, or PNG at 300 or 600 dpi. Your data stays in your browser. Combinatorics calculator #557 Count exactly, with every digit: permutations and combinations with or without repetition, multinomial coefficients (arrangements of a word), Stirling numbers of both kinds, Lah numbers, Bell and Catalan numbers, integer partitions and derangements, with tables you can download. Algorithm visualiser #573 Watch bubble, insertion, selection, merge, quick, heap, counting and radix sort work on your own list, one step at a time, with exact comparison, swap and write counts. Also linear and binary search, and the tables for longest common subsequence, edit distance and the 0/1 knapsack. Transportation and assignment problem solver #583 Solve a transportation problem from a starting plan (northwest corner, least cost or Vogel's approximation) to the optimum with the MODI method, showing every step, the u and v potentials and dummy rows for unbalanced problems. Or solve an assignment problem with the Hungarian method, minimising cost or maximising profit. Checked against scipy. Vehicle routing for small instances #586 Plan delivery routes from one depot: give the customers as map coordinates or a distance table, their demands, the vehicle capacity and the number of vehicles. Clarke-Wright savings with 2-opt and or-opt improvement, the exact shortest plan for up to 12 customers, a route map and a stop-by-stop table. Checked against brute force and an integer program. Network metrics #588 Open or paste an edge list and get the network's density, components, diameter and average path length, clustering and transitivity, degree assortativity, PageRank, Louvain communities with modularity, a log-log degree distribution and a drawing of small networks. Checked against networkx. Nothing is uploaded.