The single-file-graph layout library is a GNU GPL single C source file which can create a graph layout and easiest way is to add it to other C/C++ source to add graph layout functionality to a program.

The compiled debian Linux binary for qt5 with source of the qt graph editor
using the sfg.c graph layout routines is here in
Using clang and compiling c to run in the browser there is now a demo test version
running directed graph layout in the browser with a edit text area here at this link websfg


The source and example code is here in sfgraph.tar.gz or at

The input is graph data with nodes+edges and the output is information how to draw the graph layout.

Now added initial GNU GPL Free qt5 gui version called hypersfg on notabug
and it can read partial GML, DOT, graphml xml and matrix data and looks like this:

It only needs a parser and drawing routines and that can be as simple as strtok() and svg output.

It can be used with c, c++, python, java, go, php, javascript using swig software wrappers or emscripten.

The quality of the output drawing depends on the complexity of the drawing routines to add.

Using minimal drawing routines this are example of sugiyama directed graph layout with sfg.c


There is example how to use it with python or C and it looks like this:

    /* init to start */
    status = sfg_init();
    if (status < 0) {    /* error */


    /* run layout */
    status = sfg_layout();
    if (status < 0) {    /* error */

    printf("drawing has size (%d,%d) with %d levels and %d nodes with %d edges\n", sfg_maxx(), sfg_maxy(), sfg_nlevels(),
           sfg_nnodes(), sfg_nedges());


    /* get node data */
    status = sfg_node_foreach(getnodedataps);
    if (status < 0) {    /* error */

    /* get edge data */
    status = sfg_edge_foreach(getedgedataps);
    if (status < 0) {    /* error */


    /* de-init to finish */
    status = sfg_deinit();
    if (status < 0) {    /* error */

Because sfg.c is based on gml4gtk it is guaranteed there will be updates and support.