graphviz-java
graphviz-java copied to clipboard
FDP layout - how to create a clusters link?
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:
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:
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
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.