42 lines
1.1 KiB
Text
42 lines
1.1 KiB
Text
|
digraph g {
|
||
|
l1 [label = "Enter f()"];
|
||
|
l2 [label = "2: int sum = 0"];
|
||
|
l3 [label = "3: int prod = 0"];
|
||
|
l4 [label = "4: while (x > 0)"];
|
||
|
l5 [label = "5: sum += sum"];
|
||
|
l6 [label = "6: prod *= prod"];
|
||
|
l7 [label = "7: x--"];
|
||
|
l9 [label = "9: log(\"sum: \" + sum)"];
|
||
|
l10 [label = "10: log(\"prod: \" + prod)"];
|
||
|
// 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"];
|
||
|
l1 -> x;
|
||
|
x -> {l2} [style=invis];
|
||
|
}
|
||
|
|
||
|
{ // data edges
|
||
|
edge [color=red,constraint=true];
|
||
|
edge [style = invis];
|
||
|
{l2 l5} -> {l5 l9} [color = blue]; // sum
|
||
|
{l3 l6} -> {l6 l10} [color = darkgreen]; // prod
|
||
|
{x l7} -> {l4 l7} [color = red]; // x
|
||
|
}
|
||
|
}
|