Don't miss an insight. Subscribe to Techopedia for free.


Control Flow Graph

What Does Control Flow Graph Mean?

In computer science, a control flow graph (CFG) is the graphical representation of control flow or computation during the execution of programs or applications. Control flow graphs are mostly used in static analysis as well as compiler applications, as they can accurately represent the flow inside of a program unit.


The control flow graph owes much of its development to Frances E. Allen.

Techopedia Explains Control Flow Graph

A control flow graph is process oriented and can show all the paths that can be traversed during a program execution. A control flow graph can also be considered as a directed graph in which edges portray control flow paths and the nodes portray basic blocks, which are straight line segments without any jumps or branching.

In a control flow graph, two specially designated blocks exist: entry and exit blocks. The entry block allows the control to enter into the control flow graph, whereas the control flow leaves through the exit block. In other words, the control flow graph is comprised of all the building blocks involved in a flow diagram such as the start node, end node and flows/arcs between the nodes. A control flow graph can depict how different program units or applications process information between different ends in the context of the system.

There are many advantages associated with a control flow graph. It can easily summarize the information per each basic block. It can easily locate unreachable codes of a program, and syntactic structures such as loops are easy to find in a control flow graph.


Related Terms