 # OpenGraph DrawingFramework

v. snapshot-2018-03-28

Basic Functionality

# Generate an acyclic random graph

This example shows how to generate a random graph, make it acyclic by removing edges, and then store it as a GML file.

using namespace ogdf;
int main()
{
randomSimpleGraph(G, 10, 20);
GraphIO::write(G, "output-acyclic-graph.gml", GraphIO::writeGML);
return 0;
}

### Step-by-step explanation

1. We first have to include all header files declaring the classes and functions we want to use. OGDF's header files are contained in subdirectories of a common include directory ogdf. Here we use the class ogdf::Graph, a graph generator function ogdf::randomSimpleGraph(), an algorithm for making a digraph acyclic (ogdf::DfsAcyclicSubgraph), and functionality for exporting graphs provided by ogdf::GraphIO.
2. ttt

# Manual creation and layout of graphs

using namespace ogdf;
int main()
{
Graph G;
const int LEN = 11;
for(int i = 1; i < LEN; ++i) {
node left = G.newNode();
GA.x(left) = -5*(i+1);
GA.y(left) = -20*i;
GA.width(left) = 10*(i+1);
GA.height(left) = 15;
node bottom = G.newNode();
GA.x(bottom) = 20*(LEN-i);
GA.y(bottom) = 5*(LEN+1-i);
GA.width(bottom) = 15;
GA.height(bottom) = 10*(LEN+1-i);
edge e = G.newEdge(left,bottom);
DPolyline &p = GA.bends(e);
p.pushBack(DPoint(10,-20*i));
p.pushBack(DPoint(20*(LEN-i),-10));
}
GraphIO::write(GA, "output-manual.gml", GraphIO::writeGML);
GraphIO::write(GA, "output-manual.svg", GraphIO::drawSVG);
return 0;
}