FlashGraph-ng
A new frontier in large-scale graph analysis and data mining
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
save_result.h
1 #ifndef __SAVE_RESULT_H__
2 #define __SAVE_RESULT_H__
3 
4 /*
5  * Copyright 2014 Open Connectome Project (http://openconnecto.me)
6  * Written by Da Zheng (zhengda1936@gmail.com)
7  *
8  * This file is part of FlashGraph.
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 
23 #include "FG_vector.h"
24 #include "graph_engine.h"
25 
26 namespace {
27 
28 template<class T, class VertexType>
29 class save_query: public fg::vertex_query
30 {
31  typename fg::FG_vector<T>::ptr vec;
32 public:
33  save_query(typename fg::FG_vector<T>::ptr vec) {
34  this->vec = vec;
35  }
36 
37  virtual void run(fg::graph_engine &graph, fg::compute_vertex &v1) {
38  VertexType &v = (VertexType &) v1;
39  vec->set(graph.get_graph_index().get_vertex_id(v), v.get_result());
40  }
41 
42  virtual void merge(fg::graph_engine &graph, fg::vertex_query::ptr q) {
43  }
44 
45  virtual ptr clone() {
46  return fg::vertex_query::ptr(new save_query(vec));
47  }
48 };
49 
50 }
51 
52 #endif
virtual void run(graph_engine &, compute_vertex &v)=0
This method is executed on vertices in parallel and contains any user defined code.
This is the class that coordinates how & where algorithms are run. It can be seen as the central orga...
Definition: graph_engine.h:331
Class from which users' vertex-centric programs should inherit. Serial code written when implementing...
Definition: graph_engine.h:51
virtual void merge(graph_engine &graph, vertex_query::ptr q)=0
All vertex results may be merged (not specially combined but any custom operation). . This for instance can be used to aggregate (add, subtract, max etc.) a user defined data member for the class.
Parallized query of the vertex state of all vertices in the graph. Each worker thread gets an instanc...
Definition: graph_engine.h:295
virtual ptr clone()=0
Implements a copy constructor. The graph engine uses this method to create an instance of this query ...