Skip to content
BENIBIX Learn

Call Graph vs Control Flow Graph

People think a call graph and a control flow graph are two names for the same map of a program, and they are not. A call graph is drawn between functions: each arrow means this one calls that one. A control flow graph is drawn inside one function: each arrow is a step, and it splits at each if and loop. Use the first to see how far a change spreads, and the second to find untested paths.

Development🕸️ Code Intelligence

Call Graph

A map of which functions call which, drawn as dots and arrows.

A call graph shows which functions call which other functions. Each function is a dot, and an arrow means this one calls that one. Following the arrows forward shows what a function needs. Following them back shows who needs it. Editors show a small piece of it as the call hierarchy.

Example
Lucy opens the call hierarchy for parseDate. It shows two callers. Above them is the checkout function that calls both.
Why it matters
It shows how far a change spreads. It also finds functions that nothing calls at all.
Full entry
Development🕸️ Code Intelligence

Control Flow Graph (CFG)

A map of each path a function can take. It splits at each if and loop.

A control flow graph shows every path a program can take through one function. Each box is a run of steps with no choice in it. An arrow leads to the next box. An if or a loop makes the arrows split or circle back. Tools read it to find code no path can reach, or a path that skips a check.

Example
A tool reads the control flow graph of a login function. It finds one path where the password check is skipped.
Why it matters
Bugs hide on paths nobody tested. The graph shows every one of them.
Full entry

In one line

Call Graph
A map of which functions call which, drawn as dots and arrows.
Control Flow Graph (CFG)
A map of each path a function can take. It splits at each if and loop.