Graph Connectivity Calculator

Find connected components, isolated vertices, and the independent cycle rank of a finite undirected graph.

Enter your values

Finite graph theory

Enter vertices and edges

List each vertex once, then enter every undirected edge as A-B. The calculator groups connected components and finds the graph’s independent cycle count.

For a finite undirected graph, cycle rank (the first Betti number) is β₁ = E − V + C, where C is the number of connected components.

Press Enter in an input only when the form is ready.
Try an example
Overview

What is a graph connectivity calculator?

A graph is connected when every pair of its vertices can be joined by a path. Its connected components are the maximal connected subgraphs. For a finite undirected graph, the cycle rank β₁ = E − V + C counts independent cycles, where E is the number of edges, V the number of vertices, and C the number of connected components.

Important terms

Vertex
A node in the graph. The calculator treats each entered label as one distinct vertex.
Edge
An undirected connection between two distinct vertices. An edge A-B is the same as B-A.
Connected component
A maximal group of vertices for which a path exists between every pair.
Cycle rank β₁
The number of independent cycles in a finite undirected graph, computed as E − V + C.
Forest and tree
A forest has no cycles. A tree is a connected forest; for a finite graph with V vertices, it has V − 1 edges.

When this method is useful

  • Check connectivity in a small network, model, or graph-theory exercise.
  • Identify isolated vertices and separate connected components.
  • Determine whether a simple graph is a tree or contains independent cycles.
  • Connect graph cycle rank to the first Betti number of a one-dimensional simplicial complex.
Formula

Formula and variables

C=# connected components,β1=E−V+CC=\#\text{ connected components},\qquad \beta_1=E-V+C
V
number of listed vertices
E
number of distinct undirected edges
C
number of connected components, including isolated vertices
β₁
cycle rank, or number of independent cycles

A spanning forest on V vertices and C components has V − C edges. Each additional edge creates one independent cycle. Therefore β₁ = E − (V − C) = E − V + C. For a connected graph, this reduces to E − V + 1.

Domain note: This calculator analyzes finite simple undirected graphs. It rejects repeated vertex labels, self-loops, duplicate edges, and edge endpoints that are not in the vertex list. Labels are single tokens without spaces or hyphens. It does not analyze directed graphs, weighted edges, or multigraphs.

How it works

How to use this calculator

  1. 1

    Enter every vertex once, separated by commas, spaces, or new lines. A vertex with no incident edges must still appear in this list.

  2. 2

    Enter each undirected edge as A-B, with endpoints matching labels from the vertex list.

  3. 3

    The calculator traverses adjacency lists to determine connected components and isolated vertices.

  4. 4

    It counts V and E, then evaluates β₁ = E − V + C to classify the graph as a tree, forest, or graph with cycles.

Worked examples

Step-by-step examples

Example 1

Problem: Analyze vertices A, B, C, D, E and edges A-B, B-C, C-A, D-E.

Substitution: The components are {A, B, C} and {D, E}, so V = 5, E = 4, C = 2.

Result: β₁ = 4 − 5 + 2 = 1. The graph has two components and one independent cycle.

The triangle contributes one cycle. The separate edge D-E is a tree component.

Example 2

Problem: A tree has vertices A, B, C, D and edges A-B, A-C, C-D.

Substitution: V = 4, E = 3, C = 1.

Result: β₁ = 3 − 4 + 1 = 0; the graph is connected and is a tree.

There is exactly one path between every pair of vertices.

Example 3

Problem: List vertices P, Q, R with a single edge P-Q.

Substitution: The components are {P, Q} and {R}; V = 3, E = 1, C = 2.

Result: β₁ = 1 − 3 + 2 = 0, and R is isolated.

An isolated vertex is a component by itself and must be included in C.

Method knowledge

Rules, edge cases, and related ideas

Components include isolated vertices

A vertex with degree zero has no path to another vertex, so it is its own connected component.

Each extra edge closes one independent loop

A spanning forest uses V − C edges. Edges beyond that forest count independent cycles, giving β₁ = E − V + C.

Undirected edges have no orientation

A-B and B-A denote the same edge. Listing both would duplicate an edge and is rejected.

Edge cases and limitations

  • At least one vertex is required; an edge list may be empty.
  • A one-vertex graph with no edges is connected and is a tree under the usual graph-theory convention.
  • An empty edge list makes every listed vertex isolated.
  • The graph must be simple: loops and repeated undirected edges are not accepted.
  • At most 100 vertices may be entered.
Interpretation

Understand the result

Connectivity describes reachability, while cycle rank measures independent loops. A graph can have several components and still contain cycles within one of them. Isolated vertices each form a component. A zero cycle rank identifies a forest; it is a tree only when that forest is connected.

Common mistakes

  • Leaving an isolated vertex out of the vertex list; without it, the tool cannot count that component.
  • Treating A-B and B-A as two edges, although the graph is undirected.
  • Using cycle rank E − V + 1 for a disconnected graph; the general formula is E − V + C.
  • Calling every forest a tree; a tree must also be connected.

Frequently asked questions

How do I enter graph edges?

Enter each undirected connection as A-B and separate edges with commas, semicolons, or new lines. Both labels must appear in the vertex list.

What does cycle rank mean?

For a finite undirected graph, β₁ = E − V + C counts independent cycles. For a connected graph, use E − V + 1.

Can a disconnected graph have cycles?

Yes. Components can be trees, cyclic graphs, or a mixture. The cycle rank counts independent cycles across all components.

Does this support directed or weighted graphs?

No. It analyzes simple undirected graphs without edge weights. Directed connectivity and multigraphs require different definitions and are not inferred here.

References & technical sources

Keep calculating

Related calculators