CXXGraph  0.1.6
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 
31 namespace CXXGRAPH
32 {
33  namespace PARTITIONING
34  {
35  template <typename T>
37  {
38  private:
39  std::vector<Edge<T>> list;
40  PartitionState<T> *state;
41  PartitionStrategy<T> algorithm;
42 
43  public:
44  PartitionerThread(std::vector<Edge<T>> &list, PartitionState<T> *state, PartitionStrategy<T> &algorithm, std::list<int> *ids);
46 
47  void run();
48 
49  std::list<int> *id_partitions;
50  };
51  template <typename T>
52  PartitionerThread<T>::PartitionerThread(std::vector<Edge<T>> &list, PartitionState<T> *state, PartitionStrategy<T> &algorithm, std::list<int> *ids)
53  {
54  this->list = list;
55  this->state = state;
56  this->algorithm = algorithm;
57  this->id_partitions = ids;
58  }
59  template <typename T>
60  PartitionerThread<T>::~PartitionerThread()
61  {
62  }
63  template <typename T>
64  void PartitionerThread<T>::run()
65  {
66  auto edge_it = list.begin();
67  for (edge_it; edge_it != list.end(); ++edge_it)
68  {
69  algorithm.performStep(*edge_it, *state);
70  }
71  }
72  }
73 }
74 
75 #endif // __CXXGRAPH_PARTITIONING_PARTITIONERTHREAD_H__
Definition: Edge.hpp:40
Definition: PartitionState.hpp:31
Definition: PartitionStrategy.hpp:34
Definition: PartitionerThread.hpp:37