Abstract- This paper describes a graph-theoretic complexity measure
and illustrates how it can be used to manage and control program com-
paper first explains how the graph-theory concepts apply
and gives an intuitive explanation of the graph concepts in programming
terms. The control graphs of several actual Fortran programs are then
presented to illustrate the conelation between intuitive complexity and
the graph-theoretic complexity .Several
properties of the graph-
theoretic complexity are then proved which show, for example, that
complexity is independent of physical size (adding or subtracting
functional statements leaves complexity unchanged) and complexity
depends only on the decision structure of a program.
The issue of using non structured control flow )s also discussed. A
characterization of nonstructured control graphs is given and a method
of measuring the "structuredness" of a program is developed. The re-
lationship between structure and reducibility is illustrated with several
The last section of this paper deals with a testing methodology used
in conjunction with the complexity measure; a testing strategy is de-
fined that dictates that a program can either admit of a certain minimal
testing level or the program can be structurally reduced.
Index Temls-Basis, complexity measure, control flow, decomposi-
tion, graph theory , independence,
linear, modularization, programming,
reduction, software, testing.
II. A COMPLEXITY MEASURE
In this sl~ction a mathematical technique for program mod-
ularization will be developed. A few defmitions and theorems
from graph theory will be needed, but several examples will
be presented in order to illustrate the applications of the
The complexity measure approach we will take is to mea-
sure and control the number of paths through a program. This
approach, however, immediately raises the following nasty
problem: "Any program with a backward branch potentially
has an infinite number of paths." Although it is possible to
defme a set of algebraic expressions
that give the total number
of possible paths through a (structured) program,l using the
total number of paths has been found to be impractical. Be-
cause of this the complexity measure developed here is defmed
in terms of basic paths-that when taken in combinatio~ will
generate every possible path.
The following mathematical preliminaries will be needed, all
of which can be found in Berge [I] .
1: The cyclomatic number V(G) of a graph G
with n vertices, e edges, and p connected components is
v(G) = e -n + p.
Theorem 1: In a strongly connected graph G, the cyclo-
matic number is equal to the maximum number of linearly
The applications of the above theorem will be made as