CXXGraph  0.4.0
CXXGraph is a header only, that manages the Graphs and it's algorithm in C++
PartitionerThread.hpp
1 /***********************************************************/
2 /*** ______ ____ ______ _ ***/
3 /*** / ___\ \/ /\ \/ / ___|_ __ __ _ _ __ | |__ ***/
4 /*** | | \ / \ / | _| '__/ _` | '_ \| '_ \ ***/
5 /*** | |___ / \ / \ |_| | | | (_| | |_) | | | | ***/
6 /*** \____/_/\_\/_/\_\____|_| \__,_| .__/|_| |_| ***/
7 /*** |_| ***/
8 /***********************************************************/
9 /*** Header-Only C++ Library for Graph ***/
10 /*** Representation and Algorithms ***/
11 /***********************************************************/
12 /*** Author: ZigRazor ***/
13 /*** E-Mail: zigrazor@gmail.com ***/
14 /***********************************************************/
15 /*** Collaboration: ----------- ***/
16 /***********************************************************/
17 /*** License: AGPL v3.0 ***/
18 /***********************************************************/
19 
20 #ifndef __CXXGRAPH_PARTITIONING_PARTITIONERTHREAD_H__
21 #define __CXXGRAPH_PARTITIONING_PARTITIONERTHREAD_H__
22 
23 #pragma once
24 
25 #include <vector>
26 #include <list>
27 #include "Edge/Edge.hpp"
28 #include "PartitionState.hpp"
29 #include "PartitionStrategy.hpp"
30 #include "Utility/Runnable.hpp"
31 
32 namespace CXXGRAPH
33 {
34  namespace PARTITIONING
35  {
36  template <typename T>
37  class PartitionerThread : public Runnable
38  {
39  private:
40  std::vector<const Edge<T> *> list = {};
41  PartitionState<T> *state = nullptr;
42  PartitionStrategy<T> *algorithm = nullptr;
43 
44  public:
45  PartitionerThread(std::vector<const Edge<T> *> &list, PartitionState<T> *state, PartitionStrategy<T> *algorithm);
47 
48  void run();
49 
50  std::list<int> id_partitions;
51  };
52  template <typename T>
53  PartitionerThread<T>::PartitionerThread(std::vector<const Edge<T> *> &list, PartitionState<T> *state, PartitionStrategy<T> *algorithm)
54  {
55  this->list = list;
56  this->state = state;
57  this->algorithm = algorithm;
58  }
59  template <typename T>
60  PartitionerThread<T>::~PartitionerThread()
61  {
62  }
63  template <typename T>
64  void PartitionerThread<T>::run()
65  {
66  for (const auto &edge_it : list)
67  {
68  algorithm->performStep(*edge_it, *state);
69  }
70  }
71  }
72 }
73 
74 #endif // __CXXGRAPH_PARTITIONING_PARTITIONERTHREAD_H__
Definition: Edge.hpp:39
Definition: PartitionState.hpp:33
Definition: PartitionStrategy.hpp:34
Definition: PartitionerThread.hpp:38
Definition: Runnable.hpp:28