Complexity Profile Graph (CPG)

The Complexity Profile Graph, or CPG, is a statement-level complexity or comprehensibility metric. Each segment, which corresponds roughly to a program statement, is assigned a complexity that is a weighted sum of:

Reachability - the number of conditions that must be evaluated to reach the segment from outside of the enclosing method, function, or other top-level statement block. This is the traditional definition of reachability.

Content - the log of the number of significant tokens in the segment. Some punctuation, such as block-enclosing braces or a statement-ending semicolon, is not considered significant. A pair of parenthesis is counted as one token.

Breadth - the number of statements, methods, etc. in the innermost block containing the segment.

Inherent - value assigned based on the inherent complexity of the innermost enclosing structure. For example, segments in switch or case statements are assigned an inherent complexity of 3.0. This reflects the view that some structure types are inherently more complex than others.

The CPG window "Data Sets" menu allows any combination of these values and the total complexity to be viewed.

Currently, the CPG is implemented only for Java and Ada.


 
 

CPG Window

The main section of this window shows the complexity values for the currently selected data sets. If the source is unedited, selecting segments in the CPG window will select the corresponding text in the source CSD window, and vice versa. The selection in the CPG window is shown as a yellow background. If the source is unedited, a black rectangle shows the segments that are currently visible in the CSD window.

Each data set value is scaled in the display, by the weight used in computing the total complexity, unless there is only one data set, in which case it is shown unscaled.

The label at the top of the CPG window shows the complexity values of the segment under the mouse cursor. If the weight of a particular data set is not 1.0, the value and weight are displayed.

The scale button allows the graph to be scaled, from two-pixel wide bars to screen-width bars.

If "Scroll Lock" is on, the CPG window and the CSD window from which it was generated will scroll as one. This option is not available if the source has been edited.

A scrollbar at the bottom of the window allows the CPG to be scrolled if it does not fit in the window.


 
 

File Menu

Save Data - allows CPG complexity values to be saved in a straightforward text format.

Escape From Virtual Desktop / Enter Virtual Desktop - takes the CPG window in and out of the virtual desktop.

Disconnect From Source - dissociates the CPG window from the source CSD window. A second CPG window can then be generated from the same source.

Exit This Window - closes the CPG window.


 
 

Data Sets Menu

This menu allows each data set to be turned off or on.


 
 

View Menu

Vertical Orientation - if on, the segments axis is vertical, and the complexity horizontal.

Show Key - if on, a key that shows the color for each data set is shown (if there is more than one active data set).

Show Axis Labels - if on, the segment and complexity axes are labeled. If there is only one active data set, the complexity axis is labeled with the name of that data set, otherwise it is labeled with "complexity".

Show Number Labels - if on, segment and complexity axes have value labels. The labels are evenly spaced based on a minimum inter-label separation.