Dear Małgorzata,
the PlanarStraightLayout
seems to work:
#include <ogdf/basic/graph_generators.h>
#include <ogdf/fileformats/GraphIO.h>
#include <ogdf/planarlayout/PlanarStraightLayout.h>
#include <ogdf/planarity/EmbedderMinDepthMaxFace.h>
using namespace ogdf;
int main()
{
Graph G;
randomPlanarBiconnectedGraph(G, 14, 20, false);
GraphAttributes GA(G,
GraphAttributes::nodeGraphics |
GraphAttributes::edgeGraphics);
for (node v : G.nodes) {
GA.width(v) = 5;
GA.height(v) = 5;
}
PlanarStraightLayout pl;
EmbedderMinDepthMaxFace *emb = new EmbedderMinDepthMaxFace;
pl.setEmbedder(emb);
pl.call(GA);
GraphIO::write(GA, "output.svg", GraphIO::drawSVG);
return 0;
}
Best regards,
Dagobert
I investigated this and it is indeed a bug, one that has been introduced in February 2017.
Moreover, I have an idea for a fix. In /include/ogdf/planarity/embedder/EmbedderBCTreeBase.h
we have the following line 57:
EdgeArray<int> m_edgeLength(G, 0);
but it should actually be
EdgeArray<int> m_edgeLength(G, 1);
This might potentially break EmbedderMinDepth
(I'm not sure about that yet) but for all other Embedders it might work fine. For the next release, we will take a closer at this but the fix might help you already.
Best regards,
Dagobert
Yes, the algorithm also embeds the augmenting edges.
Does it make sense to first embed the graph and only then augment it? Is there a way to do it?
The PlanarGridLayoutModule
s promise that they are able to what you want via callFixEmbed()
:
Graph G;
randomPlanarConnectedGraph(G, 20, 30);
GraphAttributes GA(G, GraphAttributes::all);
PlanarStraightLayout pl;
EmbedderMaxFace *emb = new EmbedderMaxFace;
adjEntry adjE;
emb->call(G, adjE);
pl.callFixEmbed(GA, adjE);
This, however, does not seem to work because the internally used PlanarAugmentationFix
–which augments a graph while keeping the embedding–appears to be broken.
One could try to use a PlanarAugmentation
instead of PlanarAugmentationFix
(line 80 in PlanarStraightLayout.cpp
), but since the PlanarAugmentation
may not keep the original embedding, this will also break in many cases. Hence, I unfortunately can’t help you with this right now.
Best regards,
Dagobert