MODULE 09

Graph Theory Calculator: Degrees, Cycles & Connectivity

Enter edges like A-B, B-C, C-A (weights optional, e.g. A-B:4). Vertices are inferred from edges — list them separately only to include isolated vertices.

Graph
Examples:
  • A-B,B-C,C-D,D-A — a 4-cycle: connected, bipartite, has an Euler circuit.
  • A-B,A-C,A-D,B-C,B-D,C-D — the complete graph K4: has a Hamiltonian cycle.
  • A-B,A-C,A-D,A-E — a star: 4 odd-degree vertices, no Euler path.

What is Graph Theory?

A graph is a set of vertices connected by edges, used to model any pairwise relationship: social networks, road maps, or dependency chains. This calculator lets you build a graph and inspect its structural properties.

How Does This Calculator Work?

Enter your vertices (e.g. A,B,C,D) and edges (e.g. A-B,B-C), then the graph renders visually and the calculator reports vertex degree, connectivity, and cycle detection instantly.

Common Formulas & Rules

  • Vertex degree: the number of edges touching a vertex.
  • Path: a sequence of edges connecting a sequence of distinct vertices.
  • Cycle: a path that starts and ends at the same vertex with no repeated edges.
  • Connected graph: every pair of vertices has a path between them.
  • Directed vs. undirected: edges can be one-way (directed) or two-way (undirected).
  • Bipartite graph: vertices split into two groups with edges only between groups, never within.

Worked Example

A graph with vertices {1,2,3} and edges {(1,2),(2,3)} has 3 vertices and 2 edges — exactly one less edge than vertices, and it's connected with no cycles, which means (as this calculator's tree-checker confirms) it satisfies both conditions required to be a tree.

Study guide: Graph Theory

Written for students learning this topic for the first time. Last updated October 2026.

Overview

A graph is a set of vertices joined by edges. That simple structure models road maps, social networks, task dependencies, circuits and molecules. Graph theory asks about degrees, paths, cycles, connectivity and colourings.

Several of its best results are checkable conditions: you can decide whether a route that uses every edge exists just by counting degrees, without searching.

Key ideas explained

Basic vocabulary and the handshaking lemma

A simple graph has no loops or repeated edges. The degree of a vertex is the number of edges at it. Each edge contributes to two degrees, so Σ deg(v) = 2|E|. Consequently the number of odd-degree vertices is always even.

Euler and Hamiltonian routes

An Euler circuit uses every edge exactly once and returns to the start; it exists in a connected graph exactly when every vertex has even degree. An Euler path exists exactly when there are 0 or 2 odd vertices. A Hamiltonian cycle visits every vertex once; there is no simple test for it, although Dirac's theorem gives a sufficient condition (n ≥ 3 and every degree at least n/2).

Bipartite graphs and colouring

A graph is bipartite exactly when it has no odd cycle, which is the same as being 2-colourable. The chromatic number is the fewest colours needed so that adjacent vertices differ. For a connected planar graph, Euler's formula says v − e + f = 2.

Standard families

The complete graph Kₙ has n(n − 1)/2 edges. The complete bipartite graph K_{m,n} has m·n edges. A cycle Cₙ has n edges, and a path on n vertices has n − 1.

Worked examples

The Königsberg bridges

Problem. Four land masses are joined by seven bridges, with degrees 3, 3, 3 and 5. Can you cross every bridge exactly once?

  1. Degree sum: 3 + 3 + 3 + 5 = 14 = 2 × 7, which matches the seven bridges.
  2. All four vertices have odd degree, but an Euler path allows at most two.

Answer. No such walk exists. This is the problem that started graph theory.

Reading properties from a small graph

Problem. Vertices A, B, C, D with edges AB, BC, CD, DA, AC.

  1. Degrees: A = 3, B = 2, C = 3, D = 2, summing to 10 = 2 × 5.
  2. Exactly two odd vertices (A and C), so an Euler path exists but an Euler circuit does not. One such path is A–B–C–D–A–C.
  3. A, B, C form a triangle, which is an odd cycle, so the graph is not bipartite.

Answer. It has an Euler path from A to C, no Euler circuit, and is not bipartite.

Enter these same values in the calculator above and compare each step with the working shown here.

Common mistakes to avoid

  • Confusing Euler (every edge once) with Hamiltonian (every vertex once).
  • Forgetting that a loop adds 2 to a vertex's degree, or forgetting to halve the degree sum when counting edges.
  • Thinking “connected” means every vertex is adjacent to every other. That is a complete graph.
  • Calling a graph bipartite because it looks two-sided, without checking for odd cycles.

Where this shows up in computer science

  • Routing, GPS and social-network analysis all treat their data as graphs.
  • Graph colouring schedules exams without clashes and allocates registers in compilers.
  • Dependency graphs order tasks in build systems; molecular graphs model chemistry.

Test yourself

Try each question before opening the answer.

How many edges does K₇ have?

7·6/2 = 21.

Can a graph have exactly three vertices of odd degree?

No. By the handshaking lemma the number of odd-degree vertices is even.

Does K₅ have an Euler circuit? Does K₄?

K₅ does, because every degree is 4. K₄ does not, because every degree is 3.

Frequently asked questions

What's the difference between a path and a cycle?

A path is a sequence of edges connecting distinct vertices with no repeats. A cycle is like a path but returns to its starting vertex, forming a closed loop.

What does it mean for a graph to be connected?

A graph is connected if there's a path between every pair of vertices — no vertex or group of vertices is isolated from the rest of the graph.

What's a bipartite graph?

A bipartite graph's vertices split into two groups where every edge connects a vertex in one group to a vertex in the other — never within the same group. Bipartite graphs are common in matching problems (e.g. job assignments).