Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

BalloonLayout.h
Go to the documentation of this file.
1 
37 /*
38  * The layout is computed by first computing a spanning tree
39  * of the graph that is then used to derive the vertices' coordinates.
40  * First, the radii at each vertex are computed.
41  * Then, depending on the embedding option, the order of the
42  * edges around each vertex is optimized to maximize angular
43  * resolution and to minimize the aspect ratio.
44  *
45  * Finally, the layout is shifted into the positive quadrant
46  * of the cartesian plane
47  * */
48 
49 #pragma once
50 
51 #include <ogdf/basic/Graph.h>
53 #include <ogdf/basic/basic.h>
54 #include <ogdf/basic/memory.h>
55 
56 #include <iosfwd>
57 
58 namespace ogdf {
59 class GraphAttributes;
60 template<class E>
61 class List;
62 
64 public:
65  //Root may be defined by center of the graph
66  //Directed cases: source/sink
67  enum class RootSelection { Center, HighestDegree };
68  //either keep the given embedding or optimize
69  //the order wrto angular resolution and minimum aspect ratio
70  enum class ChildOrder { Fixed, Optimized };
71  //compute tree by different methods
72  enum class TreeComputation { Bfs, Dfs, BfsRandom };
74  BalloonLayout();
76  BalloonLayout& operator=(const BalloonLayout& bl);
77 
79  virtual void call(GraphAttributes& AG) override;
80 
84  virtual void callFractal(GraphAttributes& AG, double ratio = 0.3) {
85  bool even = getEvenAngles();
86  setEvenAngles(true);
87  call(AG);
88  setEvenAngles(even);
89  }
90 
92  void setEvenAngles(bool b) { m_evenAngles = b; }
93 
95  bool getEvenAngles() { return m_evenAngles; }
96 
97 protected:
101  void computeTree(const Graph& G);
102 
104  void computeBFSTree(const Graph& G, node v);
105 
108  void selectRoot(const Graph& G);
109 
115 #ifdef OGDF_DEBUG
116  void computeRadii(GraphAttributes& AG);
117 #else
118  void computeRadii(const GraphAttributes& AG);
119 #endif
120 
122  void computeAngles(const Graph& G);
123 
125  void computeCoordinates(GraphAttributes& AG);
126 
127 private:
136 
138 #ifdef OGDF_DEBUG
139  void checkTree(const Graph& G, bool treeRoot = true);
142 #endif
143 
147 
149 
153 
154  void check(Graph& G);
155 
157 };
158 
159 OGDF_EXPORT std::ostream& operator<<(std::ostream& os, const BalloonLayout::RootSelection& rs);
160 
161 }
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
Graph.h
Includes declaration of graph class.
ogdf::BalloonLayout::m_angle
NodeArray< double > m_angle
Angle assigned to nodes.
Definition: BalloonLayout.h:133
ogdf::BalloonLayout::m_parent
NodeArray< node > m_parent
Parent in spanning tree.
Definition: BalloonLayout.h:131
ogdf::BalloonLayout::ChildOrder
ChildOrder
Definition: BalloonLayout.h:70
ogdf::BalloonLayout
Definition: BalloonLayout.h:63
ogdf::BalloonLayout::m_childList
NodeArray< List< node > > m_childList
Definition: BalloonLayout.h:137
LayoutModule.h
Declaration of interface for layout algorithms (class LayoutModule)
ogdf::BalloonLayout::m_childOrder
ChildOrder m_childOrder
How to arrange the children.
Definition: BalloonLayout.h:150
ogdf::BalloonLayout::m_treeRoot
node m_treeRoot
Root of tree after computation.
Definition: BalloonLayout.h:145
ogdf::BalloonLayout::m_oRadius
NodeArray< double > m_oRadius
Radius at node center.
Definition: BalloonLayout.h:129
ogdf::BalloonLayout::m_size
NodeArray< double > m_size
Radius of circle around node box.
Definition: BalloonLayout.h:135
ogdf::BalloonLayout::m_root
node m_root
Root of tree by selection method.
Definition: BalloonLayout.h:146
OGDF_NEW_DELETE
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition: memory.h:85
ogdf::BalloonLayout::m_radius
NodeArray< double > m_radius
Definition: BalloonLayout.h:128
ogdf::BalloonLayout::setEvenAngles
void setEvenAngles(bool b)
Subtrees may be assigned even angles or angles depending on their size.
Definition: BalloonLayout.h:92
ogdf::BalloonLayout::RootSelection
RootSelection
Definition: BalloonLayout.h:67
ogdf::BoyerMyrvoldEdgeType::Dfs
@ Dfs
DFS-edge.
ogdf::BalloonLayout::m_treeComputation
TreeComputation m_treeComputation
How to derive the spanning tree.
Definition: BalloonLayout.h:151
ogdf::BalloonLayout::m_estimateFactor
double m_estimateFactor
Weight of value (largestchild / number of children) added to estimate to compute radius.
Definition: BalloonLayout.h:148
ogdf::operator<<
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition: Array.h:983
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::BalloonLayout::m_maxChildRadius
NodeArray< double > m_maxChildRadius
Outer radius of largest child.
Definition: BalloonLayout.h:130
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::BalloonLayout::TreeComputation
TreeComputation
Definition: BalloonLayout.h:72
ogdf::BalloonLayout::m_rootSelection
RootSelection m_rootSelection
Defines how the tree root is selected.
Definition: BalloonLayout.h:144
basic.h
Basic declarations, included by all source files.
ogdf::BalloonLayout::m_treeEdge
EdgeArray< bool > m_treeEdge
Holds info about tree edges.
Definition: BalloonLayout.h:141
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::BalloonLayout::m_evenAngles
bool m_evenAngles
Definition: BalloonLayout.h:152
ogdf::BalloonLayout::getEvenAngles
bool getEvenAngles()
returns how the angles are assigned to subtrees.
Definition: BalloonLayout.h:95
ogdf::BalloonLayout::m_estimate
NodeArray< double > m_estimate
Rough estimate of circumference of subtrees.
Definition: BalloonLayout.h:134
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
memory.h
Declaration of memory manager for allocating small pieces of memory.
ogdf::BalloonLayout::callFractal
virtual void callFractal(GraphAttributes &AG, double ratio=0.3)
Call using special parameter settings for fractal model takes radius ratio < 0.5 as parameter.
Definition: BalloonLayout.h:84
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716
ogdf::LayoutModule
Interface of general layout algorithms.
Definition: LayoutModule.h:45
ogdf::BalloonLayout::m_childCount
NodeArray< int > m_childCount
Number of children in spanning tree.
Definition: BalloonLayout.h:132