Introduction
Flow Graph is defined as a function in a program that can be represented as a control flow graph and the nodes in the flow graph are defined as program statements while the directed edges are the flow of control. A Flow Graph consists of nodes and edges. The two nodes in the Flow Graph can be either unconnected or connected by an edge in either direction or connected by an edge in all directions.
While tracing a path from a source to a sink a back edge is an edge that leads back to a node that has already been visited. The Flow Graph contains one source node and one sink.
A source node is the node that has no incoming edges while a sink node is the node with no outgoing edges. A program's function may contain more than one sink node, but this graph can be converted into a graph with only one sink. There are some languages that allow more than one source. This construct is very rare and not used in Structured Programming.
- Used as a main tool for test case identification.
- Represents the relationship between program segments, that is the sequence of statements having the property that if the first member of the sequence is executed then all other statements in that sequence will also be executed.
- Nodes represent one program segment.
- The area bounded by edges and nodes are called regions.
Flow Graph Symbols
Standard notations used in constructing a flow graph are as in the following.
To indicate a Sequence:
To indicate "IF-THEN-ELSE":
To indicate a "WHILE" Loop:
To indicate a "Repeat-Until" Loop:
To indicate a "CASE" Statement:
On a Flow Graph:
- Arrows called edges indicates flow of control.
- Circles called nodes indicates one or more actions.
- Areas bounded by edges and nodes are called regions.
- A predicate node is a node containing a condition.