--- Video Title: Cyclomatic Complexity Measures Description: Cyclomatic Complexity Measures Watch more Videos at https://www.tutorialspoint.com/videotutorials/index.htm Lecture By: Mr. Arnab Chakraborty, Tutorials Point India Private Limited --- We are going to discuss Cyclomatic Complexity Measures. So, every program encompasses statements to execute in order to perform some task, and other decision-making statements that decide what statements need to be executed next. So, these decision-making constructs change the flow of the program. Otherwise, the program will have the linear flow of the control. But due to due to existence of such decision-making statements, the program control is getting interrupted. It is not getting executed in the sequential flow, but depending upon the condition true and false, the control will be Going to the respective target statement. If we compare two programs of the same size and one with the more decision-making statements will be more complex as the control of the program jumps frequently from one statement to another statement and the linear execution of the instructions will get hampered in that case. So, Maccabay in the year that is 1976 proposed Cyclomatic Complexity Measure to quantify the complexity of a given software. So, it is a graph-driven model and that is based on decision-making constructs of the program such as if else, do while, repeat until, switch case and go to statements. So, process to make the flow control graph. So, how to make the flow control graph for it? So, break program in smaller blocks and delimited by decision-making constructs. We will be giving one example for the better understanding on this. So, create nodes representing each of these nodes. So, create nodes representing of each of these nodes. So, what is the how the nodes will get created? That we shall explain also in our example. So, connect nodes as follows. If the control can branch from block I to block J, draw and arc accordingly. From exit node to the entry node, draw and arc. So, just remember them. These are the rules and regulations for the drawing of the control graph. To calculate the cyclomatic complexity of a program module, we use the following formula. That is, we know that it is a number of edges. You can find this A, E is the total number of edges. And N is the total number of nodes. So, V of G is equal to E minus N plus 2. So, now, let us go for one example for the better understanding. So, here is one sample code is given. One sample code is with us. Here we are having this F expression 1. If the expression is 2, then I will be going for statement 2. Prior to this F, we are having statement 1, statement 1. And else, if the condition or the expression is returning false, then expression 3 will be executed. Expression 4 is there. Look at that indentation. So, that means, the statement number 1 and statement number 4 will be always getting executed. Depending upon the expression, either statement number 2 or 3 will get executed. Then do statement number 5 while expression 2. And at the end, look at the indentation, statement number 6 is there. So, this is a sample So, from here, we are trying to make one flowchart. So, statement number 1 will be executing. Depending upon the expression, either statement number 2 or statement number 3 will be executing. Then we are having this statement number 4. And statement number 5 will be executing. And this is one expression. When the expression will be true, it will be going for again and again. When the expression will be written false, it will come out. And statement number 6 will get executed. So, this nothing but a flowchart, which has been derived from the sample code. So, now, this is our flow graph. This is the control flow graph, you can find that. So, for this one, we are making one node, let it be N1. So, expression number 1, we are making one node, let it be N2. And here, we are having this respective statement number 2, and statement number number 3, we are having this node N3 and N4. For statement number Number 4, we are having this node N5. Statement number 5, the node is N6. Expression, the node is N7. And statement number 6, we are having this node N8. So, according to the control flow, we are drawing this respective, this control lines. And it was mentioned, I think you can recall, that draw exit node to entry node, draw one arc. So, from the exit node to the entry node, draw one arc. So, that is why we have drawn one arc from the exit node to the entry node. So, if we go on calculating that how many directed edges you have drawn, you can get the value that is E 10. So, E here is having the value 10. How many nodes you have drawn here? We have drawn 8 number of nodes. So, the cyclomatic complexity of this program segment will be 10 minus 8 plus 2, and the value will be coming as 4. So, according to P. George Jensen, the cyclomatic complexity of a module should not exit 10. So, in this way, this is a very nice example we have explained here. So, how this cyclomatic complexity can be measured, and what are the different rules and regulations, we will be explained that one into further details. Thanks for watching this video. Tutorialspoint.com. Simply easy learning. 0.678. Academics for крomping. 0. Ils