Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
four-block-tree.cpp
Go to the documentation of this file.
3#include <ogdf/basic/Graph.h>
9#include <memory>
10#include <string>
11
12using namespace ogdf;
13
14int main(void) {
15 Graph g;
16 constexpr int n = 16;
17 randomPlanarConnectedGraph(g, n, 3 * n - 6);
18 const adjEntry externalFace = g.firstNode()->firstAdj()->cyclicSucc();
19
20 const auto fbt = FourBlockTree::construct(g, externalFace);
21
23 {
24 GraphAttributes ga(g,
28 ga.directed() = false;
29 layout.callFixEmbed(ga, externalFace);
30 for (const node v : g.nodes) {
31 ga.label(v) = std::to_string(v->index());
32 ga.fillColor(v) = Color::Name::White;
33 }
34 GraphIO::write(ga, "output-g.svg", GraphIO::drawSVG);
35 }
36 int i = 0;
37 fbt->preorder([&](const FourBlockTree& treeNode) -> void {
38 GraphAttributes ga(*treeNode.g,
42 ga.directed() = false;
43 layout.callFixEmbed(ga, treeNode.externalFace);
44 for (const node v : treeNode.g->nodes) {
45 ga.label(v) = std::to_string(treeNode.originalNodes[v]->index());
46 ga.fillColor(v) = Color::Name::White;
47 }
48 GraphIO::write(ga, std::string("output-node-") + std::to_string(i++) + ".svg",
50 });
51 return 0;
52}
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.
Definition Graph_d.h:143
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
Definition Graph_d.h:355
Stores additional attributes of a graph (like layout information).
bool directed() const
Returns if the graph is directed.
const string & label(node v) const
Returns the label of node v.
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).
const Color & fillColor(node v) const
Returns the fill color of node v.
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).
Definition Graph_d.h:866
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Definition Graph_d.h:929
node firstNode() const
Returns the first node in the list of all nodes.
Definition Graph_d.h:994
static bool write(const Graph &G, const string &filename, WriterFunc writer=nullptr)
Writes graph G to a file with name filename and infers the format to use from the file's extension.
static bool drawSVG(const GraphAttributes &A, std::ostream &os, const SVGSettings &settings)
Class for the representation of nodes.
Definition Graph_d.h:241
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition Graph_d.h:287
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.
int main(void)
Declaration of basic types for graphics.
void randomPlanarConnectedGraph(Graph &G, int n, int m)
Creates a random connected (simple) planar (embedded) graph.
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.
static std::unique_ptr< FourBlockTree > construct(const Graph &g, adjEntry externalFace)
Construct a 4-block tree of the given graph.
std::unique_ptr< Graph > g
The 4-connected component.