Graphs-and-Tree
Question 7
|
A flow graph F with entry node (1) and exit node (11) is shown below:
What is the cyclomatic complexity of flowgraph F
2
|
|
3
|
|
4
|
|
5
|
Question 7 Explanation:
To find cyclomatic complexity we have 3 formulas
1. The number of regions(R) corresponds to the cyclomatic complexity.
Total number of regions(R) are 4.
2. V(G),Flow graph is defined as V(G)=E-N+2 where E is the number of flow graph edges, and N is the number of flow graph nodes.
Predicates are 3+1=4
3. V(G),Flow graph is defined as V(G)=P+1 where p is the number of predicate nodes contained in the flow graph G.
Edges(E)-Nodes(N)+2
= 11-9+2
= 2+2
= 4
1. The number of regions(R) corresponds to the cyclomatic complexity.
Total number of regions(R) are 4.
2. V(G),Flow graph is defined as V(G)=E-N+2 where E is the number of flow graph edges, and N is the number of flow graph nodes.
Predicates are 3+1=4
3. V(G),Flow graph is defined as V(G)=P+1 where p is the number of predicate nodes contained in the flow graph G.
Edges(E)-Nodes(N)+2
= 11-9+2
= 2+2
= 4
Correct Answer: C
Question 7 Explanation:
To find cyclomatic complexity we have 3 formulas
1. The number of regions(R) corresponds to the cyclomatic complexity.
Total number of regions(R) are 4.
2. V(G),Flow graph is defined as V(G)=E-N+2 where E is the number of flow graph edges, and N is the number of flow graph nodes.
Predicates are 3+1=4
3. V(G),Flow graph is defined as V(G)=P+1 where p is the number of predicate nodes contained in the flow graph G.
Edges(E)-Nodes(N)+2
= 11-9+2
= 2+2
= 4
1. The number of regions(R) corresponds to the cyclomatic complexity.
Total number of regions(R) are 4.
2. V(G),Flow graph is defined as V(G)=E-N+2 where E is the number of flow graph edges, and N is the number of flow graph nodes.
Predicates are 3+1=4
3. V(G),Flow graph is defined as V(G)=P+1 where p is the number of predicate nodes contained in the flow graph G.
Edges(E)-Nodes(N)+2
= 11-9+2
= 2+2
= 4