A flow graph 𝐹 with entry node (1) and exit node (11) is shown below: What is…

2019

A flow graph 𝐹 with entry node (1) and exit node (11) is shown below:

What is the cyclomatic complexity of flowgraph 𝐹?

  1. A.

    2

  2. B.

    3

  3. C.

    4

  4. D.

    5

Attempted by 84 students.

Show answer & explanation

Correct answer: C

Answer: 4 — the cyclomatic complexity of the flowgraph is 4.

Method (simple and commonly used): count the number of decision points (nodes with multiple outgoing edges) and add 1 for a single connected graph.

  • Top branching node (the node labeled "2,3"): it splits execution to the left subgraph and the right subgraph. (counts as 1 decision)

  • Branch inside the left-hand subgraph (node 6): it splits to two paths that later reconverge. (counts as 1 decision)

  • The loop/return that sends control back toward the entry (the lower part that creates a loop): it provides an additional independent path. (counts as 1 decision)

Computation: number of decision points (3) + 1 = 4.

Alternative check (formula): cyclomatic complexity M = E − N + 2P (for a single connected graph P = 1). Applying that to this flowgraph also yields M = 4.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor