ZeroOutEdges
DRAFT

Misconception:

A CFG can contain nodes (besides the exit node) that have no outgoing arrows.

Incorrect

A control-flow graph node (other than the exit node) can have zero outgoing edges

Correct

Except for the exit node, all control-flow graph nodes have outgoing edges

Correction
Here is what's right.

In a CFG, every node must be able to reach the exit node (which we draw with a circle containing an “x”). Thus, there must be a path from any node to the exit, so that the method represented by the CFG has some way to terminate.

Note: If a method contains a while (true) {...} loop, without any edges leaving the loop from inside, then one could say that the method never terminates, and that thus there is no path to the exit node from that loop. However, we usually draw a condition node (diamond) for the condition, with two outgoing edges (one for the condition evaluating to true, the other for the condition evaluating to false), even in cases when it’s theoretically possible to determine that the condition will always evaluate to the same value.

Language

Java
Notional Machine
ControlFlowAsGraph

Concepts

Expressible In

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.