title: How to calculate CBO and LCOM for a class using Python and SciTools Understand API
body: <p>In <strong>Python</strong>, how can I calculate <strong>LCOM</strong> (lack of cohesion) for C++ files (or any other file types) <strong>using SciTools Understand API</strong>?</p>
  
  <p>For an assignment, we're asked to calculate LCOM ourselves instead of using SciTools's Understand. </p>
  
  <p><strong>To calculate LCOM4</strong>, I need the following metrics,</p>
  
  <ol>
  <li><p>number of functions/methods in a class (given by Understand as "<em>CountDeclFunction</em>")</p></li>
  <li><p>number of method pairs in class with at least one instance variable that they commonly use or define in their body.</p></li>
  <li><p>number of method pairs in class that have at least one instance method that they commonly call in their body.</p></li>
  </ol>
  
  <p>Any suggestion is much appreciated.</p>