Control-flow graph
Also known as Control-flow graph, Control-flow graph in software engineering
Definition
A graph that represents the possible paths of execution through a program.
What it means
A control-flow graph, or CFG, models a procedure as nodes and directed edges. Nodes represent statements or blocks, while edges represent possible transfers such as conditions, loops, exceptions, and returns. CFGs support cyclomatic complexity, unreachable-code detection, path analysis, and test design. They make branching structure visible independently of source formatting.
Example
For a checkout function, a CFG might show separate paths for an invalid card, an unavailable item, and a successful payment. A reviewer can see that a new error branch bypasses cleanup before merging the change.
Limitations
A CFG is usually built from static assumptions. Dynamic dispatch, reflection, concurrency, and exceptions can make the graph incomplete or overly broad. A graph also says little about whether a path produces the right business result.
How to use the signal
Weave’s Engineering Intelligence can help locate high-branching changes in the surrounding pull request and review history. Pair CFG findings with test coverage and production evidence, and keep the graph calculation in the static-analysis tool.
How this relates to Weave
Weave’s Engineering Intelligence can help locate high-branching changes in the surrounding pull request and review history. Pair CFG findings with test coverage and production evidence, and keep the graph calculation in the static-analysis tool.
Explore Engineering intelligence