Correct option is B
Cyclomatic complexity is calculated using the formula: Cyclomatic Complexity (V(G)) = E – N + 2P Where,
· E is the number of edges in the graph.
· N is the number of nodes in the graph.
· P is the number of connected components (typically 1 for a single program).
Let's count the number of nodes (N) and edges (E) in the given flow graph:
Nodes (N): There are 9 nodes in the graph.
Edges (E): Count the edges by following each line connecting the nodes. The given graph has the following edges:
Connected Components (P): The graph represents a single connected component of the program, so P = 1.
Using the formula:
Therefore, the cyclomatic complexity for the given flow graph is:
(b) 4