Loading [MathJax]/extensions/tex2jax.js

Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
ArrayGraph.h
Go to the documentation of this file.
1
32#pragma once
33
36
37namespace ogdf {
38namespace fast_multipole_embedder {
39
41public:
44
47
49 ArrayGraph(const GraphAttributes& GA, const EdgeArray<float>& edgeLength,
51
54
56 inline uint32_t numNodes() const { return m_numNodes; }
57
59 inline uint32_t numEdges() const { return m_numEdges; }
60
62
68 void readFrom(const GraphAttributes& GA, const EdgeArray<float>& edgeLength,
70
72
83 template<typename CoordinateType, typename LengthType, typename SizeType>
85 const EdgeArray<LengthType>& edgeLength, const NodeArray<SizeType>& nodeSize) {
86 m_numNodes = 0;
87 m_numEdges = 0;
89 m_numNodes = 0;
90 m_numEdges = 0;
92 m_avgNodeSize = 0;
93 for (node v : G.nodes) {
99 m_numNodes++;
100 }
102
103 for (edge e : G.edges) {
104 pushBackEdge(nodeIndex[e->source()], nodeIndex[e->target()], (float)edgeLength[e]);
105 }
107 }
108
110
116
118
127 template<typename CoordinateType>
129 uint32_t i = 0;
130 for (node v : G.nodes) {
131 xPos[v] = m_nodeXPos[i];
132 yPos[v] = m_nodeYPos[i];
133 i++;
134 }
135 }
136
138 inline NodeAdjInfo& nodeInfo(uint32_t i) { return m_nodeAdj[i]; }
139
141 inline const NodeAdjInfo& nodeInfo(uint32_t i) const { return m_nodeAdj[i]; }
142
144 inline EdgeAdjInfo& edgeInfo(uint32_t i) { return m_edgeAdj[i]; }
145
147 inline const EdgeAdjInfo& edgeInfo(uint32_t i) const { return m_edgeAdj[i]; }
148
150 inline NodeAdjInfo* nodeInfo() { return m_nodeAdj; }
151
153 inline const NodeAdjInfo* nodeInfo() const { return m_nodeAdj; }
154
156 inline EdgeAdjInfo* edgeInfo() { return m_edgeAdj; }
157
159 inline const EdgeAdjInfo* edgeInfo() const { return m_edgeAdj; }
160
162 inline float* nodeXPos() { return m_nodeXPos; }
163
165 inline const float* nodeXPos() const { return m_nodeXPos; }
166
168 inline float* nodeYPos() { return m_nodeYPos; }
169
171 inline const float* nodeYPos() const { return m_nodeYPos; }
172
174 inline float* nodeSize() { return m_nodeSize; }
175
177 inline const float* nodeSize() const { return m_nodeSize; }
178
180 inline float* nodeMoveRadius() { return m_nodeMoveRadius; }
181
183 inline float* desiredEdgeLength() { return m_desiredEdgeLength; }
184
186 inline const float* desiredEdgeLength() const { return m_desiredEdgeLength; }
187
192
197
202
204 void for_all_nodes(uint32_t begin, uint32_t end, std::function<void(uint32_t)> func) {
205 for (uint32_t i = begin; i <= end; i++) {
206 func(i);
207 }
208 }
209
211 inline float avgDesiredEdgeLength() const { return (float)m_desiredAvgEdgeLength; }
212
214 inline float avgNodeSize() const { return (float)m_avgNodeSize; }
215
217 void transform(float translate, float scale);
218
221
222private:
225
228
231
233 void clear() {
234 for (uint32_t i = 0; i < m_numNodes; i++) {
235 nodeInfo(i).degree = 0;
236 }
237
238 m_numNodes = 0;
239 m_numEdges = 0;
240 }
241
244
245 float* m_nodeXPos;
246 float* m_nodeYPos;
247
248 float* m_nodeSize;
250
252
255
258};
259
260}
261}
Datastructures for edge chains itself and the edge chains of nodes.
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Dynamic arrays indexed with edges.
Definition EdgeArray.h:125
Class for the representation of edges.
Definition Graph_d.h:300
Stores additional attributes of a graph (like layout information).
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
Class for the representation of nodes.
Definition Graph_d.h:177
uint32_t twinNodeIndex(uint32_t currEdgeAdjIndex, uint32_t nodeIndex) const
Returns the other node (not nodeIndex) of the pair with index currEdgeAdjIndex.
Definition ArrayGraph.h:199
const float * nodeSize() const
Returns the node size array for all nodes.
Definition ArrayGraph.h:177
float * m_nodeYPos
The y coordinates.
Definition ArrayGraph.h:246
float * nodeMoveRadius()
Returns the node movement radius array for all nodes.
Definition ArrayGraph.h:180
float * nodeXPos()
Returns the x coord array for all nodes.
Definition ArrayGraph.h:162
uint32_t numEdges() const
Returns the number of edges.
Definition ArrayGraph.h:59
void writeTo(const Graph &G, NodeArray< CoordinateType > &xPos, NodeArray< CoordinateType > &yPos)
Store the data back to NodeArray arrays with the given coordinate type.
Definition ArrayGraph.h:128
~ArrayGraph()
Destructor. Deallocates the memory via OGDF_FREE_16 if needed.
EdgeAdjInfo & edgeInfo(uint32_t i)
Returns the adjacency information for the edge at index i in m_edgeAdj.
Definition ArrayGraph.h:144
void transform(float translate, float scale)
Transforms all positions via shifting them by translate and afterwards scaling by scale.
float * nodeYPos()
Returns the y coord array for all nodes.
Definition ArrayGraph.h:168
void writeTo(GraphAttributes &GA)
Store the data back in GraphAttributes.
void for_all_nodes(uint32_t begin, uint32_t end, std::function< void(uint32_t)> func)
Calls func on all nodes with indices from begin to end.
Definition ArrayGraph.h:204
void allocate(uint32_t numNodes, uint32_t numEdges)
Allocate all arrays.
uint32_t m_numEdges
Number of edges in the graph.
Definition ArrayGraph.h:243
NodeAdjInfo * m_nodeAdj
Information about adjacent edges.
Definition ArrayGraph.h:256
ArrayGraph()
Constructor. Does not allocate memory for the members.
const float * desiredEdgeLength() const
Returns the edge length array for all edges.
Definition ArrayGraph.h:186
const float * nodeYPos() const
Returns the y coord array for all nodes.
Definition ArrayGraph.h:171
const float * nodeXPos() const
Returns the x coord array for all nodes.
Definition ArrayGraph.h:165
NodeAdjInfo & nodeInfo(uint32_t i)
Returns the adjacency information for the node at index i in m_nodeAdj.
Definition ArrayGraph.h:138
EdgeAdjInfo * edgeInfo()
Returns the EdgeAdjInfo array for all edges.
Definition ArrayGraph.h:156
float * nodeSize()
Returns the node size array for all nodes.
Definition ArrayGraph.h:174
const NodeAdjInfo * nodeInfo() const
Returns the NodeAdjInfo array for all nodes.
Definition ArrayGraph.h:153
void centerGraph()
Transforming all positions such that the new center is at (0,0).
NodeAdjInfo * nodeInfo()
Returns the NodeAdjInfo array for all nodes.
Definition ArrayGraph.h:150
uint32_t m_numNodes
Number of nodes in the graph.
Definition ArrayGraph.h:242
void readFrom(const GraphAttributes &GA, const EdgeArray< float > &edgeLength, const NodeArray< float > &nodeSize)
Updates an ArrayGraph from GraphAttributes with the given edge lengths and node sizes and creates the...
void readFrom(const Graph &G, NodeArray< CoordinateType > &xPos, NodeArray< CoordinateType > &yPos, const EdgeArray< LengthType > &edgeLength, const NodeArray< SizeType > &nodeSize)
Updates an ArrayGraph with the given positions, edge lengths and node sizes and creates the edges.
Definition ArrayGraph.h:84
const NodeAdjInfo & nodeInfo(uint32_t i) const
Returns the adjacency information for the node at index i in m_nodeAdj.
Definition ArrayGraph.h:141
uint32_t numNodes() const
Returns the number of nodes.
Definition ArrayGraph.h:56
const EdgeAdjInfo & edgeInfo(uint32_t i) const
Returns the adjacency information for the edge at index i in m_edgeAdj.
Definition ArrayGraph.h:147
ArrayGraph(const GraphAttributes &GA, const EdgeArray< float > &edgeLength, const NodeArray< float > &nodeSize)
Constructor.
float * desiredEdgeLength()
Returns the edge length array for all edges.
Definition ArrayGraph.h:183
float avgDesiredEdgeLength() const
Average edge length.
Definition ArrayGraph.h:211
uint32_t nextEdgeAdjIndex(uint32_t currEdgeAdjIndex, uint32_t nodeIndex) const
Returns the index of the next pair of currEdgeAdjIndex of the node with index nodeIndex.
Definition ArrayGraph.h:194
float * m_nodeXPos
The x coordinates.
Definition ArrayGraph.h:245
float avgNodeSize() const
Average node size.
Definition ArrayGraph.h:214
void deallocate()
Deallocate all arrays.
const EdgeAdjInfo * edgeInfo() const
Returns the EdgeAdjInfo array for all edges.
Definition ArrayGraph.h:159
float * m_nodeMoveRadius
Maximum node movement lengths.
Definition ArrayGraph.h:251
void pushBackEdge(uint32_t a, uint32_t b, float desiredEdgeLength)
Internal function used by readFrom.
float * m_nodeSize
Sizes of the nodes.
Definition ArrayGraph.h:248
ArrayGraph(uint32_t maxNumNodes, uint32_t maxNumEdges)
Constructor. Allocates memory via OGDF_MALLOC_16.
uint32_t firstEdgeAdjIndex(uint32_t nodeIndex) const
Returns the index of the first pair of the node with index nodeIndex in m_nodeAdj.
Definition ArrayGraph.h:189
EdgeAdjInfo * m_edgeAdj
Information about adjacent nodes.
Definition ArrayGraph.h:257
Information about an edge (16 bytes).
Definition EdgeChain.h:52
uint32_t nextEdgeAdjIndex(uint32_t index) const
Returns the index of the next pair of index.
Definition EdgeChain.h:66
uint32_t twinNode(uint32_t index) const
Returns the other node (not index).
Definition EdgeChain.h:60
Information about incident edges (16 bytes).
Definition EdgeChain.h:43
uint32_t firstEntry
The first pair in the edges chain.
Definition EdgeChain.h:46
uint32_t degree
Total count of pairs where is either the first or second node.
Definition EdgeChain.h:45
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.