See the vds5 plugin in the Hex-Rays SDK.
/* * Hex-Rays Decompiler project * Copyright (c) 2007-2008 by Hex-Rays, [email protected] * ALL RIGHTS RESERVED. * * Sample plugin for the Hex-Rays Decompiler. * It adds a new command to show graph of the ctree. * The current item will be highlighted in the graph. * * The command hotkey is G. It is also added into the right-click menu. * * To display the graph, we traverse the ctree and build * a gdl_graph_t object. Then we use gen_gdl() function from IDA * to create a GDL file from this object. Finally, we call * wingraph32 to display the graph on the screen. * */