This example shows how to generate a random plane triangulation, decompose it into its 4-connected components, and draw each of them from the outside in.
#include <memory>
#include <string>
constexpr int n = 16;
randomPlanarConnectedGraph(g, n, 3 * n - 6);
const auto fbt = FourBlockTree::construct(g, externalFace);
{
ga.directed() = false;
for (
const node v : g.nodes) {
ga.label(v) = std::to_string(v->index());
ga.fillColor(v) = Color::Name::White;
}
GraphIO::write(ga, "output-g.svg", GraphIO::drawSVG);
}
int i = 0;
ga.directed() = false;
for (
const node v : treeNode.g->nodes) {
ga.label(v) = std::to_string(treeNode.
originalNodes[v]->index());
ga.fillColor(v) = Color::Name::White;
}
GraphIO::write(ga, std::string("output-node-") + std::to_string(i++) + ".svg",
GraphIO::drawSVG);
});
return 0;
}
Declaration of FourBlockTree.
Includes declaration of graph class.
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Declares class GraphIO which provides access to all graph read and write functionality.
Decralation of GraphElement and GraphList classes.
Declaration of class PlanarStraightLayout which represents a planar straight-line drawing algorithm.
Class for adjacency list elements.
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
Stores additional attributes of a graph (like layout information).
static const long edgeStyle
Corresponds to edge attributes strokeColor(edge), strokeType(edge), and strokeWidth(edge).
static const long nodeLabel
Corresponds to node attribute label(node).
static const long nodeStyle
Corresponds to node attributes strokeColor(node), strokeType(node), strokeWidth(node),...
static const long edgeGraphics
Corresponds to edge attribute bends(edge).
static const long nodeGraphics
Corresponds to node attributes x(node), y(node), width(node), height(node), and shape(node).
Data type for general directed graphs (adjacency list representation).
node firstNode() const
Returns the first node in the list of all nodes.
Class for the representation of nodes.
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
void callFixEmbed(GraphAttributes &AG, adjEntry adjExternal=nullptr)
Calls the grid layout algorithm with a fixed planar embedding (general call).
Implementation of the Planar-Straight layout algorithm.
Declaration of basic types for graphics.
The namespace for all OGDF objects.
Declaration of randomized graph generators.
A node in a 4-block tree.
NodeArray< node > originalNodes
The nodes in the original graph corresponding to the nodes in g.
adjEntry externalFace
A half-edge in g such that the external face of g is to its right.
std::unique_ptr< Graph > g
The 4-connected component.