Cyclomatic complexity is the count of linearly independent paths in a program's source code. With the help of control flow graph, we can use the following formula to calculate this:

CC = E - N + 2P

Variable Description
E The number of edges in the control flow graph.
N The number of nodes in the control flow graph.
P The number of connected components. This has a value of 1 if you are computing at the method (i.e. function or subroutine) level.

Related
Control Flow Graph