digraph g { l1 [label = "Enter f()", style = filled]; l2 [label = "2: int sum = 0"]; l3 [label = "3: int prod = 0", style = filled]; l4 [label = "4: while (x > 0)", style = filled]; l5 [label = "5: sum += sum"]; l6 [label = "6: prod *= prod", style = filled]; l7 [label = "7: x--", style = filled]; l9 [label = "9: log(\"sum: \" + sum)"]; l10 [label = "10: log(\"prod: \" + prod)", style = filled]; // graph order {rank=min; l1}; {rank=same; l2 l3 l4 l9 l10}; {rank=max; l5 l6 l7}; { edge [style=invis]; l2 -> l3 -> l4 -> l9 -> l10; l5 -> l6 -> l7; } { // control edges // edge [style=invis]; l1 -> {l2 l3 l4 l9 l10}; l4 -> {l5 l6 l7}; } { // data input node [style=dashed]; // node [style=invis]; // edge [style=invis]; x [label = "x = x_in", style = filled]; l1 -> x; x -> {l2} [style=invis]; } { // data edges edge [color=red,constraint=true]; {l2 l5} -> {l5 l9} [color = blue]; // sum {l3 l6} -> {l6 l10} [color = darkgreen]; // prod {x l7} -> {l4 l7} [color = red]; // x } }