Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

HierarchyLayoutModule.h
Go to the documentation of this file.
1 
33 #pragma once
34 
35 #include <ogdf/basic/Graph.h>
37 #include <ogdf/basic/GraphCopy.h>
38 #include <ogdf/basic/GraphList.h>
39 #include <ogdf/basic/basic.h>
40 #include <ogdf/basic/memory.h>
42 #include <ogdf/layered/Hierarchy.h>
43 
44 namespace ogdf {
45 
46 
53 public:
56 
57  virtual ~HierarchyLayoutModule() { }
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.
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
87 
92  void call(Hierarchy& H, GraphAttributes &AG) {
93  GraphAttributes AGC(H);
94  doCall(H,AGC);
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 
114  static void dynLayerDistance(GraphAttributes& AGC, HierarchyLevelsBase& levels);
115 
116 private:
118  static void overlap(GraphAttributes& AGC, HierarchyLevelsBase& levels, node s, node t, int i,
119  int& ci, int& cj);
120 
121 protected:
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 }
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.
ogdf::HierarchyLayoutModule::call
void call(const HierarchyLevelsBase &levels, GraphAttributes &GA)
Computes a hierarchy layout of levels in GA.
Definition: HierarchyLayoutModule.h:64
ogdf::HierarchyLayoutModule::getHeight
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.
Definition: HierarchyLayoutModule.h:130
ogdf::HierarchyLayoutModule
Interface of hierarchy layout algorithms.
Definition: HierarchyLayoutModule.h:52
ogdf::HierarchyLayoutModule::dynLayerDistance
static void dynLayerDistance(GraphAttributes &AGC, HierarchyLevelsBase &levels)
ogdf::GraphCopyBase::isDummy
bool isDummy(node v) const
Returns true iff v has no corresponding node in the original graph.
Definition: GraphCopy.h:173
ogdf::GraphCopy
Copies of graphs supporting edge splitting.
Definition: GraphCopy.h:391
ogdf::Hierarchy
Representation of proper hierarchies used by Sugiyama-layout.
Definition: Hierarchy.h:47
ogdf::HierarchyLevelsBase
Definition: CrossingMinInterfaces.h:63
ogdf::GraphAttributes::constGraph
const Graph & constGraph() const
Returns a reference to the associated graph.
Definition: GraphAttributes.h:223
ogdf::GraphAttributes::shape
Shape shape(node v) const
Returns the shape type of node v.
Definition: GraphAttributes.h:429
ogdf::Graph::nodes
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Definition: Graph_d.h:932
OGDF_MALLOC_NEW_DELETE
#define OGDF_MALLOC_NEW_DELETE
Makes the class use malloc for memory allocation.
Definition: memory.h:92
GraphList.h
Decralation of GraphElement and GraphList classes.
ogdf::node
NodeElement * node
The type of nodes.
Definition: Graph_d.h:70
GraphCopy.h
Declaration of graph copy classes.
ogdf::GraphAttributes::height
double height(node v) const
Returns the height of the bounding box of node v.
Definition: GraphAttributes.h:393
ogdf::GraphAttributes::transferToOriginal
void transferToOriginal(GraphAttributes &origAttr) const
Copies attributes of this to origAttr.
ogdf::HierarchyLayoutModule::~HierarchyLayoutModule
virtual ~HierarchyLayoutModule()
Definition: HierarchyLayoutModule.h:57
ogdf::HierarchyLayoutModule::HierarchyLayoutModule
HierarchyLayoutModule()
Initializes a hierarchy layout module.
Definition: HierarchyLayoutModule.h:55
ogdf::GraphCopy::copy
edge copy(edge e) const override
Returns the first edge in the list of edges corresponding to edge e.
Definition: GraphCopy.h:464
CrossingMinInterfaces.h
Declaration of interfaces used in Sugiyama framework.
basic.h
Basic declarations, included by all source files.
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::HierarchyLayoutModule::getWidth
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.
Definition: HierarchyLayoutModule.h:123
Hierarchy.h
Declaration of Hierarchy class.
ogdf::HierarchyLevelsBase::hierarchy
virtual const Hierarchy & hierarchy() const =0
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::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::GraphAttributes::has
bool has(long attr) const
Returns true iff all attributes in attr are available.
Definition: GraphAttributes.h:200
ogdf::GraphAttributes::width
double width(node v) const
Returns the width of the bounding box of node v.
Definition: GraphAttributes.h:357