20 #ifndef __CXXGRAPH_PARTITIONING_PARTITIONER_H__
21 #define __CXXGRAPH_PARTITIONING_PARTITIONER_H__
25 #include "PartitionStrategy.hpp"
26 #include "Partitioning/Utility/Globals.hpp"
27 #include "Edge/Edge.hpp"
28 #include "CoordinatedPartitionState.hpp"
29 #include "Utility/Runnable.hpp"
30 #include "PartitionerThread.hpp"
31 #include "PartitionAlgorithm.hpp"
36 namespace PARTITIONING
42 std::vector<Edge<T>> dataset;
58 this->dataset = dataset;
59 if (GLOBALS.partitionStategy == PartitionAlgorithm::HDRF_ALG)
61 algorithm =
new HDRF<T>(GLOBALS);
65 CoordinatedPartitionState<T> Partitioner<T>::startCoordinated()
67 CoordinatedPartitionState state(GLOBALS);
68 int processors = GLOBALS.threads;
70 std::thread myThreads[processors];
72 int n = dataset.size();
73 int subSize = n / processors + 1;
74 for (
int t = 0; t < processors; t++)
76 int iStart = t * subSize;
77 int iEnd = std::min((t + 1) * subSize, n);
80 std::vector<Edge<T>> list(dataset.begin() + iStart, dataset.begin() + iEnd);
81 Runnable x = PartitionerThread<T>(list, state, algorithm,
new std::list<int>());
82 myThreads[t] = std::thread(&Runnable::run, &x);
85 for (
int t = 0; t < processors; t++)
92 Partitioner<T>::~Partitioner()
96 CoordinatedPartitionState<T> Partitioner<T>::performCoordinatedPartition()
98 return startCoordinated();
Definition: CoordinatedPartitionState.hpp:39
Definition: Globals.hpp:32
Definition: PartitionStrategy.hpp:34
Definition: Partitioner.hpp:40