Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
HierarchyLayoutModule.h
Go to the documentation of this file.
1
33#pragma once
34
35#include <ogdf/basic/Graph.h>
39#include <ogdf/basic/basic.h>
40#include <ogdf/basic/memory.h>
43
44namespace ogdf {
45
46
53public:
56
58
64 void call(const HierarchyLevelsBase& levels, GraphAttributes& GA) {
65 GraphAttributes AGC(levels.hierarchy());
66
67 // Copy over relevant nodeGraphics attributes that may be used by doCall
68 // or need to be preserved. edgeGraphics' bend points need to be cleared
69 // and are not copied over.
70 if (GA.has(GraphAttributes::nodeGraphics)) {
71 const GraphCopy& GC = dynamic_cast<const GraphCopy&>(AGC.constGraph());
72 for (node vOrig : GA.constGraph().nodes) {
73 node v = GC.copy(vOrig);
74 if (v != nullptr) {
75 AGC.height(v) = GA.height(vOrig);
76 AGC.width(v) = GA.width(vOrig);
77 AGC.shape(v) = GA.shape(vOrig);
78 }
79 }
80 }
81
82 doCall(levels, AGC);
83 AGC.transferToOriginal(GA);
84 }
85
86#if 0
92 void call(Hierarchy& H, GraphAttributes &AG) {
93 GraphAttributes AGC(H);
94 doCall(H,AGC);
95 HierarchyLayoutModule::dynLayerDistance(AGC, H);
96 HierarchyLayoutModule::addBends(AGC, H);
97 AGC.transferToOriginal(AG);
98 }
99
106 void call(const Hierarchy& H, GraphAttributes &, GraphAttributes &AGC) {
107 doCall(H,AGC);
108 }
109
111 static void addBends(GraphAttributes &AGC, HierarchyLevels &levels);
112#endif
113
115
116private:
118 static void overlap(GraphAttributes& AGC, HierarchyLevelsBase& levels, node s, node t, int i,
119 int& ci, int& cj);
120
121protected:
123 static inline double getWidth(const GraphAttributes& GA, const HierarchyLevelsBase& levels,
124 node v) {
125 const GraphCopy& GC = levels.hierarchy();
126 return GC.isDummy(v) ? 0.0 : GA.width(v);
127 }
128
130 static inline double getHeight(const GraphAttributes& GA, const HierarchyLevelsBase& levels,
131 node v) {
132 const GraphCopy& GC = levels.hierarchy();
133 return GC.isDummy(v) ? 0.0 : GA.height(v);
134 }
135
144 virtual void doCall(const HierarchyLevelsBase& levels, GraphAttributes& AGC) = 0;
145
147};
148
149}
Declaration of interfaces used in Sugiyama framework.
Includes declaration of graph class.
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Declaration of graph copy classes.
Decralation of GraphElement and GraphList classes.
Declaration of Hierarchy class.
Basic declarations, included by all source files.
Stores additional attributes of a graph (like layout information).
double height(node v) const
Returns the height of the bounding box of node v.
const Graph & constGraph() const
Returns a reference to the associated graph.
double width(node v) const
Returns the width of the bounding box of node v.
void transferToOriginal(GraphAttributes &origAttr) const
Copies attributes of this to origAttr.
Shape shape(node v) const
Returns the shape type of node v.
bool has(long attr) const
Returns true iff all attributes in attr are available.
bool isDummy(node v) const
Returns true iff v has no corresponding node in the original graph.
Definition GraphCopy.h:172
Copies of graphs supporting edge splitting.
Definition GraphCopy.h:390
edge copy(edge e) const override
Returns the first edge in the list of edges corresponding to edge e.
Definition GraphCopy.h:463
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Definition Graph_d.h:929
Representation of proper hierarchies used by Sugiyama-layout.
Definition Hierarchy.h:47
Interface of hierarchy layout algorithms.
static void overlap(GraphAttributes &AGC, HierarchyLevelsBase &levels, node s, node t, int i, int &ci, int &cj)
after calling, ci (cj) contains the number of nodes of level i (j=i-1) which overlap the edge (s,...
static void dynLayerDistance(GraphAttributes &AGC, HierarchyLevelsBase &levels)
virtual void doCall(const HierarchyLevelsBase &levels, GraphAttributes &AGC)=0
Implements the actual algorithm call.
void call(const HierarchyLevelsBase &levels, GraphAttributes &GA)
Computes a hierarchy layout of levels in GA.
static double getWidth(const GraphAttributes &GA, const HierarchyLevelsBase &levels, node v)
Returns the GA width of node v or 0 if it is a dummy node in the hierarchy of levels.
HierarchyLayoutModule()
Initializes a hierarchy layout module.
static double getHeight(const GraphAttributes &GA, const HierarchyLevelsBase &levels, node v)
Returns the GA height of node v or 0 if it is a dummy node in the hierarchy of levels.
virtual const Hierarchy & hierarchy() const =0
Class for the representation of nodes.
Definition Graph_d.h:241
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
#define OGDF_MALLOC_NEW_DELETE
Makes the class use malloc for memory allocation.
Definition memory.h:92
Declaration of memory manager for allocating small pieces of memory.
The namespace for all OGDF objects.