Graph Theory Explorer (Euler Paths, Spanning Trees, Colouring)

Draw vertices and edges, then run Euler and Hamilton searches, Kruskal and Prim spanning trees, greedy and exact colouring and Dijkstra, with every step listed.

Runs in your browser. Your files never leave your device. See how to check

…

How to do it

  1. 1
    Draw or load a graph

    Load an example or use + Vertex and + Edge to draw your own.

  2. 2
    Set weights and names

    Open Edge weights and Rename vertices below the drawing to edit them.

  3. 3
    Choose an algorithm

    Pick Euler, Hamilton, Kruskal, Prim, colouring or Dijkstra from the menu.

  4. 4
    Read the result

    The result is highlighted on the drawing and explained in the step list.

  5. 5
    Check the matrix

    Open Degree table and matrix for the adjacency matrix and degrees.

  6. 6
    Save and practise

    Save graphs by name, print the result and try generated questions in Practice.

About this tool

Graph theory is the maths of networks: road maps, circuit boards, friendships and timetables are all vertices joined by edges. It appears in decision maths at A-level, in discrete maths courses at university and in many computing degrees, and its problems are easiest to understand when you can draw them. This explorer is a small drawing board for graphs. You add vertices with a tap, join them with edges, give the edges weights and then run the standard algorithms. The tool highlights the result on the drawing and writes out the steps in the order a student would: the degree check for an Euler path, the sorted edge list for Kruskal, the growing tree for Prim, the colours given by Welsh-Powell and the exact chromatic number.

Drawing a graph

Use + Vertex and tap empty space to place vertices, then + Edge and tap two vertices to join them. Edges between the same pair are allowed (multigraphs such as the Königsberg bridges) and are drawn as separate curves. Move drags vertices, Delete removes a vertex or edge, and edge weights and vertex names are edited in the lists below the drawing. Six examples load with one click, including the Königsberg bridges, the envelope puzzle, K5, the Petersen graph and a cube.

Degrees, Euler paths and circuits

The degree of a vertex is the number of edge ends touching it. The handshake lemma says the degrees add up to twice the number of edges, so there is always an even number of odd vertices. Euler proved in 1736 that a connected graph has a circuit using every edge exactly once when every degree is even, and a path when exactly two vertices are odd; the path must start at one of them. The tool checks the condition, then builds the route with Hierholzer's algorithm and numbers the vertices in visiting order. Königsberg has four odd vertices, so no walk crosses each bridge once.

Hamilton cycles

A Hamilton cycle visits every vertex once and returns to the start. Unlike the Euler case there is no simple test, so the tool searches every possibility by backtracking for graphs of up to 14 vertices. The Petersen graph is the classic example with no Hamilton cycle even though every vertex has degree 3.

Minimum spanning trees

A spanning tree connects all vertices with no cycles, using n − 1 edges. Kruskal's algorithm sorts the edges by weight and adds each one unless it would close a cycle. Prim's algorithm starts from a chosen vertex and repeatedly adds the cheapest edge leading to a new vertex. Both always find a minimum total weight; the step lists show the decisions, which is exactly what decision-maths exams ask you to write.

Colouring and shortest paths

A proper colouring gives neighbouring vertices different colours. The Welsh-Powell greedy method colours vertices in order of decreasing degree and may use more colours than needed; the exact search finds the chromatic number χ for up to 14 vertices. Odd cycles need 3 colours and K5 needs 5. Dijkstra's algorithm gives the shortest weighted path between two chosen vertices.

Worked example

Load the weighted network. Kruskal sorts the edges and adds A–D (5), C–E (5), D–F (6), A–B (7) and B–E (7), skipping heavier edges that would form cycles. Five edges join all six vertices with a total weight of 30. Prim started at A gives a different order but the same total.

Limits

Hamilton searches and exact colouring try every case, so they are limited to 14 vertices. Directed graphs, flows and matchings are not covered. The tool is for learning and checking homework; for very large networks use specialist graph software.

Worked example

Weighted network: Kruskal adds AD 5, CE 5, DF 6, AB 7, BE 7 → minimum spanning tree of weight 30.

Quick facts

Frequently asked questions

When does a graph have an Euler circuit?

When it is connected (ignoring isolated vertices) and every vertex has even degree. With exactly two odd vertices it has an Euler path instead.

Why is there no answer for the Königsberg bridges?

All four land areas have odd degree (5, 3, 3 and 3). An Euler path allows at most two odd vertices.

Do Kruskal and Prim always give the same tree?

They always give the same total weight. If several edges have equal weights the actual trees can differ.

What is the chromatic number?

The smallest number of colours needed so that no edge joins two vertices of the same colour.

How large a graph can I draw?

Any size for drawing, degrees, Euler paths, spanning trees and shortest paths. Hamilton and exact colouring searches stop at 14 vertices.

Can I export my graph?

Yes. Save a PNG of the drawing, an edges CSV, the adjacency matrix CSV, or the whole project as a JSON file.

Guides for this tool

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages