Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

four-block-tree.cpp
Go to the documentation of this file.
6 
7 #include <string>
8 
9 using namespace ogdf;
10 
11 int main(void) {
12  Graph g;
13  constexpr int n = 16;
14  randomPlanarConnectedGraph(g, n, 3 * n - 6);
15  const adjEntry externalFace = g.firstNode()->firstAdj()->cyclicSucc();
16 
17  const auto fbt = FourBlockTree::construct(g, externalFace);
18 
19  PlanarStraightLayout layout;
20  {
21  GraphAttributes ga(g,
25  ga.directed() = false;
26  layout.callFixEmbed(ga, externalFace);
27  for (const node v : g.nodes) {
28  ga.label(v) = std::to_string(v->index());
30  }
31  GraphIO::write(ga, "output-g.svg", GraphIO::drawSVG);
32  }
33  int i = 0;
34  fbt->preorder([&](const FourBlockTree& treeNode) -> void {
35  GraphAttributes ga(*treeNode.g,
39  ga.directed() = false;
40  layout.callFixEmbed(ga, treeNode.externalFace);
41  for (const node v : treeNode.g->nodes) {
42  ga.label(v) = std::to_string(treeNode.originalNodes[v]->index());
44  }
45  GraphIO::write(ga, std::string("output-node-") + std::to_string(i++) + ".svg",
47  });
48  return 0;
49 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:66
ogdf::GraphIO::write
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.
ogdf::GraphAttributes::fillColor
const Color & fillColor(node v) const
Returns the fill color of node v.
Definition: GraphAttributes.h:513
ogdf::GraphAttributes::edgeStyle
static const long edgeStyle
Corresponds to edge attributes strokeColor(edge), strokeType(edge), and strokeWidth(edge).
Definition: GraphAttributes.h:143
ogdf::GraphAttributes::nodeStyle
static const long nodeStyle
Corresponds to node attributes strokeColor(node), strokeType(node), strokeWidth(node),...
Definition: GraphAttributes.h:147
ogdf::GraphIO::drawSVG
static bool drawSVG(const GraphAttributes &A, std::ostream &os, const SVGSettings &settings)
ogdf::NodeElement::index
int index() const
Returns the (unique) node index.
Definition: Graph_d.h:267
PlanarStraightLayout.h
Declaration of class PlanarStraightLayout which represents a planar straight-line drawing algorithm.
ogdf::GraphAttributes::directed
bool directed() const
Returns if the graph is directed.
Definition: GraphAttributes.h:226
ogdf::FourBlockTree::g
std::unique_ptr< Graph > g
The 4-connected component.
Definition: FourBlockTree.h:74
ogdf::PlanarGridLayoutModule::callFixEmbed
void callFixEmbed(GraphAttributes &AG, adjEntry adjExternal=nullptr)
Calls the grid layout algorithm with a fixed planar embedding (general call).
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:135
ogdf::Color::Name::White
@ White
randomized.h
Declaration of randomized graph generators.
ogdf::Graph::nodes
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Definition: Graph_d.h:924
ogdf::FourBlockTree::construct
static std::unique_ptr< FourBlockTree > construct(const Graph &g, adjEntry externalFace)
Construct a 4-block tree of the given graph.
ogdf::FourBlockTree::originalNodes
NodeArray< node > originalNodes
The nodes in the original graph corresponding to the nodes in g.
Definition: FourBlockTree.h:82
GraphIO.h
Declares class GraphIO which provides access to all graph read and write functionality.
FourBlockTree.h
Declaration of FourBlockTree.
ogdf::Graph::firstNode
node firstNode() const
Returns the first node in the list of all nodes.
Definition: Graph_d.h:989
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::GraphAttributes::nodeLabel
static const long nodeLabel
Corresponds to node attribute label(node).
Definition: GraphAttributes.h:128
main
int main(void)
Definition: four-block-tree.cpp:11
ogdf::AdjElement::cyclicSucc
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
Definition: Graph_d.h:347
ogdf::FourBlockTree
A node in a 4-block tree.
Definition: FourBlockTree.h:59
ogdf::GraphAttributes::edgeGraphics
static const long edgeGraphics
Corresponds to edge attribute bends(edge).
Definition: GraphAttributes.h:116
ogdf::NodeElement::firstAdj
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition: Graph_d.h:279
ogdf::FourBlockTree::externalFace
adjEntry externalFace
A half-edge in g such that the external face of g is to its right.
Definition: FourBlockTree.h:87
ogdf::PlanarStraightLayout
Implementation of the Planar-Straight layout algorithm.
Definition: PlanarStraightLayout.h:113
ogdf::sync_plan::internal::to_string
std::string to_string(const std::function< std::ostream &(std::ostream &)> &func)
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::GraphAttributes::nodeGraphics
static const long nodeGraphics
Corresponds to node attributes x(node), y(node), width(node), height(node), and shape(node).
Definition: GraphAttributes.h:113
simple_graph_alg.h
Declaration of simple graph algorithms.
ogdf::randomPlanarConnectedGraph
void randomPlanarConnectedGraph(Graph &G, int n, int m)
Creates a random connected (simple) planar (embedded) graph.
ogdf::GraphAttributes::label
const string & label(node v) const
Returns the label of node v.
Definition: GraphAttributes.h:549