On this page
01
Overview
Graph Labs is a visual graph theory lab. You draw the graph, pick one of the classic algorithms and follow the run iteration by iteration, with the same tables, queues and notation used in class.
- 17
- algorithms implemented
- 9
- course topics
- 12
- sample graphs
The problem it solves
Pseudocode on paper hides exactly the part that matters most for learning: what happens at each iteration. Reading that Dijkstra's algorithm "selects the unclosed vertex with the smallest label" is very different from watching that vertex get picked, the distance table get updated and the edge join the solution.
In Graph Labs you rebuild the graph from a homework exercise, run the method on it and compare every step with what you solved by hand. It is useful in lectures and tutoring sessions, when checking exercises and for self-study before an exam.
Faithful to the course
Names, notation, tables and visiting order follow what is taught and tested in class, not the generic version of a library.
Every decision explained
Each step has a title, an explanation of what happened and the state of the auxiliary structures at that moment.
100% in the browser
No sign-up, no server and no database. It works on desktop, tablet and phone.
Application pages
Studio /studio
The heart of the project: graph editor, algorithm selection and step-by-step playback of the run.
Algorithms /algorithms
Theory reference for each method: core idea, invariant, requirements, common pitfalls and pseudocode.
About /about
Where the project came from, in the Graph Theory teaching assistantship, and information about the author.
02
Getting started
Every use of the studio follows the same four-stage cycle, mirrored by the three tabs of the side panel: Build, Run and Steps.
- 1
Build the graph
In the Build tab, load a sample graph or draw from scratch: create vertices by clicking on the canvas and connect them with the edge tool.
- 2
Set weights and directions
Set the weight of each edge (or leave it without one) and choose whether it is undirected or directed, on the canvas or in the edge list.
- 3
Choose the algorithm
In the Run tab, select the method and fill in the parameters that show up: root, target, source, sink or visit sequence.
- 4
Run and follow along
Click Run. The Steps tab opens on its own at the first step; move forward manually or use automatic playback.
Guided example: shortest path with Dijkstra's algorithm
A two-minute walkthrough to get to know the studio with a ready-made graph:
- 1.In the Build tab, click Weighted network. The graph is loaded and framed automatically.
- 2.Go to Run and choose Dijkstra's algorithm, under Shortest paths.
- 3.In Root / origin, select
A; in Target vertex, selectF. - 4.Click Run Dijkstra and use Next step to watch each vertex get closed and each tense edge get relaxed in the dist and pred table.
- 5.At the last step, the shortest path
A → C → F, with weight 11, turns purple, and the Conclusions card sums up the final distances.
Tip
03
Studio layout
The studio splits the screen into two areas: the canvas, where the graph is drawn and animated, and the side panel, which holds the forms, the algorithm catalog and the trace of the run.
- 1
Editing tools
Select and move, add vertex, connect vertices and remove element.
- 2
History
Undo, redo and clear the whole graph.
- 3
Direction of new edges
Sets whether edges created on the canvas start undirected or directed.
- 4
Layout
Turns the automatic suggestion on or off and rearranges the drawing on demand.
- 5
Contextual hint
Explains how to use the active tool. Shown on screens from 640 px wide.
- 6
Canvas
Drawing area with a dotted grid, panning, zoom and run highlights.
- 7
Legend
Meaning of each color applied to vertices and edges during the simulation.
- 8
Zoom
Zoom in, zoom out and fit the whole graph on screen.
- 9
Panel tabs
Switches between Build, Run and Steps, the three stages of the flow.
- 10
Tab content
Graph forms, algorithm catalog or the step-by-step trace.
Responsive layout
04
Canvas and tools
The canvas is the drawing area of the studio. It is where you create and arrange the graph and, during the simulation, visually follow the state of every vertex and edge.
Editing tools
Only one tool is active at a time, highlighted in the top bar. The cursor changes shape to show which one is in use, and a hint next to the bar explains what to do.
Select and move
The default tool. Click a vertex or an edge to select it, drag vertices to reposition them and drag the background to move the view.
Add vertex
Each click on an empty spot creates a vertex there. Labels follow the sequence A, B, C, ..., Z, A1, B1, ..., always skipping the ones already in use.
Connect vertices
Click the source vertex and then the target. Between the two clicks, a dashed line follows the cursor. Esc cancels.
Remove element
Click a vertex or an edge to delete it. Removing a vertex also removes every edge attached to it.
History, direction and layout
Undo
Reverts the last change to the graph. Keeps up to 60 changes.
Redo
Reapplies a change that was undone.
Clear graph
Deletes every vertex and edge. It can be reverted with Undo.
New edges are undirected
Edges created on the canvas start undirected (default).
New edges are directed
Edges created on the canvas start with an arrow, from source to target.
Layout suggestion
When on, each new edge triggers a light adjustment of the drawing. The preference is saved.
Rearrange now
Applies the layout adjustment right away, just once.
How the layout suggestion works
Navigation and zoom
Drag the background to move the view and use the mouse wheel (or a pinch gesture on a trackpad or phone) to zoom in and out, always centered on the point under the cursor. Zoom ranges from 30% to 260%. The buttons in the bottom-right corner offer the same control:
Zoom in
Increases the zoom by 25%, keeping the center.
Zoom out
Decreases the zoom by 20%, keeping the center.
Fit graph
Adjusts zoom and position so the whole graph fits on screen.
When a sample graph is loaded, it is framed automatically. Parallel edges between the same pair of vertices, such as A → B and B → A, are drawn curved so they do not overlap.
Colors during a run
Once an algorithm runs, every vertex and edge gets a state at each step. The legend in the bottom-left corner of the canvas sums up what the colors mean:
Unexplored
Initial state: the algorithm has not reached the element yet.
Marked
Reached but not processed yet: it is in the queue, the stack or the frontier.
Under analysis
Element examined in the current step. Vertices under analysis pulse to draw attention.
Explored / in solution
Processing finished or element accepted into the solution (tree, order, matching).
Discarded
Rejected by the algorithm, such as an edge that would form a cycle. Discarded edges are dashed.
Path
Result highlighted at the end: shortest path, augmenting path or Eulerian trail.
Extra markings
Dashed ring in the main color
Starting vertex. The label above it reads ROOT or, in flow algorithms, SOURCE.
Purple dashed ring
Ending vertex: TARGET, or SINK in flow algorithms.
- 1/6
Badge under the vertex
Value of the vertex at the current step: d/f in depth-first search, level in breadth-first search, dist in Dijkstra, color in coloring, s and t in flow.
- 3/5
Edge label
Shows the weight. During a run it may give way to another value, such as flow/capacity in flow algorithms or the traversal order in Fleury's algorithm.
Colored outline
Groups vertices of the same set: strongly connected components in Kosaraju, trees of the forest in Kruskal, color classes in coloring.
05
Build tab
Everything about the structure of the graph: sample graphs, the vertex list and the edge list. Any change made here shows up on the canvas instantly, and vice versa.
Sample graphs
The samples reproduce examples used in class, each one designed to highlight the behavior of specific algorithms. Loading a sample replaces the current graph (you can undo it), clears the chosen root and target and frames the drawing.
Weighted network
Undirected weighted graph, with weight w(e) > 0 on every edge: the base for MSTs (Prim and Kruskal) and for Dijkstra.
PrimKruskalDijkstraDirected graph with cycles
Directed graph with three strongly connected components, for Kosaraju's algorithm.
KosarajuDFSFlow network
Flow network: a directed graph with capacity u(e) on every edge, from the source s = S to the sink t = T.
Ford-FulkersonNegative weights
Directed graph with negative-weight edges and no negative-weight cycle, for Bellman-Ford and Floyd-Warshall.
Bellman-FordFloyd-WarshallSimple graph
Simple undirected graph with no relevant weights: a good fit for breadth-first and depth-first search.
BFSDFSEulerian graph
Example 1 from the Eulerian graphs lecture: every vertex has even degree, so an Eulerian circuit exists.
FleurySemi-Eulerian graph
Example 2 from the lecture: exactly two vertices of odd degree (5 and 6), so an open Eulerian trail exists.
FleuryNetwork with a bottleneck
The network from the Edmonds-Karp lecture: two edges of capacity 100 joined by one of capacity 1, which exposes the weakness of choosing paths arbitrarily.
Ford-FulkersonEdmonds-KarpDinicActivity precedence
Acyclic graph from the topological sorting lecture: building a bookshelf, from buying the boards to moving it.
KahnTopological sort (DFS)Matching with blossoms
General graph with two odd-length cycles: it requires the blossom contraction of Edmonds' algorithm.
EdmondsVertex coloring
Graph with χ(G) = 3 in which alphabetical order makes the greedy method use 4 colors, while Welsh-Powell finds 3.
Greedy coloringWelsh-PowellWelsh-Powell counterexample
Bipartite graph, so χ(G) = 2, on which Welsh-Powell still uses 3 colors. It is the counterexample from the coloring lecture.
Welsh-PowellGreedy coloring
Vertices
The Vertices card lists every vertex in alphabetical order, with the total count in the header. The New button creates a vertex on the canvas without switching tools; then just drag it where you want it.
- Rename: edit the label directly in the text field, up to 6 characters. The alphabetical order of the labels is the default visit order of every algorithm.
- Select: click the circle with the initials or the text field to highlight the vertex on the canvas.
- Remove: the trash icon deletes the vertex and every edge incident to it.
Edges
The form at the top of the card creates edges precisely, which helps with large graphs or when copying an exercise: choose the From and To vertices, enter the Weight and the Type (undirected or directed) and click Add edge. The header shows the total number of edges and how many there are of each type.
Optional weight
An empty field creates an unweighted edge, which counts as 1 in weighted algorithms. Negative values and decimals with a comma or a dot are accepted.
No loops
An edge must connect two different vertices.
No repeated edges
Two identical edges cannot be created. An undirected edge A - B already connects B to A, but two opposite directed edges, A → B and B → A, are allowed.
Each edge in the list can be edited without being recreated:
- the numeric field changes the weight, and clearing it leaves the edge unweighted;
- the badge toggles the direction with one click: undirected / directed
- clicking the labels selects the edge on the canvas;
- the trash icon removes the edge.
Mixed graphs
06
Run tab
Here you choose the algorithm, provide the parameters it asks for and check that the graph meets the requirements before running the simulation.
Choosing the algorithm
The Algorithm card groups the methods by topic, in course order. Each option shows the name, the complexity and a summary of the strategy. The selected algorithm is highlighted and defines the content of the Parameters card right below.
Parameters
The card header repeats the name and complexity of the method, followed by the graph requirements as badges. Vertex fields only appear when the algorithm uses them:
| Field | Algorithms | Usage | Effect |
|---|---|---|---|
| Root / origin | Breadth-first and depth-first search, Prim, Dijkstra and Bellman-Ford | required | Vertex where the run starts. |
| Target vertex | Dijkstra, Bellman-Ford and Floyd-Warshall | optional | Highlights in purple, at the last step, the shortest path to it. |
| Root / origin (optional) | Floyd-Warshall | optional | Together with the target, picks which pair of vertices gets its path highlighted. |
| Source s and sink t | Ford-Fulkerson, Edmonds-Karp and Dinic | required | Endpoints of the flow network. They must be different vertices. |
| Starting vertex | Fleury | optional | If there are vertices of odd degree, the trail must start at one of them. |
When a required field has not been chosen yet, the studio uses the first vertex in alphabetical order (and, for the sink, the first one different from the source). The chosen vertices get a dashed ring on the canvas with the label ROOT, TARGET, SOURCE or SINK.
Visit sequence
Many algorithms need to decide which neighbor to examine first. By default the decision follows the alphabetical order of the labels, which is the convention used in class. When the exercise asks for another order, build it in Visit sequence:
- click the vertices in the desired order to add them to the sequence;
- the first vertex chosen becomes the root when none is set above (in flow algorithms, it is the first neighbor tried in the search);
- click a vertex in the sequence to take it out;
- vertices left out follow in alphabetical order, after the chosen ones;
- the Default button goes back to alphabetical order.
Validation before running
Requirements are checked on every change to the graph or the parameters. If everything is fine, a green confirmation appears; otherwise, each problem is listed in red with the suggested fix, and the Run button is disabled.
The graph meets the requirements of this algorithm.
Kruskal works on undirected graphs: convert every edge to undirected.
The source s and the sink t must be different vertices.
Tip
07
Steps tab
After the run, the Steps tab works like a player: you move through the simulation while the canvas and the auxiliary structures show the exact state of each iteration.
Playback controls
The header shows the algorithm and the current position (for example, Step 4 of 23), with a progress bar right below. The controls are:
First step
Goes back to the initial state.
Previous step
Goes back one iteration.
Play / pause
Moves forward on its own at the chosen pace. At the end, it restarts from the first step.
Next step
Moves forward one iteration.
Last step
Jumps to the final result.
Clear
Discards the run and restores the original canvas colors.
The slider jumps straight to any step. Any manual navigation pauses automatic playback. The available speeds are:
What each step shows
The main card shows the title of the decision taken (for example, "Tense edge (A, C): relaxed"), the reasoning with the values involved and, when it makes sense, metrics such as the visit order, the current iteration or the flow value. The algorithm’s auxiliary structures appear below it.
Queue
The first element, the next one to leave, is highlighted.
Stack
The top of the stack, the last element, is highlighted.
Set
Elements with no exit order, such as the vertices not yet closed.
The tables reproduce the ones on the board: dist and pred, discovery and finish times, Floyd-Warshall matrices, flow and residual capacities, among others. Colored rows show the role of each entry at the current step:
dist and pred
| Vertex | dist | pred |
|---|---|---|
| A | 0 | - |
| B | 7 | A |
| C | 3 | A |
| D | ∞ | - |
- Blue: entry changed or examined in this step.
- Green: final value or accepted element.
- Red: rejected element.
Conclusions
At the last step the green Conclusions card appears and interprets the result: final distances and the recovered path, total weight of the spanning tree, maximum flow value and the matching cut, components found, topological order, number of colors used. It is the summary to compare with your answer.
When the run is discarded
08
Algorithm catalog
The 17 methods available in the studio, in course order. For the core idea, the invariant, the common pitfalls and the pseudocode of each one, open the reference page.
Graph search
- Depth-first searchO(n + m)
Always picks the marked vertex that was reached most recently, recording a discovery time d and a finish time f.
Parameters: Root
Accepts directed and undirected edgesUndirected graph: tree and back edgesDirected graph: tree, back, forward and cross edges - Breadth-first searchO(n + m)
Always picks the marked vertex that was reached least recently, using a queue, and assigns each vertex its level.
Parameters: Root
Accepts directed and undirected edgesIgnores edge weightsClassifies edges as parent, uncle, sibling and cousin
Connectivity
- Kosaraju's algorithmO(n + m)
Finds the strongly connected components with two depth-first searches: one on G and another on the reverse graph Gᴿ.
Parameters: None
Requires a directed graphIgnores edge weights
Eulerian graphs
- Fleury's algorithmO(m² )
Builds an Eulerian trail by walking through the graph and avoiding crossing a bridge while another edge is still available.
Parameters: Optional starting vertex
Requires an undirected, connected graphAt most 2 vertices of odd degreeIgnores edge weights
Minimum spanning tree
- Prim's algorithmO(m log n)
Adds vertices one by one: at each step it takes the lightest edge between V(T) and the vertices not yet selected.
Parameters: Root
Requires an undirected graphRequires a weighted graph with w(e) > 0A spanning tree only exists if the graph is connected - Kruskal's algorithmO(m log m)
Adds edges, not vertices: sorts the edges by non-decreasing weight and accepts each one that does not form a cycle with those already in E(T).
Parameters: None
Requires an undirected graphRequires a weighted graph with w(e) > 0On a disconnected graph it produces a minimum spanning forest
Shortest paths
- Dijkstra's algorithmO(n²)
"Closes" one vertex per iteration, always the one with the smallest dist, and relaxes the tense edges leaving it.
Parameters: Origin; optional target
Accepts directed and undirected edgesRequires non-negative weightsBased on the relaxation principle - Bellman-Ford algorithmO(n · m)
Dynamic programming: examines every edge in each iteration, relaxing the tense ones, for |V(G)| − 1 iterations.
Parameters: Origin; optional target
Allows negative-weight edgesDoes not allow negative-weight cyclesDetects a negative-weight cycle reachable from the source All-pairs shortest paths through dynamic programming: round k allows vertex k as an intermediate.
Parameters: Optional origin and target
Allows negative-weight edgesDoes not allow negative-weight cyclesComputes every pair of vertices at once
Maximum flow
- Ford-Fulkerson methodO(m · f) with integer capacities
While some augmenting path exists in G'(f), pushes the bottleneck δ along it and updates the residual network.
Parameters: Source s and sink t
Requires a flow network: a directed graph with capacity u(e) > 0Requires a source s and a sink tThe augmenting path is chosen arbitrarily - Edmonds-Karp algorithmO(n · m² )
An efficient implementation of Ford-Fulkerson: each iteration picks the shortest augmenting path, found by breadth-first search.
Parameters: Source s and sink t
Requires a flow network: a directed graph with capacity u(e) > 0Requires a source s and a sink tAlways picks the augmenting path with the fewest edges - Dinic's algorithmO(n² · m)
Each iteration builds the level graph GL from G′(f) and finds a blocking flow in it.
Parameters: Source s and sink t
Requires a flow network: a directed graph with capacity u(e) > 0Requires a source s and a sink tAt most n − 1 blocking flows
Topological sorting
- Kahn's algorithmO(n + m)
At each step takes a vertex with in-degree zero, appends it to the result and lowers the in-degree of its successors.
Parameters: None
Requires a directed graphA topological order only exists in an acyclic graphDetects the presence of a cycle Described by Tarjan in 1976: inserts each vertex at the front of the result only after visiting every vertex that depends on it.
Parameters: None
Requires a directed graphA topological order only exists in an acyclic graphMeeting a temporary mark again reveals a cycle
Matching
- Edmonds' blossom algorithmO(n² · m)
Searches for M-augmenting paths between exposed vertices, contracting the blossoms that appear, until none is left.
Parameters: None
Requires an undirected graphIgnores edge weightsHandles general graphs, not only bipartite ones
Coloring
- Greedy coloringO(n + m)
Goes through the vertices in any order and gives each one the lowest-index color not used by any of its neighbors.
Parameters: None
Requires an undirected graphApproximate coloring, not necessarily minimumThe result depends on the vertex order - Welsh-Powell algorithmO(n² )
Sorts the vertices by non-increasing degree and gives one color to every vertex not adjacent to a vertex already painted with it.
Parameters: None
Requires an undirected graphApproximate coloring, not necessarily minimumUsually uses fewer colors than the greedy method
09
Keyboard shortcuts
Shortcuts work in any tab of the studio and speed up graph editing.
- Undoes the last change to the graph.Ctrl Zor⌘ Z
- Redoes the change that was undone.Ctrl Shift Zor⌘ Shift Z
- Removes the selected vertex or edge.DeleteorBackspace
- Cancels the selection or the edge being created.Esc
Note
10
Data and preferences
Graph Labs has no server, no database and no sign-up. All the processing happens in your browser and nothing you draw is sent anywhere.
- Current graphSaved in the browser
Vertices, positions, edges, weights and directions are saved on every change. When you return to the studio, the graph comes back exactly as you left it.
- Layout suggestionSaved in the browser
Remembers whether you prefer the automatic adjustment on or off.
- Light or dark themeSaved in the browser
On the first visit it follows the operating system preference. After that, the choice made with the header button applies.
- LanguageSaved in the browser
English is the default. Once you choose another language in the header, the site opens in it on your next visits.
- History and runThis session only
The undo and redo history, the chosen algorithm and the trace of the run are discarded when the page is reloaded.
One graph per browser
11
FAQ
Quick answers to the most common questions about using the studio.
Why is the Run button disabled?
The graph or the parameters do not meet the requirements of the chosen algorithm. The problems are listed in red right above the button, each with the suggested fix, such as converting the edges to directed or choosing a source different from the sink.
The result differs from what I did on paper. What could it be?
Most of the time it is the visit order. On ties, the studio examines neighbors in alphabetical order of their labels. If the exercise uses another convention, build the same order in Visit sequence, in the Run tab. Also check the chosen root and whether every edge has the right type and weight.
What happens with unweighted edges?
They count as weight 1 in algorithms that use weights or capacities. Searches, Kosaraju, Fleury, matching and coloring ignore weights.
Can I use negative weights?
Yes. Bellman-Ford and Floyd-Warshall accept negative-weight edges and report when there is a negative-weight cycle. Dijkstra requires non-negative weights, and the flow algorithms require positive capacities; in those cases validation warns you before the run.
Can the graph have loops or multiple edges?
No. Loops (edges from a vertex to itself) are not supported, and an edge cannot be repeated between the same pair of vertices. The exception is two directed edges in opposite directions, such as A → B and B → A, which are allowed and drawn curved.
I changed the graph and the run disappeared. Is that a bug?
No. The trace always matches the graph it was generated for. Any structural change, such as vertices, edges, labels, weights or directions, or switching algorithms discards the run to avoid showing steps that are no longer valid. Just run it again. Only dragging vertices discards nothing.
I lost the graph I was building. Can I get it back?
If the page is still open, use Undo (Ctrl + Z): the history keeps the last 60 changes, including Clear graph and loading a sample. After reloading the page the history is lost, but the latest state of the graph is still saved in the browser.
Does it work on a phone?
Yes. The canvas accepts touch to create and move vertices, one-finger drag to move the view and two-finger pinch to zoom. The side panel appears below the canvas, with its tabs pinned to the top.