37 namespace fast_multipole_embedder {
53 #ifdef OGDF_FME_KERNEL_USE_SSE 54 std::cout <<
"OGDF_FME_KERNEL_USE_SSE" << std::endl;
56 #ifdef OGDF_FME_THREAD_AFFINITY 57 std::cout <<
"OGDF_FME_THREAD_AFFINITY" << std::endl;
59 #ifdef OGDF_FME_PARALLEL_QUADTREE_SORT 60 std::cout <<
"OGDF_FME_PARALLEL_QUADTREE_SORT" << std::endl;
62 #ifdef OGDF_FME_KERNEL_USE_SSE_DIRECT 63 std::cout <<
"OGDF_FME_KERNEL_USE_SSE_DIRECT" << std::endl;
67 #ifdef OGDF_FME_KERNEL_USE_SSE 68 #include <emmintrin.h> 69 #include <pmmintrin.h> 78 return !(((size_t)(
void*)ptr) & 0x0F);
84 return (T*)(((size_t)((
void*)t))&~ 0x0F);
90 return (T*)((((size_t)((
void*)t)) + 15)&~ 0x0F);
93 #ifdef OGDF_SYSTEM_UNIX 95 inline timeval GetDiffTime(timeval _then,
double& dtime)
97 timeval then = (timeval) _then;
99 gettimeofday(&now,
nullptr);
102 diff.tv_sec = now.tv_sec - then.tv_sec;
103 diff.tv_usec = now.tv_usec - then.tv_usec;
104 while(diff.tv_usec < 0)
107 diff.tv_usec = 1000000 + now.tv_usec - then.tv_usec;
110 dtime = (double) diff.tv_sec;
111 dtime += (
double) diff.tv_usec / 1e6;
113 return (timeval) now;
117 inline void printProfiledTime(
double t,
const char* text) { std::cout << t <<
"s\t" << text << std::endl; }
118 inline void printProfiledTime(
double t,
double sum,
const char* text) { std::cout << t <<
"s\t" << text <<
"\t" << (t / sum)*100.0 <<
"%"<< std::endl; }
121 #define OGDF_MALLOC_16(s) System::alignedMemoryAlloc16((s)) 124 #define OGDF_FREE_16(ptr) System::alignedMemoryFree((ptr)) 127 template<
typename MNR_T,
typename C_T>
133 const unsigned int BIT_LENGTH =
static_cast<unsigned int>(
sizeof(MNR_T)) << 3;
138 for (
unsigned int i = (BIT_LENGTH >> 1);i>0; i = i >> 1) {
140 mask = mask ^ (mask << i);
141 x = (x | (x << i)) & mask;
142 y = (y | (y << i)) & mask;
149 template<
typename MNR_T,
typename C_T>
153 unsigned int BIT_LENGTH =
static_cast<unsigned int>(
sizeof(C_T)) << 3;
158 for (
unsigned int i=0; i < BIT_LENGTH; i++)
160 x = (C_T)(x | (mnr & mask));
162 y = (C_T)(y | (mnr & mask));
171 uint32_t BIT_LENGTH =
static_cast<uint32_t
>(
sizeof(T)) << 3;
173 mask = mask << (BIT_LENGTH - 1);
174 for (uint32_t i = 0; i < BIT_LENGTH; i++)
187 return 0x1 << (msb - 1);
267 for (
int j=1; j<m; j++)
270 G.
newEdge(topRow[j-1], topRow[j]);
272 for (
int i=1; i<n; i++)
277 for (
int j=1; j<m; j++)
291 int numberOfNodesToDelete = (int)((
double)G.
numberOfNodes() * missinNodesPercentage);
294 for(
int i=0; i<numberOfNodesToDelete;i++)
307 explicit BinCoeff(
unsigned int n) : m_max_n(n) { init_array(); }
316 m_binCoeffs =
new ptr[m_max_n+1];
317 for(i = 0;i<= m_max_n ;i++)
319 m_binCoeffs[i]=
new TYP[i+1];
323 for (i = 0; i <= m_max_n;i++)
325 m_binCoeffs[i][0] = m_binCoeffs[i][i] = 1;
328 for (i = 2; i <= m_max_n; i ++)
330 for (j = 1; j < i; j++)
332 m_binCoeffs[i][j] = m_binCoeffs[i-1][j-1]+m_binCoeffs[i-1][j];
341 for(i = 0;i<= m_max_n;i++)
343 delete[] m_binCoeffs[i];
345 delete[] m_binCoeffs;
349 inline TYP
value(
unsigned int n,
unsigned int k)
const 351 return m_binCoeffs[n][k];
368 template<
typename FunctionType,
379 FuncInvoker(FunctionType f, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3, ArgType4 _arg4, ArgType5 _arg5, ArgType6 _arg6, ArgType7 _arg7, ArgType8 _arg8) :
380 function(f), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5), arg6(_arg6), arg7(_arg7), arg8(_arg8) { }
382 inline void operator()() {
function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); }
384 FunctionType
function;
399 template<
typename FunctionType,
typename ArgType1,
typename ArgType2,
typename ArgType3,
typename ArgType4,
typename ArgType5,
typename ArgType6,
typename ArgType7>
402 FuncInvoker(FunctionType f, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3, ArgType4 _arg4, ArgType5 _arg5, ArgType6 _arg6, ArgType7 _arg7) :
403 function(f), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5), arg6(_arg6), arg7(_arg7) { }
405 inline void operator()() {
function(arg1, arg2, arg3, arg4, arg5, arg6, arg7); }
407 FunctionType
function;
420 template<
typename FunctionType,
typename ArgType1,
typename ArgType2,
typename ArgType3,
typename ArgType4,
typename ArgType5,
typename ArgType6>
423 FuncInvoker(FunctionType f, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3, ArgType4 _arg4, ArgType5 _arg5, ArgType6 _arg6) :
424 function(f), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5), arg6(_arg6) { }
426 inline void operator()() {
function(arg1, arg2, arg3, arg4, arg5, arg6); }
428 FunctionType
function;
440 template<
typename FunctionType,
typename ArgType1,
typename ArgType2,
typename ArgType3,
typename ArgType4,
typename ArgType5>
443 FuncInvoker(FunctionType f, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3, ArgType4 _arg4, ArgType5 _arg5) :
444 function(f), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5) { }
446 inline void operator()() {
function(arg1, arg2, arg3, arg4, arg5); }
448 FunctionType
function;
459 template<
typename FunctionType,
typename ArgType1,
typename ArgType2,
typename ArgType3,
typename ArgType4>
462 FuncInvoker(FunctionType f, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3, ArgType4 _arg4) :
463 function(f), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4) { }
465 inline void operator()() {
function(arg1, arg2, arg3, arg4); }
467 FunctionType
function;
477 template<
typename FunctionType,
typename ArgType1,
typename ArgType2,
typename ArgType3>
480 FuncInvoker(FunctionType f, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3) :
481 function(f), arg1(_arg1), arg2(_arg2), arg3(_arg3) { }
485 FunctionType
function;
494 template<
typename FunctionType,
typename ArgType1,
typename ArgType2>
498 function(f), arg1(_arg1), arg2(_arg2) { }
502 FunctionType
function;
510 template<
typename FunctionType,
typename ArgType1>
514 function(f), arg1(_arg1) { }
518 FunctionType
function;
525 template<
typename FunctionType>
533 FunctionType
function;
537 template<
typename FunctionType,
typename ArgType1,
typename ArgType2,
typename ArgType3,
typename ArgType4,
typename ArgType5,
typename ArgType6,
typename ArgType7,
typename ArgType8>
539 createFuncInvoker(FunctionType func, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3, ArgType4 _arg4, ArgType5 _arg5, ArgType6 _arg6, ArgType7 _arg7, ArgType8 _arg8)
541 return FuncInvoker<FunctionType, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8>(func, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8);
544 template<
typename FunctionType,
typename ArgType1,
typename ArgType2,
typename ArgType3,
typename ArgType4,
typename ArgType5,
typename ArgType6,
typename ArgType7,
typename ArgType8>
546 createFuncInvoker(FunctionType func, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3, ArgType4 _arg4, ArgType5 _arg5, ArgType6 _arg6, ArgType7 _arg7)
548 return FuncInvoker<FunctionType, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, EmptyArgType>(func, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7);
551 template<
typename FunctionType,
typename ArgType1,
typename ArgType2,
typename ArgType3,
typename ArgType4,
typename ArgType5,
typename ArgType6>
553 createFuncInvoker(FunctionType func, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3, ArgType4 _arg4, ArgType5 _arg5, ArgType6 _arg6)
555 return FuncInvoker<FunctionType, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6>(func, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6);
558 template<
typename FunctionType,
typename ArgType1,
typename ArgType2,
typename ArgType3,
typename ArgType4,
typename ArgType5>
560 createFuncInvoker(FunctionType func, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3, ArgType4 _arg4, ArgType5 _arg5)
562 return FuncInvoker<FunctionType, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5>(func, _arg1, _arg2, _arg3, _arg4, _arg5);
565 template<
typename FunctionType,
typename ArgType1,
typename ArgType2,
typename ArgType3,
typename ArgType4>
567 createFuncInvoker(FunctionType func, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3, ArgType4 _arg4)
572 template<
typename FunctionType,
typename ArgType1,
typename ArgType2,
typename ArgType3>
579 template<
typename FunctionType,
typename ArgType1,
typename ArgType2>
586 template<
typename FunctionType,
typename ArgType1>
593 template<
typename FunctionType>
bool isAvailable(node v) const
Declaration of class GraphAttributes which extends a Graph by additional attributes.
T * align_16_prev_ptr(T *t)
utility class to select multiple nodes randomly
FuncInvoker(FunctionType f, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3)
virtual void clear()
Removes all nodes and all edges from the graph.
Data type for general directed graphs (adjacency list representation).
virtual void delNode(node v)
Removes node v and all incident edges from the graph.
void init()
Reinitializes the array. Associates the array with no graph.
void randomGridGraph(Graph &G, int n, int m, double missinNodesPercentage=0.03)
int randomNumber(int low, int high)
Returns random integer between low and high (including).
FuncInvoker(FunctionType f, ArgType1 _arg1)
node * m_array
the set of all nodes (at the end the available nodes)
FuncInvoker(FunctionType f, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3, ArgType4 _arg4, ArgType5 _arg5, ArgType6 _arg6, ArgType7 _arg7, ArgType8 _arg8)
void removeNode(node v)
removes a node from available nodes (assumes v is available) in O(1)
FuncInvoker(FunctionType f, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3, ArgType4 _arg4)
int m_numNodesChoosen
num available nodes
const Graph & m_graph
the graph
T * align_16_next_ptr(T *t)
RandomNodeSet(const Graph &G)
init the random node set with the given graph. takes O(n)
FuncInvoker(FunctionType f)
NodeArray< int > m_nodeIndex
the index in the array of the nodes
FuncInvoker(FunctionType f, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3, ArgType4 _arg4, ArgType5 _arg5, ArgType6 _arg6)
~RandomNodeSet()
destructor
edge newEdge(node v, node w)
Creates a new edge (v,w) and returns it.
FuncInvoker(FunctionType f, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3, ArgType4 _arg4, ArgType5 _arg5, ArgType6 _arg6, ArgType7 _arg7)
void init_array()
Init BK -matrix for values n, k in 0 to t.
void free_array()
Free space for BK.
MNR_T mortonNumber(C_T ix, C_T iy)
common template for bit-interleaving to compute the morton number assumes sizeOf(MNR_T) = 2*sizeOf(C_...
Class for the representation of nodes.
uint32_t mostSignificantBit(T n)
returns the index of the most signficant bit set. 0 = most signif, bitlength-1 = least signif ...
void mortonNumberInv(MNR_T mnr, C_T &x, C_T &y)
common template for extracting the coordinates from a morton number assumes sizeOf(MNR_T) = 2*sizeOf(...
TYP value(unsigned int n, unsigned int k) const
uint32_t prevPowerOfTwo(uint32_t n)
returns the prev power of two
FuncInvoker(FunctionType f, ArgType1 _arg1, ArgType2 _arg2)
int m_numNodes
total num nodes
int nodesLeft() const
number of nodes available
FuncInvoker(FunctionType f, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3, ArgType4 _arg4, ArgType5 _arg5)
FuncInvoker< FunctionType, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8 > createFuncInvoker(FunctionType func, ArgType1 _arg1, ArgType2 _arg2, ArgType3 _arg3, ArgType4 _arg4, ArgType5 _arg5, ArgType6 _arg6, ArgType7 _arg7, ArgType8 _arg8)
The namespace for all OGDF objects.
void gridGraph(Graph &G, int n, int m)
binomial coeffs from Hachuls FMMM
TYP ** m_binCoeffs
holds the binominal coefficients
void printProfiledTime(double t, const char *text)
int numberOfNodes() const
Returns the number of nodes in the graph.
node newNode()
Creates a new node and returns it.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
node chooseNode() const
chooses a node from the available nodes in O(1)
void OGDF_FME_Print_Config()