20 #ifndef __CXXGRAPH_PARTITIONING_EDGEBALANCEDVERTEXCUT_H__
21 #define __CXXGRAPH_PARTITIONING_EDGEBALANCEDVERTEXCUT_H__
25 #include "Partitioning/Utility/Globals.hpp"
26 #include "Edge/Edge.hpp"
27 #include "PartitionStrategy.hpp"
32 namespace PARTITIONING
56 EdgeBalancedVertexCut<T>::~EdgeBalancedVertexCut()
60 void EdgeBalancedVertexCut<T>::performStep(
const Edge<T> &e, PartitionState<T> &state)
63 int P = GLOBALS.numberOfPartition;
64 auto nodePair = e.getNodePair();
65 int u = nodePair.first->getId();
66 int v = nodePair.second->getId();
68 std::shared_ptr<Record<T>> u_record = state.getRecord(u);
69 std::shared_ptr<Record<T>> v_record = state.getRecord(v);
72 bool locks_taken =
false;
75 srand((
unsigned)time(NULL));
77 while (!u_record->getLock())
79 std::this_thread::sleep_for(std::chrono::microseconds(usleep_time));
80 usleep_time = (int)pow(usleep_time, 2);
85 while (!v_record->getLock())
87 std::this_thread::sleep_for(std::chrono::microseconds(usleep_time));
88 usleep_time = (int)pow(usleep_time, 2);
90 if (usleep_time > GLOBALS.SLEEP_LIMIT)
92 u_record->releaseLock();
93 performStep(e, state);
103 int MIN_LOAD = state.getMachineLoad(0);
105 double MAX_SCORE = 0.0;
107 for (
int m = 0; m < P; m++)
109 int load = state.getMachineLoad(m);
110 if ( load <= MIN_LOAD ){
117 CoordinatedPartitionState<T> &cord_state =
dynamic_cast<CoordinatedPartitionState<T> &
>(state);
119 if (!u_record->hasReplicaInPartition(machine_id))
121 u_record->addPartition(machine_id);
122 cord_state.incrementMachineLoadVertices(machine_id);
124 if (!v_record->hasReplicaInPartition(machine_id))
126 v_record->addPartition(machine_id);
127 cord_state.incrementMachineLoadVertices(machine_id);
130 catch (
const std::bad_cast& e)
134 if (!u_record->hasReplicaInPartition(machine_id))
136 u_record->addPartition(machine_id);
138 if (!v_record->hasReplicaInPartition(machine_id))
140 v_record->addPartition(machine_id);
145 state.incrementMachineLoad(machine_id, &e);
148 u_record->incrementDegree();
149 v_record->incrementDegree();
152 u_record->releaseLock();
153 v_record->releaseLock();
A Vertex Cut Partioning Algorithm that assign an edge in the partition with less load.
Definition: EdgeBalancedVertexCut.hpp:40
Definition: Globals.hpp:32
Definition: PartitionState.hpp:33
Definition: PartitionStrategy.hpp:34