Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

GridLayout.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Graph.h>
35 #include <ogdf/basic/basic.h>
36 #include <ogdf/basic/geometry.h>
37 #include <ogdf/basic/memory.h>
38 
39 namespace ogdf {
40 class Layout;
41 
48 public:
50  GridLayout() { }
51 
53  explicit GridLayout(const Graph& G) : m_x(G, 0), m_y(G, 0), m_bends(G) { }
54 
56  virtual ~GridLayout() { }
57 
59  const NodeArray<int>& x() const { return m_x; }
60 
62  NodeArray<int>& x() { return m_x; }
63 
65  const NodeArray<int>& y() const { return m_y; }
66 
68  NodeArray<int>& y() { return m_y; }
69 
71  const EdgeArray<IPolyline>& bends() const { return m_bends; }
72 
74  EdgeArray<IPolyline>& bends() { return m_bends; }
75 
77  const int& x(node v) const { return m_x[v]; }
78 
80  int& x(node v) { return m_x[v]; }
81 
83  const int& y(node v) const { return m_y[v]; }
84 
86  int& y(node v) { return m_y[v]; }
87 
89  const IPolyline& bends(edge e) const { return m_bends[e]; }
90 
92  IPolyline& bends(edge e) { return m_bends[e]; }
93 
95  IPolyline polyline(edge e) const;
96 
98  void init(const Graph& G) {
99  m_x.init(G, 0);
100  m_y.init(G, 0);
101  m_bends.init(G);
102  }
103 
105  void init() {
106  m_x.init();
107  m_y.init();
108  m_bends.init();
109  }
110 
112  IPolyline getCompactBends(edge e) const;
113 
115  void compactAllBends();
116 
125  bool checkLayout();
126 
137  void computeBoundingBox(int& xmin, int& xmax, int& ymin, int& ymax);
138 
140  int totalManhattanEdgeLength() const;
141 
142  int maxManhattanEdgeLength() const;
143  int manhattanEdgeLength(edge e) const;
144 
146  double totalEdgeLength() const;
147 
149  int numberOfBends() const;
150 
157  virtual void remap(Layout& drawing);
158 
159  static int manhattanDistance(const IPoint& ip1, const IPoint& ip2);
160  static double euclideanDistance(const IPoint& ip1, const IPoint& ip2);
161 
162 protected:
166 
167 private:
168  static bool isRedundant(IPoint& p1, IPoint& p2, IPoint& p3);
169  static void compact(IPolyline& ip);
170 
172 };
173 
174 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::GridLayout::bends
const IPolyline & bends(edge e) const
Returns a reference to the bend point list of edge e.
Definition: GridLayout.h:89
ogdf::GridLayout::y
int & y(node v)
Returns a reference to the y-coordinate of node v.
Definition: GridLayout.h:86
Graph.h
Includes declaration of graph class.
ogdf::GenericPoint< int >
geometry.h
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
ogdf::GenericPolyline
Polylines with PointType points.
Definition: geometry.h:261
ogdf::GridLayout::y
const NodeArray< int > & y() const
Returns a reference to the array storing the y-coordinates of nodes.
Definition: GridLayout.h:65
ogdf::GridLayout::x
const NodeArray< int > & x() const
Returns a reference to the array storing the x-coordinates of nodes.
Definition: GridLayout.h:59
ogdf::GridLayout::y
const int & y(node v) const
Returns a reference to the y-coordinate of node v.
Definition: GridLayout.h:83
ogdf::GridLayout::~GridLayout
virtual ~GridLayout()
Destruction.
Definition: GridLayout.h:56
ogdf::GridLayout::bends
EdgeArray< IPolyline > & bends()
Returns a reference to the array storing the bend points of edges.
Definition: GridLayout.h:74
ogdf::Layout
Stores a layout of a graph (coordinates of nodes, bend points of edges).
Definition: Layout.h:49
OGDF_MALLOC_NEW_DELETE
#define OGDF_MALLOC_NEW_DELETE
Makes the class use malloc for memory allocation.
Definition: memory.h:92
ogdf::GridLayout::bends
const EdgeArray< IPolyline > & bends() const
Returns a reference to the array storing the bend points of edges.
Definition: GridLayout.h:71
ogdf::GridLayout::bends
IPolyline & bends(edge e)
Returns a reference to the bend point list of edge e.
Definition: GridLayout.h:92
ogdf::GridLayout::GridLayout
GridLayout(const Graph &G)
Creates an instance of a grid layout associated with G.
Definition: GridLayout.h:53
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::GridLayout::init
void init(const Graph &G)
Initializes the grid layout for graph G.
Definition: GridLayout.h:98
ogdf::GridLayout::y
NodeArray< int > & y()
Returns a reference to the array storing the y-coordinates of nodes.
Definition: GridLayout.h:68
ogdf::GridLayout::x
NodeArray< int > & x()
Returns a reference to the array storing the x-coordinates of nodes.
Definition: GridLayout.h:62
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::GridLayout::x
const int & x(node v) const
Returns a reference to the x-coordinate of node v.
Definition: GridLayout.h:77
ogdf::GridLayout::m_x
NodeArray< int > m_x
The x-coordinates of nodes.
Definition: GridLayout.h:163
ogdf::GridLayout::x
int & x(node v)
Returns a reference to the x-coordinate of node v.
Definition: GridLayout.h:80
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:363
ogdf::GridLayout
Representation of a graph's grid layout.
Definition: GridLayout.h:47
ogdf::GridLayout::init
void init()
Initializes the grid layout for no graph (frees memory).
Definition: GridLayout.h:105
ogdf::GridLayout::GridLayout
GridLayout()
Creates an instance of a grid layout (associated with no graph).
Definition: GridLayout.h:50
ogdf::GridLayout::m_y
NodeArray< int > m_y
The y-coordinates of nodes.
Definition: GridLayout.h:164
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::GridLayout::m_bends
EdgeArray< IPolyline > m_bends
The bend points of edges.
Definition: GridLayout.h:165
memory.h
Declaration of memory manager for allocating small pieces of memory.
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716