20 #ifndef __CXXGRAPH_PARTITIONING_EBV_H__
21 #define __CXXGRAPH_PARTITIONING_EBV_H__
25 #include "Partitioning/Utility/Globals.hpp"
26 #include "Edge/Edge.hpp"
27 #include "PartitionStrategy.hpp"
28 #include <unordered_map>
33 namespace PARTITIONING
61 void EBV<T>::performStep(
const Edge<T> &e, PartitionState<T> &state)
63 GLOBALS.edgeAnalyzed++;
65 int P = GLOBALS.numberOfPartition;
66 double alpha = GLOBALS.param1;
67 double beta = GLOBALS.param2;
68 unsigned long long edgeCardinality = GLOBALS.edgeCardinality;
69 unsigned long long vertexCardinality = GLOBALS.vertexCardinality;
70 auto nodePair = e.getNodePair();
71 int u = nodePair.first->getId();
72 int v = nodePair.second->getId();
74 std::shared_ptr<Record<T>> u_record = state.getRecord(u);
75 std::shared_ptr<Record<T>> v_record = state.getRecord(v);
78 bool locks_taken =
false;
81 srand((
unsigned)time(NULL));
83 while (!u_record->getLock())
85 std::this_thread::sleep_for(std::chrono::microseconds(usleep_time));
86 usleep_time = (int)pow(usleep_time, 2);
91 while (!v_record->getLock())
93 std::this_thread::sleep_for(std::chrono::microseconds(usleep_time));
94 usleep_time = (int)pow(usleep_time, 2);
96 if (usleep_time > GLOBALS.SLEEP_LIMIT)
98 u_record->releaseLock();
99 performStep(e, state);
110 std::map<int, double> eva;
111 auto u_partition = u_record->getPartitions();
112 auto v_partition = v_record->getPartitions();
113 auto optimalEdgesNumber = (double)edgeCardinality / (
double)P;
114 auto optimalVerticesNumber = (double)vertexCardinality / (
double)P;
115 for (
int i = 0; i < P; i++)
118 if (u_partition.empty() || u_partition.find(i) == u_partition.end())
122 if (v_partition.empty() || v_partition.find(i) == v_partition.end())
126 eva[i] += alpha * (state.getMachineLoad(i) / optimalEdgesNumber) + beta * (state.getMachineLoadVertices(i) / optimalVerticesNumber);
129 double min = eva.at(0);
136 machine_id = it.first;
141 CoordinatedPartitionState<T> &cord_state =
dynamic_cast<CoordinatedPartitionState<T> &
>(state);
143 if (!u_record->hasReplicaInPartition(machine_id))
145 u_record->addPartition(machine_id);
146 cord_state.incrementMachineLoadVertices(machine_id);
148 if (!v_record->hasReplicaInPartition(machine_id))
150 v_record->addPartition(machine_id);
151 cord_state.incrementMachineLoadVertices(machine_id);
154 catch (
const std::bad_cast &e)
158 if (!u_record->hasReplicaInPartition(machine_id))
160 u_record->addPartition(machine_id);
162 if (!v_record->hasReplicaInPartition(machine_id))
164 v_record->addPartition(machine_id);
169 state.incrementMachineLoad(machine_id, &e);
172 u_record->incrementDegree();
173 v_record->incrementDegree();
176 u_record->releaseLock();
177 v_record->releaseLock();
A Vertex Cut Partioning Algorithm ( as described by this paper https://arxiv.org/abs/2010....
Definition: EBV.hpp:41
Definition: Globals.hpp:32
Definition: PartitionState.hpp:33
Definition: PartitionStrategy.hpp:34