graphviz-java icon indicating copy to clipboard operation
graphviz-java copied to clipboard

FDP layout - how to create a clusters link?

Open yauhen-l opened this issue 4 years ago • 1 comments

Example:

       Graphviz.useEngine(new GraphvizCmdLineEngine());
    	
    	Node a = node("a");
    	Node b = node("b");
    	Node c = node("c");
    	
    	MutableGraph subgraph1 = mutGraph("subgraph1").setCluster(true).add(a.link(b));
    	MutableGraph subgraph2 = mutGraph("subgraph2").setCluster(true).add(c);
    	
        MutableGraph g = mutGraph("example1");
        
        g.add(subgraph1);
        g.add(subgraph2);
        
        subgraph1.addLink(subgraph2);
        
        
        Graphviz.fromGraph(g).engine(Engine.FDP).height(100).render(Format.SVG).toFile(new File("example/ex1.svg"));

Produces dot file:

graph "example1" {
subgraph "cluster_subgraph1" {
"a" -- "b"
} -- subgraph "cluster_subgraph2" {
"c"
}
}

Which looks like this: image

However expected result is:

graph "example1" {
subgraph "cluster_subgraph1" {
"a" -- "b"
}
subgraph "cluster_subgraph2" {
"c"
}
cluster_subgraph1 -- cluster_subgraph2
}

Which gives completely different look with a link between clusters: image

Is dot file always optimized? Or there is a way to create links between clusters? There is also an example on graphviz site: http://www.graphviz.org/Gallery/undirected/fdpclust.html

yauhen-l avatar Feb 14 '21 20:02 yauhen-l

Interesting, I thought cluster_1 { a, b } -- cluster_2 { c } is the same as cluster_1 { a, b } cluster_2 { c } cluser_1 -- cluster_2 but appearantly not. I don't see any workaround right now, I'll have to fix it.

nidi3 avatar Mar 07 '21 16:03 nidi3