Cyclomatic Complexity Formula Calculator

Work out M = E − N + 2P from a control-flow graph, or M = decisions + 1, with the steps shown. Free and private: runs in your browser.

Enter edges, nodes and connected components from a control-flow graph (or just the number of decision points) to calculate cyclomatic complexity and the number of basis-path test cases.

Runs entirely in your browser. Nothing you paste is uploaded or stored.

Use cases

  • Check a function before opening a pull request.
  • Explain a review comment with numbers instead of opinions.
  • Find the riskiest code to refactor first.

Frequently asked questions

How is cyclomatic complexity used in software testing?

It equals the number of independent paths through a function, which is the minimum number of test cases needed for basis-path (branch) coverage.

Is the Cyclomatic Complexity Formula Calculator free?

Yes. It is free with no sign-up, and it runs entirely in your browser, so your input is never uploaded or stored.

How accurate is a browser-based code check?

It uses fast heuristics on the snippet you paste, so it is great for quick feedback. For whole repositories, cross-file analysis and history, run a full CodeInspector scan.

Related tools

Track complexity, duplication and code smells across your whole codebase with CodeInspector.

All free developer tools