Control Flow Graph Factory Tutorial

Prerequisites

Please download and install Control Flow Graph Factory Plugin.

Back to the top

Generate a graph from Java class file.

Let's get started with the first step. Most tutorials start out with a simple Hello World program. We've created a program those graph includes a branch element. Just copy the following sample to your eclipse project and compile it.

package test;

public class C2 {

	public static float abs(float a) {
		float b = 0.0F;
		if(a <= b){
			return (b - a);
		}

		return a;
	}
	
}

To generate the graph for the method main select the method in package explorer and open the context menu "Create Control Flow Graph". Select submenu "Sourcecode graph" to generate a source code graph for this method.

Context menu > Create Control Flow Graph > Create Sourcecode  Graph

Now you select the target folder in the export dialog. To save the graph file click OK.

Dialog to select folder, name and format

The graph is generated and open in a Control Flow Graph Editor.

Graph in Control Flow Graph Factory

Now you can generate a bytecode or a basic code graph in the same way. Use for that the context menu in the package explorer "Create Control Flow Graph/Bytecode graph" or "Create Control Flow Graph/Basic block graph.

Back to the top

Edit and export Graph

The Control Flow Graph Factory editor window provides you with some editing functions. You can move copy or delete the graph elements. You can order layout your elements by using the layout algorithms or layout the elements manually.

Context menu to align elements (horizontal, vertical) Context menu to resize elements resized elements after choosing minimal width

To export the modified graph in DOT, GraphXML format or to an image please use the export functions provided by the Control flow graph Factory. You can export the graph directly to DOT or GraphXML format by selecting the format in the context menu.

Dialog with possible formats (Dr. Garbage Graph, DOT, GraphXML)

The Control Flow Graph Factory provides a simple DOT text editor for editing the dot files.

Example DOT file in integrated DOT file editor

You can generate graphs for the selected method, selected class or for the whole package.

Possible options when exporting in GraphXML format

Thank you for practicing with this tutorial. For questions and discussion around the control flow graph topics please use our contact form.

Back to the top