EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials Software Testing Tutorial What is Cyclomatic Complexity?
Secondary Sidebar
Software Testing Tutorial
  • Advance
    • Cyclomatic Complexity
    • Decision Table Testing
    • Decision Tree Algorithm
    • What is Continuous Integration
    • Mantis Bug Tracker
    • Equivalence Partitioning
    • Gantt Chart Software
    • Acceptance Testing Types
    • Load testing tools
    • Install TestNG
    • Install Unity
    • Defect Management Process
    • Test Plan Template
    • Testing Interview Questions
    • Testing of Mobile application
    • What is Test Automation Frameworks
    • Test Automation Framework
    • Application of Automation
    • Test Automation Process
    • Automation Testing Roles and Responsibilities
    • What is Instruction Cycle?
    • What is Cucumber?
    • 15 Best Popular Bug Reporting Tools
    • What is Automated Testing?
    • Software Maintenance Types
    • Types of Penetration Testing
    • Software Reliability
    • Best Gantt Chart Software
    • Code Coverage
    • Branch Coverage
    • Decision Coverage
    • Statement Coverage
    • What is Test Case
    • Types of Test Case
    • What is Test Scenario
    • Formal Review
    • Alpha Beta Pruning
    • What is Cyclomatic Complexity?
    • Test Coverage
    • How to Write Test Case
    • Testing Documentation
    • Performance Testing Life Cycle
    • Test Harness
    • Test Strategy
    • Software Incident Management
    • What is Debugging
    • What is Defect?
    • Listeners in TestNG
  • Basics
    • What is Software Testing
    • Careers in Software Testing
    • Defect Life Cycle in Software Testing
    • Bug Life Cycle
    • Levels of Software Testing
    • Software Testing Life Cycle
    • Software Tester Work
    • Software Testing Principles
    • Software Testing Services
    • Testing Methodologies
    • Test Approaches
    • Grey Box Testing
    • Types of Software Testing
    • What is a Bug in Software Testing
    • Benefits of Automation Testing
    • What is Automation Testing?
    • Types of Automation
    • Typical Journey of a Software Tester
    • Automation Testing Process
    • Mobile Automation Testing
    • Automation Testing Life Cycle
    • Software Quality Assurance
    • Software Quality Assurance
    • What is Test Environment?
    • Verification and Validation Testing
  • Types of Testing
    • Adhoc Testing
    • Types of System Testing
    • Manual Testing Types
    • Unit Testing Types
    • Unit Testing Benefits
    • Agile Testing
    • What is Agile Testing
    • Acceptance Testing
    • Stress Testing Types
    • Alpha and Beta Testing
    • Application Testing
    • Automation Testing
    • Automation Testing Advantages
    • Benchmark Testing
    • Black Box Testing
    • Domain Testing
    • Dynamic Testing
    • Ecommerce Testing
    • Fuzz Testing
    • Gray Box Testing
    • GUI Testing
    • Installation Testing
    • Interface Testing
    • Interoperability Testing
    • Mainframe Testing
    • Manual Testing
    • Mutation Testing
    • Monkey Testing
    • Negative Testing
    • Penetration Testing
    • Penetration testing phases
    • Penetration testing framework
    • Protocol Testing
    • Recovery Testing
    • Regression Testing
    • Mobile Penetration Testing
    • Accessibility Testing
    • Sanity Testing
    • Scalability Testing
    • Security Testing
    • Spike Testing
    • Stability Testing
    • State Transition Testing
    • Static Testing
    • Gatling Load Testing
    • System Integration Testing
    • Structural Testing
    • Locust Load Testing
    • System Testing
    • Control Flow Testing
    • Unit Testing
    • Cypress testing
    • Volume Testing
    • Web Testing Application
    • What is Exploratory Testing
    • What is Stress Testing
    • What is Usability Testing
    • White Box Testing
    • Types of White Box Testing
    • Compatibility Testing?
    • Use Case Testing
    • Beta Testing
    • Integration Testing
    • Non Functional Testing
    • Non Functional Testing Types
    • What is Functional Testing
    • Functional testing types
    • Cookie Testing
    • Alpha Testing
    • Boundary Value Testing
    • Equivalence Class Testing
    • Glass Box Testing
    • SOA Testing
    • Smoke Testing
    • Visual Testing
    • Visual Paradigm
    • Model-Based Testing
  • Testing techniques
    • Software Testing Methodologies
    • Black Box Testing Techniques
    • Static Testing Techniques
    • Test Case Design Techniques
    • What is Static Analysis
  • Testing tools
    • Manual Testing Tools
    • Visual Testing Tools
    • Automation Testing Tools
    • Functional Testing Tools
    • GUI Testing Tools
    • Penetration Testing Tools
    • Performance Testing Tools
    • SOA Testing Tools
    • Accessibility Testing Tools
    • What is QTP
    • Regression Testing Tools
    • Security Testing Tools
    • Test Management Tools
    • Defect Management Tools
    • Code Coverage Tools
    • Test Coverage Tools
    • Defect Tracking Tools
    • Continuous Integration Tools
    • Install Bugzilla
    • Test data generation tool
    • Unit Testing Tools
    • Web Testing Tools
    • Stress Testing Tools
    • Performance Monitoring Tools
    • Mobile Testing Tools
    • Responsive Testing Tool
    • Cross Browser Testing Tools
    • Risk Based Testing
    • Database Testing Tools
    • WinRunner
    • What is Squish?
    • CubicTest
    • What is WinRM?
    • Bugzilla Tool
    • Code review tools
    • Penetration Testing Open Source Tools
  • Inteview Questions
    • Automation Testing Interview Questions
    • Manual Testing Interview Questions
    • ISTQB Interview Questions
    • Cucumber Interview Questions
    • Software Testing Interview Questions
    • Penetration Testing Interview Questions

What is Cyclomatic Complexity?

By Priya PedamkarPriya Pedamkar

What is Cyclomatic Complexity?

Introduction to Cyclomatic Complexity

Cyclomatic complexity is a measurement to calculate the code complexity and the errors present in the code using the graph methodology in which nodes of the graph represent source code and the arcs present in the graph represent the control flow in the program. The graph notation is used to find a number of ways for the given program and find the complexity of the program. The topological intricacy of the graph can be compared with computer program complexity.

What is Cyclomatic Complexity?

The measurement of efficiency of computer programs using the graphical representation method is known as Cyclomatic complexity. It is the software metric for finding complexity and errors present in the program. The complexity of source code can be easily measured. It was given by McCabe for finding the efficiency of a computer program. It uses the graphical representation in which the independent paths represent the number of ways in which the computer program can execute. This method uses the graph methodology to finding computer program complexity which can be easily applied for source files of the program, individual functions, and modules of the program. The flow of the graph is from top to bottom and the bottom node is used for representing the program end. The maximum value is given as ten. The use of Cyclomatic complexity can be done for software testing, finding the defects and the correlation among them and limiting the complexity of source code.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

It can be calculated by the given formula:

V(G) = E- N + 2*P

Here,

  • P =  Total connected components present in graph.
  • E = Total edge count in a graph.
  • N = Total nodes count in a graph.

For calculating the Cyclomatic complexity, the first graph is made from the assembly code. The assembly code is first to disassemble and then from that code graph is created in the following steps:

  • One node is created for one instruction.
  •  The nodes are internally connected to each other when the next instruction is related to previous instruction.
  •  The recursive call is considered as one functional call otherwise it will create a loop situation that will create a problem to calculate the Cyclomatic complexity for source program.

It is inversely proportional to code readability and easy to understand code. It means when the Cyclomatic complexity is greater the code is not easy to understand and difficult to read and when the complexity is less the code is easy to read and easy to understand.

Properties

Cyclomatic complexity uses a simple algorithm to calculate the program complexity. The Cyclomatic complexity has the formula V(G) = ‘E-N+2*P’ which is used for calculating the complexity of a computer program. For this methodology, it has certain properties that exist to calculate the Cyclomatic complexity. Some of them are mentioned below:

  1. E represents no. of edges present in the graph, M is McCabe’s complexity and N is nodes count.
  2. V(G) is an expression used for defining the number of independent paths of the graph.
  3. The V(G) should be greater than 1.
  4. If the value of V(G) is equal to 1 then there is only one path in the graph which means there is only one solution to the computer program.
  5. The complexity should be less than 10.
  6. It is completely independent of source lines count in the computer program. The complexity does not depend on how many lines of code are there or how many branches are present in the graph.
  7. If the code is reformatted it does not affect the Cyclomatic complexity.
  8. The metric count gets linearly growth if the complexity of the function is increased. It means if the code contains a number of if-else statement it will directly increase the number of metric and the Cyclomatic complexity.
  9. This calculation is quite easy for a single function but when the number of function increases in the source program it increases the complexity calculation. The main reason for the increase in complexity is because of the function call which is not shown in the flow diagram.
  10. It is used for calculating the complexity of source code and not the complexity of data structures used in the source code.
  11. Greater the Cyclomatic complexity less efficient is the source code.

Advantages of Cyclomatic Complexity

It is used for calculating the code complexity and the errors present in the source code if any. Apart from these, there are several advantages, that need to be overlooked while using it for calculating the code complexity. Some of them are described below:

  • As the Cyclomatic complexity calculates the independent paths for the source program, it gives the idea of a number of test cases for testing the source code. So when the number of independent path count is present it helps to test the code in that number of times. And by this, the whole code is covered for testing and solve the bugs if present.
  • By finding the code complexity the potential defect risk is also decreased which means the relative cost is reduced for finding the defects in source code.  By the Cyclomatic complexity calculation, the program maintenance cost is also reduced.
  • Based on the Cyclomatic complexity the project released can be shipped and the product can be on board in the organization.
  • It uses the graphical representation for representing the number of solutions for executing the same source code. And to calculate the Cyclomatic Complexity at that time became easier.

Conclusion

Cyclomatic complexity uses the graphical representation to calculate the complexity of the source program. The graph uses the linear independent path which represents the individual solution for the execution of source code. It is widely used for testing different software and finding defects in the source program.

Recommended Articles

This is a guide to the What is Cyclomatic Complexity?. Here we discuss the Introduction and the different Properties along with advantages. You can also go through our suggested articles to learn more –

  1. What is Automation Testing?
  2. Selenium Automation Testing
  3. Testing Methodologies
  4. Automation Testing Interview Questions
Popular Course in this category
Software Testing Training (11 Courses, 2 Projects)
  11 Online Courses |  2 Hands-on Projects |  65+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course

Related Courses

Penetration Testing Training Program (2 Courses)4.9
TestNG Training (4 Courses, 2 Project)4.8
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2023 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more