retagged by
2,072 views
1 votes
1 votes

With respect to software testing, consider a flow graph G with one connected component. Let E be the number of edges, N be the number of nodes, and P be the number of predicate nodes of G. Consider the following four expressions:

  1. E - N + P                                            
  2. E - N + 2
  3. P +  2
  4. P + 1

The cyclomatic complexity of G is given by

  1. I or III
  2. II or III
  3. II or IV
  4. I or IV
retagged by

1 Answer

3 votes
3 votes

Ans C)


The cyclomatic complexity of a structured program is defined with reference to the control flow graph of the program, a directed graph containing the basic blocks of the program, with an edge between two basic blocks if control may pass from the first to the second.

    V(G) = E − N + 2K,

where

    E = the number of edges of the graph.
    N = the number of nodes of the graph.
    K = the number of connected components = 1(given)

Cyclomatic complexity provides the upper bound on the number of test cases that must be executed to
guarantee that every statement in a component has been executed at least once.

Thus, Cyclomatic complexity, V(G), for a flow graph, G, is defined as
V(G) = E - N + 2
Also, it can be defined as
V(G) = P + 1,

where P is the number of predicate nodes contained in the flow graph G. ( A predicate node is a node containing a condition.)

The value for V(G) provides us with an upper bound for the number of independent paths that form the basis set ( a set of independent paths for the flow graph such that if tests can be designed to force execution of these paths then every statement in the program will have been guaranteed to be executed at least one time and
every condition will have been executed on its true and false sides)
and, by implication, an upper bound on the number of tests that must be designed and executed to guarantee coverage of all program statements.

edited by
Answer:

Related questions

0 votes
0 votes
1 answer
4
Ishrat Jahan asked Nov 1, 2014
1,347 views
void swap(float* A1, float* A2) { float temp; if (*A1 = = *A2) return; temp = *A1; *A1 = *A2; *A2 = temp; return; }The program volume for the above module using Halstead'...