Wikipedia has a definition for a control flow graph. I've also heard terminology thrown around referring to 'call (flow?) graph', but can't find any relevant resources. What is the relationship between the two?
CONTROL FLOW GRAPHS Vs FLOWCHARTS:The flowchart focuses on process steps, where as the flow graph focuses on control flow of the program. The act of drawing a control flow graph is a useful tool that can help us clarify the control flow and data flow issues.
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.
There are several types of control-flow diagrams, for example: Change-control-flow diagram, used in project management. Configuration-decision control-flow diagram, used in configuration management. Process-control-flow diagram, used in process management.
A control-flow graph (cfg) models the flow of control between the basic blocks in a program. A cfg is a directed graph, G = (N, E). Each node n ∈ N corresponds to a basic block. Each edge e = (ni, nj) ∈ E corresponds to a possible transfer of control from block ni to block nj.
Wikipedia defines a call graph as a representation of the calling relationships between subroutines in a program. In a call graph, an edge between two nodes f
and g
:
f --> g
represents the fact that subroutine f
calls subroutine g
. A call graph gives an inter-procedural view of a program.
A control flow graph (CFG) provides finer "details" into the structure of the program as a whole, and of the subroutines in particular. For instance, the CFG of a subroutine f
will make explicit all of the paths that are induced by a conditional branch:
/ branch1 \
begin --> condition --> --> codeblock --> g --> end
\ branch2 /
This kind of CFG is used to build an intra-procedural view of a subroutine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With