|
Notes > Software Analysis / Testing > Control Flow Graphs (CFG)
|
A Control Flow Graph (CFG) is a diagrammatic representation of a program and its execution. A CFG shows all the possible sequences of statements of a program. CFGs consist of all the typical building blocks of any flow diagrams. There is always a start node, an end node, and flows (or arcs) between nodes. Each node is labelled in order for it to be identified and associated correctly with its corresponding part in the program code.
CFGs allow for constructs to be nested in order to represent nested loops in the actual code.
If Loop

Nested If Loop

While Loop

Do While Loop

In programs where while loops exist, there are potentially an infinite number of unique paths through the program. Every path through a program has a set of associated conditions. Finding out what these conditions are allows for test data to be created. This enables the code to be tested to a suitable degree.
The conditions that exist for a path through a program are defined by the values of variable which change through the execution of the code. At any point in the program execution, the program state is described by these variables. Statements in the code such as "x = x + 1" alter the state of the program by changing the value of a variable (in this case, x).
Infeasible paths are those paths which cannot be executed. Infeasible paths occur when no values will satisfy the path constraint.
Search for "Control Flow Graphs (CFG)" on:
Google |
Kelkoo |
Amazon |
eBay (UK) |
eBay (US)
Search for "Control Flow Graphs (CFG)" on the rest of Computing Students: Control Flow Graphs (CFG)
|
|
|