ArticleslgStudy

mathematics

Cyclomatic number

Cyclomatic number is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Cyclomatic number rather than just read about it. In short: In graph theory, a branch of mathematics, the cyclomatic number, circuit rank, cycle rank, corank or nullity of an undirected graph is the minimum number of edges that must be removed from the graph to break all its cycles, making it into a tree or forest. The concept was introduced and called the cyclomatic number by Gustav Kirchhoff.

Cyclomatic number — main illustration
Cyclomatic number — illustration

Key takeaways

  • Cyclomatic number belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Cyclomatic number to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Cyclomatic number from memory before moving on to harder problems.

Reference excerpt

In graph theory, a branch of mathematics, the cyclomatic number, circuit rank, cycle rank, corank or nullity of an undirected graph is the minimum number of edges that must be removed from the graph to break all its cycles, making it into a tree or forest. The concept was introduced and called the cyclomatic number by Gustav Kirchhoff.

Formula The cyclomatic number of a graph equals the number of independent cycles in the graph, the size of a cycle basis. Unlike the corresponding feedback arc set problem for directed graphs, the cyclomatic number r is easily computed using the formula: r=e−v+c, where e is the number of edges in the given graph, v is the number of vertices, and c is the number of connected components.

It is possible to construct a minimum-size set of edges that breaks all cycles efficiently, either using a greedy algorithm or by complementing a spanning forest. The cyclomatic number can be explained in terms of algebraic graph theory as the dimension of the cycle space of the graph, in terms of matroid theory as the dual rank of its graphic matroid, and in terms of topology as one of the Betti numbers of a topological space derived from the graph. It counts the ears in an ear decomposition of the graph, forms the basis of parameterized complexity on almost-trees, and has been applied in software metrics as part of the definition of cyclomatic complexity of a piece of code.

For hypergraphs The cyclomatic number of a hypergraph can be derived by its Levi graph, with the same cyclomatic number but reduced to a simple graph. It is r=g−(v+e)+c, where g is the degree sum (and the number of edges in the Levi graph), e is the number of hyperedges in the given hypergraph, v is the number of vertices, and c is the number of connected components. The degree sum of a hypergraph is the sum of the degrees of all the vertices, reducing to 2e for a simple graph, or ke for a k-uniform hypergraph. This formula is symmetric between vertices and edges which demonstrates a hypergraph and its dual hypergraph have the same cyclomatic number.

Matroid rank and construction of a minimum feedback edge set The cyclomatic number of a graph G may be described using matroid theory as the dual rank of the graphic matroid of G. Using the greedy property of matroids, this means that one can find a minimum set of edges that breaks all cycles using a greedy algorithm that at each step chooses an edge that belongs to at least one cycle of the remaining graph. Alternatively, a minimum set of edges that breaks all cycles can be found by constructing a maximal forest of G and choosing the complementary set of edges that do not belong to the maximal forest.

The number of independent cycles In algebraic graph theory, the cyclomatic number is also the dimension of the cycle space of G. Intuitively, this can be explained as meaning that the cyclomatic number counts the number of independent cycles in the graph, where a collection of cycles is independent if it is not possible to form one of the cycles as the symmetric difference of some subset of the others. This count of independent cycles can also be explained using homology theory, a branch of topology. Any graph G may be viewed as an example of a 1-dimensional simplicial complex, a type of topological space formed by representing each graph edge by a line segment and gluing these line segments together at their endpoints. The cyclomatic number is the rank of the first (integer) homology group of this complex, r=rank⁡[H1(G,ℤ)]. Because of this topological connection, the cyclomatic number of a graph G is also called the first Betti number of G. More generally, the first Betti number of any topological space, defined in the same way, counts the number of independent cycles in the space.

Applications

Meshedness coefficient A variant of the cyclomatic number for planar graphs, normalized by dividing by the maximum possible cyclomatic number of any planar graph with the same vertex set, is called the meshedness coefficient. For a connected planar graph with m edges and n vertices, the meshedness coefficient can be computed by the formula

m−n+12n−5. Here, the numerator m−n+1 of the formula is the cyclomatic number of the given graph, and the denominator 2n−5 is the largest possible cyclomatic number of an n-vertex planar graph. The meshedness coefficient ranges between 0 for trees and 1 for maximal planar graphs.

Ear decomposition The cyclomatic number controls the number of ears in an ear decomposition of a graph, a partition of the edges of the graph into paths and cycles that is useful in many graph algorithms. In particular, a graph is 2-vertex-connected if and only if it has an open ear decomposition. This is a sequence of subgraphs, where the first subgraph is a simple cycle, the remaining subgraphs are all simple paths, each path starts and ends on vertices that belong to previous subgraphs, and each internal vertex of a path appears for the first time in that path. In any biconnected graph with circuit rank r, every open ear decomposition has exactly r ears.

Almost-trees A graph with cyclomatic number r is also called an r-almost-tree, because only r edges need to be removed from the graph to make it into a tree or forest. A 1-almost-tree is a near-tree, and a connected near-tree is a pseudotree, a cycle with a (possibly trivial) tree rooted at each vertex. Several authors have studied the parameterized complexity of graph algorithms on r-near-trees, parameterized by r.

Generalizations to directed graphs The cycle rank is an invariant of directed graphs that measures the level of nesting of cycles in the graph. It has a more complicated definition than cyclomatic number (closely related to the definition of tree-depth for undirected graphs) and is more difficult to compute. Another problem for directed graphs related to the cyclomatic number is the minimum feedback arc set, the smallest set of edges whose removal breaks all directed cycles. Both cycle rank and the minimum feedback arc set are NP-hard to compute. It is also possible to compute a simpler invariant of directed graphs by ignoring the directions of the edges and computing the circuit rank of the underlying undirected graph. This principle forms the basis of the definition of cyclomatic complexity, a software metric for estimating how complicated a piece of computer code is.

… excerpt ends here. Continue reading the full article.

Illustrations

Cyclomatic number: This graph has cyclomatic number .mw-parser-output .texhtml{font-family:"Nimbus Roman No9 L","Times New Roman",Times,serif;font-size:118%;line-height:1;font-variant-numeric:lining-nums tabular-nums;font-kerning:none}.mw-parser-output .texhtml .texhtml{font-size:100%}.mw-parser-output .texhtml-big{font-size:165%}.mw-parser-output .mvar{font-style:italic}@media(min-width:420px){.mw-parser-output .texhtml{white-space:nowrap}}r = 2 because it can be made into a tree by removing two edges, for instance the edges 1–2 and 2–3, but removing any one edge leaves a cycle in the graph.
This graph has cyclomatic number .mw-parser-output .texhtml{font-family:"Nimbus Roman No9 L","Times New Roman",Times,serif;font-size:118%;line-height:1;font-variant-numeric:lining-nums tabular-nums;font-kerning:none}.mw-parser-output .texhtml .texhtml{font-size:100%}.mw-parser-output .texhtml-big{font-size:165%}.mw-parser-output .mvar{font-style:italic}@media(min-width:420px){.mw-parser-output .texhtml{white-space:nowrap}}r = 2 because it can be made into a tree by removing two edges, for instance the edges 1–2 and 2–3, but removing any one edge leaves a cycle in the graph.

Worked examples

Example 1 — a first encounter with Cyclomatic number

Start with the simplest possible case. Write down what Cyclomatic number claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Cyclomatic number before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Cyclomatic number ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Cyclomatic number

In research
Cyclomatic number appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Cyclomatic number in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Cyclomatic number is common in secondary-school and first-year university syllabi. It links to neighbouring topics Graph invariants, Matroid theory, Spanning tree, so understanding it makes those chapters shorter.
In everyday life
Look for Cyclomatic number outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Cyclomatic number” →

How to study Cyclomatic number in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Cyclomatic number means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Cyclomatic number out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Cyclomatic number in simple terms?

In graph theory, a branch of mathematics, the cyclomatic number, circuit rank, cycle rank, corank or nullity of an undirected graph is the minimum number of edges that must be removed from the graph to break all its cycles, making it into a tree or forest. The concept was introduced and called the…

Why does Cyclomatic number matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Cyclomatic number?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Cyclomatic number.

Tags

  • Graph invariants
  • Matroid theory
  • Spanning tree

Keep exploring