title: cyclomatic complexity = 1 + #if statements?
body: <p>I found the following paragraph regarding cyclomatic complexity <a href="http://en.wikipedia.org/wiki/Cyclomatic_complexity" rel="noreferrer">on Wikipedia</a>:</p>
  
  <blockquote>
    <p>It can be shown that the cyclomatic complexity of any structured program with only one entrance point and one exit point is equal to the number of decision points (i.e., "if" statements or conditional loops) contained in that program plus one.</p>
  </blockquote>
  
  <p>That would imply a cyclomatic complexity of 3 for two arbitrary nested if statements:</p>
  
  <pre><code>if (a)
  {
      if (b)
      {
          foo();
      }
      else
      {
          bar();
      }
  }
  else
  {
      baz();
  }
  </code></pre>
  
  <p>Since exactly one of the three functions is going to be called, my gut agrees with 3.</p>
  
  <p>However, two arbitrary if statements could also be written in sequence instead of nesting them:</p>
  
  <pre><code>if (a)
  {
      foo();
  }
  else
  {
      bar();
  }
  
  if (b)
  {
      baz();
  }
  else
  {
      qux();
  }
  </code></pre>
  
  <p>Now there are four paths through the code:</p>
  
  <ul>
  <li>foo, baz</li>
  <li>foo, qux</li>
  <li>bar, baz</li>
  <li>bar, qux</li>
  </ul>
  
  <p>Shouldn't the cyclomatic complexity of this fragment hence be 4 instead of 3?</p>
  
  <p>Am I misunderstanding the quoted paragraph?</p>