A Control-Flow-Graph is:
In computer science, a control-flow graph (CFG) is a representation, using graph notation, of all paths that might be traversed through a program during its execution.
The CFG is essential to many compiler optimizations and static-analysis tools.
I wanted to use them for code optimization and analysis such as dead code elimination and for ensuring valid code. My question is how can I implement a CFG? What data structures should I use and how can this be represented in code?