Hello,

> However, it seems that it doesn't take into account the hgap property, which 
> should set the "minimum horizontal gap between vertices in the same layer", 
> according to the documentation.
It does take the hgap property into account, the problem is that igraph.plot() 
will rescale your layout to fill the specified bounding box and it does not 
strive to keep the aspect ratio the same. To prove that layout_sugiyama() 
indeed uses the hgap parameter, try this:

>>> g = Graph.Tree(4, 3)
>>> layout_1 = g.layout_sugiyama(hgap=1)
>>> print list(layout_1)
[[1.0, 0.0], [0.0, 1.0], [1.0, 1.0], [2.0, 1.0]]
>>> layout_2 = g.layout_sugiyama(hgap=10)
>>> print list(layout_2)
[[10.0, 0.0], [0.0, 1.0], [10.0, 1.0], [20.0, 1.0]]

The only solution I can think of is to take the layout, get its bounding box 
using the bounding_box() method of the layout itself and then specify the bbox 
parameter of igraph.plot to be proportional to the dimensions of the layout's 
bounding box (and don't forget to set margin=0 or take the margin into account 
when invoking igraph.plot()). Yes, I agree that this sucks. I will add a 
keep_aspect_ratio option to the default graph drawer class in the next version.

If you are willing to modify igraph's source code a bit, you can also work 
around the issue as follows:

1. Open igraph/drawing/graph.py from igraph's source code -- this contains the 
DefaultGraphDrawer class, which is used for graph drawing.

2. Find the line that looks like this:

layout.fit_into(bbox, keep_aspect_ratio=False)

3. Replace the line with the following:

layout.fit_into(bbox, keep_aspect_ratio=kwds.get("keep_aspect_ratio", False))

Then you can simply say igraph.plot(g, "graph.pdf", layout=layout, 
keep_aspect_ratio=True).

> It also seems that the weights property ("edge weights to be used") wasn't 
> taken into account when I tried it, passing a list with the weight for each 
> layer.
The weights are taken into account only in the cycle-breaking phase: since the 
Sugiyama layout requires a directed acyclic graph, it will temporarily break 
all the cycles by trying to remove a set of edges whose total weight is minimal.

-- 
T.
_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to