FlashGraph-ng
A new frontier in large-scale graph analysis and data mining
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
vertex_request.h
1 #ifndef __VERTEX_REQUEST_H__
2 #define __VERTEX_REQUEST_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 "vertex.h"
24 
25 namespace fg
26 {
27 
28 class graph_engine;
29 
30 class vertex_request
31 {
32  vertex_id_t id;
33 public:
34  vertex_request() {
35  id = INVALID_VERTEX_ID;
36  }
37 
38  vertex_request(vertex_id_t id) {
39  this->id = id;
40  }
41 
42  vertex_id_t get_id() const {
43  return id;
44  }
45 
46  bool is_valid() const {
47  return id != INVALID_VERTEX_ID;
48  }
49 
50  // We override "<" so that they can be used in the priority queue.
51  // We want the priority queue to return the requests with smaller
52  // vertex IDs first.
53  bool operator<(const vertex_request &req) const {
54  return this->get_id() > req.get_id();
55  }
56 };
57 
58 class directed_vertex_request: public vertex_request
59 {
60  edge_type type;
61 public:
62  directed_vertex_request() {
63  type = edge_type::NONE;
64  }
65 
66  directed_vertex_request(vertex_id_t id, edge_type type): vertex_request(id) {
67  this->type = type;
68  }
69 
70  edge_type get_type() const {
71  return type;
72  }
73 };
74 
79 class ts_vertex_request: public vertex_request
80 {
81  timestamp_pair range;
82 public:
84  range = timestamp_pair(INT_MAX, INT_MIN);
85  }
86 
87  ts_vertex_request(vertex_id_t id): vertex_request(id) {
88  range = timestamp_pair(INT_MAX, INT_MIN);
89  }
90 
91  ts_vertex_request(vertex_id_t id, timestamp_pair range): vertex_request(
92  id) {
93  this->range = range;
94  }
95 
96  void add_timestamp(int timestamp) {
97  if (range.second < timestamp)
98  range.second = timestamp + 1;
99  if (range.first > timestamp)
100  range.first = timestamp;
101  }
102 
103  const timestamp_pair &get_range() const {
104  return range;
105  }
106 
107  bool is_require_all() const {
108  return range.first == INT_MAX && range.second == INT_MIN;
109  }
110 };
111 
112 }
113 
114 #endif
edge_type
Edge type of an edge in the graph.
Definition: vertex.h:43
Definition: vertex_request.h:79