How to create a automatic graph

I am new to this graphviz. Can anybody help me to create a automatic graph using the code (java)? It would be more helpful when somebody gives a small example

Thanks

vinoth

Assuming you using the

Assuming you using the swig-generated API for java provided by graphviz, the following is a sample program that builds a graph G from scratch by adding two nodes and an edge; reads a graph from a string; and reads in a graph from hello.gv, uses dot to lay it out, and then makes a png image.

(The file hello.gv can contain any valid Graphviz graph, such as digraph G {hello->world} )

public class test {
    static {
    System.loadLibrary("gv");
    }

    public static void main(String[] args) {
    SWIGTYPE_p_Agraph_t g, sg;
    SWIGTYPE_p_Agnode_t n, m;
    SWIGTYPE_p_Agedge_t e;

    g = gv.digraph("G");
    System.out.println(gv.setv(g,"aaa","xxx"));
    System.out.println(gv.getv(g,"aaa"));
    sg = gv.graph(g,"SG");
    n = gv.node(g,"hello");
    System.out.println(gv.getv(n,"label"));
    System.out.println(gv.setv(n,"aaa","xxx"));
    System.out.println(gv.getv(n,"aaa"));
    m = gv.node(g,"world");
        System.out.println(gv.getv(m,"aaa"));
    e = gv.edge(n,m);
    System.out.println(gv.setv(e,"aaa","xxx"));
        System.out.println(gv.getv(e,"aaa"));
    gv.rm(e);
    gv.rm(n);
    gv.rm(m);
    gv.rm(g);

    g = gv.readstring("digraph G {a->b}");
    gv.rm(g);

    g = gv.read("hello.gv");
    gv.layout(g,"dot");
    gv.render(g,"png","hello.png");
    gv.rm(g);
    }
}

Details about the specfic java functions in gv can be found at http://www.graphviz.org/pdf/gv.3java.pdf.

Recent comments