Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

four-block-tree.cpp
Go to the documentation of this file.
2 #include <ogdf/basic/GraphList.h>
3 #include <ogdf/basic/Graph.h>
5 #include <ogdf/basic/graphics.h>
9 #include <memory>
10 #include <string>
11 
12 using namespace ogdf;
13 
14 int 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 
22  PlanarStraightLayout layout;
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());
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());
47  }
48  GraphIO::write(ga, std::string("output-node-") + std::to_string(i++) + ".svg",
50  });
51  return 0;
52 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:72
GraphAttributes.h
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Graph.h
Includes declaration of graph class.
graphics.h
Declaration of basic types for graphics.
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:519
ogdf::GraphAttributes::edgeStyle
static const long edgeStyle
Corresponds to edge attributes strokeColor(edge), strokeType(edge), and strokeWidth(edge).
Definition: GraphAttributes.h:149
ogdf::GraphAttributes::nodeStyle
static const long nodeStyle
Corresponds to node attributes strokeColor(node), strokeType(node), strokeWidth(node),...
Definition: GraphAttributes.h:153
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:274
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:232
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:142
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:932
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
GraphList.h
Decralation of GraphElement and GraphList classes.
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:997
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::GraphAttributes::nodeLabel
static const long nodeLabel
Corresponds to node attribute label(node).
Definition: GraphAttributes.h:134
main
int main(void)
Definition: four-block-tree.cpp:14
ogdf::AdjElement::cyclicSucc
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
Definition: Graph_d.h:354
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:122
ogdf::NodeElement::firstAdj
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition: Graph_d.h:286
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:117
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:240
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:119
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:555