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"
33 #include "EdgeBalancedVertexCut.hpp"
34 #include "GreedyVertexCut.hpp"
39 namespace PARTITIONING
45 const T_EdgeSet<T>* dataset =
nullptr;
63 this->dataset = dataset;
64 if (GLOBALS.partitionStategy == PartitionAlgorithm::HDRF_ALG)
66 algorithm =
new HDRF<T>(GLOBALS);
67 }
else if (GLOBALS.partitionStategy == PartitionAlgorithm::EDGEBALANCED_VC_ALG)
69 algorithm =
new EdgeBalancedVertexCut<T>(GLOBALS);
70 }
else if (GLOBALS.partitionStategy == PartitionAlgorithm::GREEDY_VC_ALG)
72 algorithm =
new GreedyVertexCut<T>(GLOBALS);
73 }
else if (GLOBALS.partitionStategy == PartitionAlgorithm::EBV_ALG)
75 algorithm =
new EBV<T>(GLOBALS);
81 Partitioner<T>::Partitioner(
const Partitioner& other){
82 this->dataset = other.dataset;
83 this->GLOBALS = other.GLOBALS;
84 if (GLOBALS.partitionStategy == PartitionAlgorithm::HDRF_ALG)
86 algorithm =
new HDRF<T>(GLOBALS);
87 }
else if (GLOBALS.partitionStategy == PartitionAlgorithm::EDGEBALANCED_VC_ALG)
89 algorithm =
new EdgeBalancedVertexCut<T>(GLOBALS);
90 }
else if (GLOBALS.partitionStategy == PartitionAlgorithm::GREEDY_VC_ALG)
92 algorithm =
new GreedyVertexCut<T>(GLOBALS);
93 }
else if (GLOBALS.partitionStategy == PartitionAlgorithm::EBV_ALG)
95 algorithm =
new EBV<T>(GLOBALS);
100 CoordinatedPartitionState<T> Partitioner<T>::startCoordinated()
102 CoordinatedPartitionState<T> state(GLOBALS);
103 int processors = GLOBALS.threads;
105 std::thread myThreads[processors];
106 std::shared_ptr<Runnable> myRunnable[processors];
107 std::vector<const Edge<T>*> list_vector[processors];
108 int n = dataset->size();
109 int subSize = n / processors + 1;
110 for (
int t = 0; t < processors; ++t)
112 int iStart = t * subSize;
113 int iEnd = std::min((t + 1) * subSize, n);
116 list_vector[t] = std::vector<const Edge<T>*>(std::next(dataset->begin(), iStart), std::next(dataset->begin(), iEnd));
117 myRunnable[t] = std::make_shared<PartitionerThread<T>>(list_vector[t], &state, algorithm);
118 myThreads[t] = std::thread(&Runnable::run, myRunnable[t].get());
121 for (
int t = 0; t < processors; ++t)
123 if (myThreads[t].joinable()){
139 template <
typename T>
140 Partitioner<T>::~Partitioner()
142 if(algorithm !=
nullptr)
147 template <
typename T>
148 CoordinatedPartitionState<T> Partitioner<T>::performCoordinatedPartition()
150 return startCoordinated();
Definition: CoordinatedPartitionState.hpp:41
Definition: Globals.hpp:32
A Vertex Cut Partioning Algorithm ( as described by this paper https://www.fabiopetroni....
Definition: HDRF.hpp:40
Definition: PartitionStrategy.hpp:34
Definition: Partitioner.hpp:43