by Dinesh Thakur

For a programmer, to understand a given program, he typically draws arrows from the point of control transfer to its destination, helping him to create a mental picture of the program and the control transfer in it.


According to this metric the more interwined these arrows become the more complex the program. This notion is captured in the concept of a "Knot".

A knot is essentially the intersection of two such control transfer arrows. If each statement in the program is written one as separate line, this notion can be formalized as follows. A jump from line a to line b is represented by the pair (a, b).


Two jumps  (a,b) and (p,q) give rise to a knot if either min (a,b) <min (p,q)<max(a,b) and max (p,q) > max (a,b) ;or min (a,b)< max (p, qa)< max(a,b) and min (p, q)< min (a,b).