Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00041 #ifdef _MSC_VER
00042 #pragma once
00043 #endif
00044
00045 #ifndef _FAST_MULTIPOLE_EMBEDDER_H_
00046 #define _FAST_MULTIPOLE_EMBEDDER_H_
00047
00048 #include <ogdf/basic/Graph.h>
00049 #include <ogdf/module/LayoutModule.h>
00050 #include <ogdf/internal/energybased/MultilevelGraph.h>
00051
00052 namespace ogdf {
00053
00054 class ArrayGraph;
00055 class LinearQuadtree;
00056 class LinearQuadtreeExpansion;
00057 class FMEThreadPool;
00058 class FMEThread;
00059 struct FMEGlobalOptions;
00060 class GalaxyMultilevel;
00061
00062 class OGDF_EXPORT FastMultipoleEmbedder : public LayoutModule
00063 {
00064 public:
00066 FastMultipoleEmbedder();
00067
00069 ~FastMultipoleEmbedder();
00070
00072
00073
00074
00076 void call(const Graph& G, NodeArray<float>& nodeXPosition, NodeArray<float>& nodeYPosition,
00077 const EdgeArray<float>& edgeLength, const NodeArray<float>& nodeSize);
00078
00080 void call(GraphAttributes &GA, const EdgeArray<float>& edgeLength, const NodeArray<float>& nodeSize);
00081
00083 void call(GraphAttributes &GA);
00084
00086 void setNumIterations(__uint32 numIterations) { m_numIterations = numIterations; };
00087
00089 void setMultipolePrec(__uint32 precision) { m_precisionParameter = precision; };
00090
00092 void setRandomize(bool b) { m_randomize = b; };
00093
00095 void setDefaultEdgeLength(float edgeLength) { m_defaultEdgeLength = edgeLength; };
00096
00098 void setDefaultNodeSize(float nodeSize) { m_defaultNodeSize = nodeSize; };
00099
00101 void setNumberOfThreads(__uint32 numThreads) { m_maxNumberOfThreads = numThreads; };
00102
00103
00104 private:
00105 void initOptions();
00106
00107 void runMultipole();
00108
00109 void runSingle();
00110
00112 void run(__uint32 numIterations);
00113
00115 void allocate(__uint32 numNodes, __uint32 numEdges);
00116
00118 void deallocate();
00119
00120 __uint32 m_numIterations;
00121
00122 ArrayGraph* m_pGraph;
00123
00124 FMEThreadPool* m_threadPool;
00125
00126 FMEGlobalOptions* m_pOptions;
00127
00128 __uint32 m_precisionParameter;
00129
00130 bool m_randomize;
00131
00132 float m_defaultEdgeLength;
00133
00134 float m_defaultNodeSize;
00135
00136 __uint32 m_numberOfThreads;
00137
00138 __uint32 m_maxNumberOfThreads;
00139 };
00140
00141
00142 class OGDF_EXPORT FastMultipoleMultilevelEmbedder : public LayoutModule
00143 {
00144 public:
00146 FastMultipoleMultilevelEmbedder() : m_iMaxNumThreads(1) {}
00148 void call(GraphAttributes &GA);
00149
00151 void multilevelUntilNumNodesAreLess(int nodesBound) { m_multiLevelNumNodesBound = nodesBound; };
00152
00153 void maxNumThreads(int numThreads) { m_iMaxNumThreads = numThreads; }
00154 private:
00156 void computeAutoEdgeLength(const GraphAttributes& GA, EdgeArray<float>& edgeLength, float factor = 1.0f);
00157
00159 void run(GraphAttributes& GA, const EdgeArray<float>& edgeLength);
00160
00162 void createMultiLevelGraphs(Graph* pGraph, GraphAttributes& GA, const EdgeArray<float>& edgeLength);
00163
00165 void initFinestLevel(GraphAttributes &GA, const EdgeArray<float>& edgeLength);
00166
00168 void layoutCurrentLevel();
00169
00171 void assignPositionsFromPrevLevel();
00172
00174 void writeCurrentToGraphAttributes(GraphAttributes& GA);
00175
00177 void nextLevel();
00178
00180 void initCurrentLevel();
00181
00183 void deleteMultiLevelGraphs();
00184
00186 void dumpCurrentLevel(const String& filename);
00187
00189 __uint32 numberOfIterationsByLevelNr(__uint32 levelNr);
00190
00191 int m_iMaxNumThreads;
00192 int m_iNumLevels;
00193 int m_multiLevelNumNodesBound;
00194
00195 GalaxyMultilevel* m_pCurrentLevel;
00196 GalaxyMultilevel* m_pFinestLevel;
00197 GalaxyMultilevel* m_pCoarsestLevel;
00198
00199 Graph* m_pCurrentGraph;
00200 NodeArray<float>* m_pCurrentNodeXPos;
00201 NodeArray<float>* m_pCurrentNodeYPos;
00202 EdgeArray<float>* m_pCurrentEdgeLength;
00203 NodeArray<float>* m_pCurrentNodeSize;
00204 NodeArray<float> m_adjustedNodeSize;
00205 int m_iCurrentLevelNr;
00206
00207 Graph* m_pLastGraph;
00208 NodeArray<float>* m_pLastNodeXPos;
00209 NodeArray<float>* m_pLastNodeYPos;
00210 };
00211
00212 }
00213
00214 #endif
00215