Open
Graph Drawing
Framework

 v. snapshot-2018-03-28
 

Calling Layout Algorithms

Hierarchical layout

using namespace ogdf;
int main()
{
Graph G;
if (!GraphIO::read(GA, G, "unix-history.gml", GraphIO::readGML)) {
std::cerr << "Could not load unix-history.gml" << std::endl;
return 1;
}
ohl->layerDistance(30.0);
ohl->nodeDistance(25.0);
ohl->weightBalancing(0.8);
SL.setLayout(ohl);
SL.call(GA);
GraphIO::write(GA, "output-unix-history-hierarchical.svg", GraphIO::drawSVG);
return 0;
}

Hierarchical layout with predefined layering

using namespace ogdf;
int r[] = {
0, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9, 10, 10, 11, 12, 12,
13, 14, 14, 15, 16, 17, 18, 18, 19, 19, 20, 21, 22, 22,
22, 23, 23, 23, 23, 24, 25, 26, 27, 27, 27, 28, 29, 29,
29, 30, 30, 31, 31, 31, 32, 33, 33, 34, 34, 35, 35, 35,
35, 0, 1, 2, 3, 5, 6, 7, 8, 10, 11, 12, 14, 15, 16, 18,
19, 20, 21, 22, 23, 25, 27, 29, 30, 31, 32, 33, 34, 35, -1
};
int main()
{
Graph G;
if (!GraphIO::read(GA, G, "unix-history-time.gml", GraphIO::readGML)) {
std::cerr << "Could not load unix-history-time.gml" << std::endl;
return 1;
}
NodeArray<int> rank(G);
int i = 0;
for(node v : G.nodes)
rank[v] = r[i++];
SL.arrangeCCs(false);
ohl->layerDistance(30.0);
ohl->nodeDistance(25.0);
ohl->weightBalancing(0.7);
SL.setLayout(ohl);
SL.call(GA, rank);
GraphIO::write(GA, "output-unix-history-hierarchical-ranking.svg", GraphIO::drawSVG);
return 0;
}

Energy-based layout

using namespace ogdf;
int main()
{
Graph G;
if (!GraphIO::read(G, "sierpinski_04.gml")) {
std::cerr << "Could not load sierpinski_04.gml" << std::endl;
return 1;
}
for (node v : G.nodes)
GA.width(v) = GA.height(v) = 10.0;
FMMMLayout fmmm;
fmmm.useHighLevelOptions(true);
fmmm.unitEdgeLength(15.0);
fmmm.newInitialPlacement(true);
fmmm.call(GA);
GraphIO::write(GA, "output-energybased-sierpinski-layout.gml", GraphIO::writeGML);
return 0;
}

Orthogonal layout