Graph Labs

Documentation

How Graph Labs works

A complete guide to the studio: how to build the graph, configure and run each algorithm, read the step-by-step trace and make the most of the features that speed up checking exercises.

On this page
  1. 01Overview
  2. 02Getting started
  3. 03Studio layout
  4. 04Canvas and tools
  5. 05Build tab
  6. 06Run tab
  7. 07Steps tab
  8. 08Algorithm catalog
  9. 09Keyboard shortcuts
  10. 10Data and preferences
  11. 11FAQ

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.

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. 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. 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. 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. 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. 1.In the Build tab, click Weighted network. The graph is loaded and framed automatically.
  2. 2.Go to Run and choose Dijkstra's algorithm, under Shortest paths.
  3. 3.In Root / origin, select A; in Target vertex, select F.
  4. 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. 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

On your first visit the studio opens with the Weighted network already loaded. After that, it always reopens with the last graph you worked on.

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. 1

    Editing tools

    Select and move, add vertex, connect vertices and remove element.

  2. 2

    History

    Undo, redo and clear the whole graph.

  3. 3

    Direction of new edges

    Sets whether edges created on the canvas start undirected or directed.

  4. 4

    Layout

    Turns the automatic suggestion on or off and rearranges the drawing on demand.

  5. 5

    Contextual hint

    Explains how to use the active tool. Shown on screens from 640 px wide.

  6. 6

    Canvas

    Drawing area with a dotted grid, panning, zoom and run highlights.

  7. 7

    Legend

    Meaning of each color applied to vertices and edges during the simulation.

  8. 8

    Zoom

    Zoom in, zoom out and fit the whole graph on screen.

  9. 9

    Panel tabs

    Switches between Build, Run and Steps, the three stages of the flow.

  10. 10

    Tab content

    Graph forms, algorithm catalog or the step-by-step trace.

Responsive layout

On wide screens (from 1024 px), the canvas takes the full height on the left and the panel stays fixed on the right, with its own scrolling. On tablets and phones, the canvas sits on top, at about half the screen height, with the panel right below and its tabs pinned to the top while you scroll.

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

The adjustment moves vertices a little at a time, without losing sight of the original drawing, to reduce edge crossings, vertices sitting on edges, overlaps and very tight angles. It works on graphs with 3 to 40 vertices and up to 90 edges, and does nothing if the drawing is already clean.

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.

    PrimKruskalDijkstra
  • Directed graph with cycles

    Directed graph with three strongly connected components, for Kosaraju's algorithm.

    KosarajuDFS
  • Flow network

    Flow network: a directed graph with capacity u(e) on every edge, from the source s = S to the sink t = T.

    Ford-Fulkerson
  • Negative weights

    Directed graph with negative-weight edges and no negative-weight cycle, for Bellman-Ford and Floyd-Warshall.

    Bellman-FordFloyd-Warshall
  • Simple graph

    Simple undirected graph with no relevant weights: a good fit for breadth-first and depth-first search.

    BFSDFS
  • Eulerian graph

    Example 1 from the Eulerian graphs lecture: every vertex has even degree, so an Eulerian circuit exists.

    Fleury
  • Semi-Eulerian graph

    Example 2 from the lecture: exactly two vertices of odd degree (5 and 6), so an open Eulerian trail exists.

    Fleury
  • Network 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-KarpDinic
  • Activity 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.

    Edmonds
  • Vertex coloring

    Graph with χ(G) = 3 in which alphabetical order makes the greedy method use 4 colors, while Welsh-Powell finds 3.

    Greedy coloringWelsh-Powell
  • Welsh-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

Each edge keeps its own direction, so a graph can mix undirected and directed edges. When that happens, a warning shows up in the edge card with two shortcuts, All directed and All undirected, because most algorithms require a single type.

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:

FieldAlgorithmsUsageEffect
Root / originBreadth-first and depth-first search, Prim, Dijkstra and Bellman-FordrequiredVertex where the run starts.
Target vertexDijkstra, Bellman-Ford and Floyd-WarshalloptionalHighlights in purple, at the last step, the shortest path to it.
Root / origin (optional)Floyd-WarshalloptionalTogether with the target, picks which pair of vertices gets its path highlighted.
Source s and sink tFord-Fulkerson, Edmonds-Karp and DinicrequiredEndpoints of the flow network. They must be different vertices.
Starting vertexFleuryoptionalIf 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

When you click Run, the studio computes the whole run at once, opens the Steps tab at the first step and switches the canvas tool back to Select and move, so no accidental click changes the graph during the analysis.

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:

0.5×1.6 s per step1×0.8 s per step2×0.4 s per step4×0.18 s per step

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

BDE

The first element, the next one to leave, is highlighted.

Stack

ACF

The top of the stack, the last element, is highlighted.

Set

CDE

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

Vertexdistpred
A0-
B7A
C3A
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.

final distshortest pathMST weightmaximum flowtopological ordernumber of colors

When the run is discarded

A run is tied to the graph and the algorithm it was generated for. Creating, removing or renaming vertices, changing edges, weights or directions, or switching algorithms discards the trace automatically, and you need to run it again. Dragging vertices to rearrange the drawing does not affect the run.

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

  • 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
  • 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

  • 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

  • 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

  • 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
  • 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

  • "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
  • 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
  • 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
  • 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

  • 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

  • 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

  • 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
  • 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

While you type in a text field or pick an option from a list, the shortcuts are turned off, so deleting a character never removes a vertex.

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

The studio only keeps the graph being edited, and only in the browser and device where it was created. Clearing site data, using a private window or loading a sample graph replaces the saved graph.

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.