use twopi as a java api

Hello,
I'm using tha java api graphviz to design graphs.
Until now, everything is going ok, but I want to improve my program by using the centralisation of one node.
I read some articles which speak about this point, so I decided to use twopi − filter for radial layouts of graphs
However, the overlap between nodes is not clear, I used different modes (false, scale, true) and for each mode there is overlap and the graph can't be clearly read. Only the rank changes when using the different modes.

This is my graph:

digraph G {
root=b;
ranksep=1;
overlap=true;
a->b;
a-> c;
a-> d;
b-> e;
e-> c;
}

Any suggestions?

graphviz behaviour ubuntu/windows

I don't know if I have to create a new topic...

Is there any diffrence between graphviz on ubuntu and graphviz on windows?

The behaviour is not the same, the graph is bigger on ubuntu and it cannot be fully displayed, some nodes are omitted, the edhes are smaller...

The overlap parameter only

The overlap parameter only deals with node overlaps, not with edge-node overlaps. In this case, your graph is so simple that the nodes are laid out on a line. Node b is in the center; nodes a and e are placed on opposite sides; then nodes c and d are placed on opposite sides. There are various ways to get around this. This simplest is to draw the edges as splines rather than line segments: set splines=true. Alternatively, you can set weight=0 for edge e->c. This will cause c to connect with a during the layout, which defeats the symmetry. Finally, you can try another layout, such as neato.

how to avoid edge overlap?

First, thank's to erg for the reply. Then, when I used neato, the result was worst...

I have juste tried with a small graph, but in fact my graph is bigger than this...

I tried this setting:

thedigraph G { graph [splines=true,  overlap=true, ratio=.5 ranksep=2];
 node [  shape = plaintext];
root= c

a->b;
a-> c;
a-> d;
b-> e;
e-> c;
}

There is no overlaps (for both nodes and edges) but the node c is not in the center...

I want to display icons instead of simple nodes, sometimes the icon is dispalyed and sometimes not. I'm pretty sure that the image path is the good one. 

 any idea for these problems?

How is the result worse with

How is the result worse with neato? Because node c is not in the center? I should have been clearer. If you use neato, there is no guarantee that any node will be in the center. Only twopi will put a node in the center. As for the problem with icons, you'll have to give more information.  What is your input graph specifying icons? What does the output look like? Are you getting any warning messages?

No warning message that is the problem

I need to center one of my node, cause my application highlight this node and shoes the main links related to. so, I chose twopi.

I solved my icon's problem. It was due to the label of the icon, when the label is empty (the string denoting the node is empty), the icon is not dispalyed.

I think that, it is a big problem of graphviz, there is no error or warning or anything to indicate any problem...

I have some other questions again, please,

- Do you know any way to avoid that the label of an adge across the edge?

- Do you know any reason which prevents the node that I specified to be in the center?

 

 

- I solved my icon's problem.

- I solved my icon's problem. It was due to the label of the icon, when the label is empty (the string denoting the node is empty), the icon is not dispalyed.

This should not be happening. Can you post your graph or submit a bug report?

- Do you know any way to avoid that the label of an adge across the edge?

Not really. Except in dot, edge labels are added after the drawing is done. We try to place the label beside the edge, but there is often no room, and the placement algorithm is fairly simple. For certain simple edge labels, we have a prototype for aligning the label along the edge.

- Do you know any reason which prevents the node that I specified to be in the center?

If you are using twopi and you specify a root node, it will be place in the center. If you have a very unbalanced graph, it may look like its not. Again, if you could post an example, it is easier to comment.

An example

This is an example of my graph (.gv)

digraph G { graph [         splines=true, overlap=true, ratio=.5 ranksep=2]; node [  shape = plaintext];
root=id24Location;
id24Location [ label=<<TABLE border="0" cellborder="0">
<TR><TD width="50" height="50" fixedsize="true"><IMG SRC="Icones/Location.png" scale="true"/></TD><td><font point-size="10"><i>Location</i> : <b>New York</b></font></td></TR>
</TABLE>>];
id34Location [ label=<<TABLE border="0" cellborder="0">
<TR><TD width="50" height="50" fixedsize="true"><IMG SRC="Icones/Location.png" scale="true"/></TD><td><font point-size="10"><i>Location</i> : <b>US</b></font></td></TR>
</TABLE>>];
id1911061619110616 [ label=<<TABLE border="0" cellborder="0">
<TR><TD width="50" height="50" fixedsize="true"><IMG SRC="Icones/Date.png" scale="true"/></TD><td><font point-size="10"><i>Date</i> : <b>1911-06-16</b></font></td></TR>
</TABLE>>];
id4Company [ label=<<TABLE border="0" cellborder="0">
<TR><TD width="50" height="50" fixedsize="true"><IMG SRC="Icones/Company.png" scale="true"/></TD><td><font point-size="10"><i>Company</i> : <b>IBM corp</b></font></td></TR>
</TABLE>>];
id24Location->id34Location[label= "located"];
id4Company->id24Location[label= "location or adress"];
id4Company->id1911061619110616[label= "beginning date"];
}

I want my graph to be center on the node id24Location ...

By the way, I want to generate an svg not a png at the end. I read that I have to use the option  -Tsvg but I don't know where to specify this option in my java program...

When I open it (the svg file) with my browser the icons are not displayed.

So, with png the icons are ok and with svg noo

  

 

I want my graph to be center

I want my graph to be center on the node id24Location ...

This node is in the center of the graph layout, but the graph is not symmetric, so the node will off-center in the final drawing. If you want the node to be in the center of the output drawing, use the viewport attribute when rendering. Of course, if you view the output as svg in a browser, it will still seem off-center if the browser window is larger than the image.

By the way, I want to generate an svg not a png at the end. I read that I have to use the option  -Tsvg but I don't know where to specify this option in my java program...

Use the fmt argument as "svg" in gv.render()

When I open it (the svg file) with my browser the icons are not displayed.

So, with png the icons are ok and with svg noo

An svg file is interpreted when you view it, using the pathnames it had when you created it. So your file will contain

<image xlink:href="Icones/Location.png" width="46px" height="44.62px" preserveAspectRatio="xMinYMin meet" x="12" y="-53.31"/>

If you view the svg file from a different directory or use a web server with a different directory structure, the svg rendering won't find the image file. You can do one of the following:

  • Use an absolute pathname for the png files
  • Post-process the svg file to fix the paths to the images
  • Use svg:cairo which will export the actual images into the svg file.

 

 

 

 

Ok

Thank you again erg for your reply, 

Using the absolute or relative path is the same,

However with second one, when I put the file result (.svg) in the same directory as all the icons, it works...

I have one other question again, when I draw a small graph with only two nodes, the edge is small and we can not distinguish between the nodes cause the label of the first one cross the second

this is my graph

digraph G { graph [ tooltip="Clic here to get the full graph or choose a node", href="OutGraph.svg", splines=true, overlap=true, ratio=.5 ranksep=2];
    node [  shape = plaintext];
root=id149Person;
id149Person [ label=<<TABLE border="0" cellborder="0"><TR><TD width="50" height="50" fixedsize="true"><IMG SRC=".\Icones\Person.png" scale="true"/></TD><td><font point-size="10"><i>Person</i> : <b>Virginia Rometty</b></font></td></TR></TABLE>>, tooltip="given-name : Virginia, familly-name : Rometty"];
id122Experience [ label=<<TABLE border="0" cellborder="0"><TR><TD width="50" height="50" fixedsize="true"><IMG SRC=".\Icones\Experience.png" scale="true"/></TD><td><font point-size="10"><i>Professionnal experience</i> : <b> </b></font></td></TR></TABLE>>, href="id122ExperienceOutGraph.svg"];
id149Person->id122Experience[label= "works as"];

}

I don't want to set a fixed size to all edges, so how can I say "put a longer edge to avoid nodes overlaps "?

 

Of course, you are viewing

Of course, you are viewing the svg file through a web server, so a normal absolute path won't work, at least not in the ordinary file system sense. Any path is going to be relative to the root of the server. So, if the absolute path of an image is /Users/erg/tmp/jcr.png, one would get <image xlink:href="/Users/erg/tmp/jcr.png"...> in the svg output. If your web server has root directory /var/www/html, the image would have to be stored in /var/www/html/Users/erg/tmp/jcr.png.

To avoid node overlap, change the graph's overlap attribute to overlap=false or overlap=scale. The first does minimal adjustment to remove node overlaps but the shape may not be preserved; the second uses scaling, so the shape will be preserved, but the size can get large quickly.

OK

Ok thanks. 

When I set overlap=scale there is no overlaps but the length of the edge still too small or too long.

In fact, I create a full graph with all the nodes, when I clic on one of them (with href), it displays the subgraph which concerns only the node choosed.

When the graph is full (contains about 15 nodes) some edges are too long and when there is 5 nodes (one is centred) the graph is perfect, but when I have only two nodes the edge between them is too small and we can't distinguish between the edge's label and the nodes' labels 

An other note concerns the graph settings 

 graph [ tooltip="Clic here to get the full graph or choose a node", href="OutGraph.svg",ratio=0.5 ,ranksep=2,overlap=scale];
    node [  shape = plaintext,];edge [ fontname=Helvetica, fontcolor=red, fontsize=10, arrowsize=1.0 ];

is there any problem? when I remove the ratio (cause I read that it can change the size), all the graph is placed in the left side of the page, even if I put rankdir="LR"

When the graph is full

When the graph is full (contains about 15 nodes) some edges are too long and when there is 5 nodes (one is centred) the graph is perfect, but when I have only two nodes the edge between them is too small and we can't distinguish between the edge's label and the nodes' labels

What do you mean by too long? How do you go from the full graph to a subgraph? Do you lay out the subgraph separately, or induce the layout from the full graph's layout? Can you provide an example of a two node graph when the edge is too small?

is there any problem? when I remove the ratio (cause I read that it can change the size), all the graph is placed in the left side of the page, even if I put rankdir="LR"

Why should there be a problem? Yes, ratio can adjust the graph layout. See http://www.graphviz.org/content/attrs#dratio. By default (without ratio), the final graph drawing is just big enough for the graph, and lies in the first quadrant close to the origin of the coordinate system. This means the graph will always be placed on the left side of the page. The rankdir attribute has nothing to do with placement on the page, and only has effect when used with dot.

an other example

What do you mean by too long? 

too long means there is a lot of ditance between nodes which set the graph bigger than we need...

How do you go from the full graph to a subgraph? Do you lay out the subgraph separately, or induce the layout from the full graph's layout? Can you provide an example of a two node graph when the edge is too small?

For each node I draw the corresponded graph and keep it in a map with the id of the node. Than I draw the full graph, and associate to each node, the corresponded graph, in the attribute href, i give the path to follow

this is a an example of my small graph : 

digraph G { graph [ tooltip="Clic here to get the full graph or choose a node", href="OutGraph.svg",ratio=0.5 ,overlap=scale,];
node [ shape = plaintext,];edge [ fontname=Helvetica, fontcolor=red, fontsize=10, arrowsize=1.0 , arrowhead="vee"];
root=id34Location;
id34Location [ label=<<TABLE border="0" cellborder="0"><TR><TD width="50" height="50" fixedsize="true"><IMG SRC=".\Icones\Location.png" scale="true"/></TD><td><font point-size="10"><i>Location</i> : <b>US</b></font></td></TR>
</TABLE>>, tooltip="location name : USA, type : country"];
id24Location [ label=<<TABLE border="0" cellborder="0"><TR><TD width="50" height="50" fixedsize="true"><IMG SRC=".\Icones\Location.png" scale="true"/></TD><td><font point-size="10"><i>Location</i> : <b>New York</b></font></td></TR>
</TABLE>>, tooltip="location name : New York, type : town", href="id24LocationOutGraph.svg"];
id24Location->id34Location[label= "located"];

}

You may need to treat small

You may need to treat small graphs with different parameters. Try normalize=90 and/or ranksep=3 (or try other values).

As for edges being too long, I'd have to see the graph but as I mentioned, scaling can cause the graph to grow a lot.