25 #ifndef GRAPHLAB_GRAPH_VERTEX_SET_HPP
26 #define GRAPHLAB_GRAPH_VERTEX_SET_HPP
28 #include <graphlab/util/dense_bitset.hpp>
29 #include <graphlab/graph/graph_basic_types.hpp>
30 #include <graphlab/rpc/buffered_exchange.hpp>
31 #include <graphlab/macros_def.hpp>
100 template <
typename DGraphType>
101 const dense_bitset& get_lvid_bitset(
const DGraphType& dgraph)
const {
102 if (lazy) make_explicit(dgraph);
114 inline void set_lvid_unsync(
lvid_type lvid) {
137 template <
typename DGraphType>
138 void make_explicit(
const DGraphType& dgraph)
const {
140 localvset.
resize(dgraph.num_local_vertices());
141 if (is_complete_set) {
156 template <
typename DGraphType>
157 void synchronize_master_to_mirrors(DGraphType& dgraph,
158 buffered_exchange<vertex_id_type>& exchange) {
160 make_explicit(dgraph);
163 foreach(
size_t lvid, localvset) {
164 typename DGraphType::local_vertex_type lvtx = dgraph.l_vertex(lvid);
168 foreach(
size_t proc, lvtx.mirrors()) {
169 exchange.send(proc, gvid);
178 typename buffered_exchange<vertex_id_type>::buffer_type recv_buffer;
181 while(exchange.recv(sending_proc, recv_buffer)) {
194 template <
typename DGraphType>
195 void synchronize_mirrors_to_master_or(DGraphType& dgraph,
196 buffered_exchange<vertex_id_type>& exchange) {
198 make_explicit(dgraph);
201 foreach(
size_t lvid, localvset) {
202 typename DGraphType::local_vertex_type lvtx = dgraph.l_vertex(lvid);
206 exchange.send(lvtx.owner(), gvid);
211 typename buffered_exchange<vertex_id_type>::buffer_type recv_buffer;
214 while(exchange.recv(sending_proc, recv_buffer)) {
222 template <
typename VertexType,
typename EdgeType>
234 explicit vertex_set(
bool complete):is_complete_set(complete),lazy(true){}
238 localvset(other.localvset),
239 is_complete_set(other.is_complete_set),
244 localvset = other.localvset;
245 is_complete_set = other.is_complete_set;
254 inline bool l_contains(
lvid_type lvid)
const {
255 if (lazy)
return is_complete_set;
256 if (lvid < localvset.
size()) {
257 return localvset.
get(lvid);
331 if (is_complete_set) (*this) = other;
334 else if (other.lazy) {
335 if (other.is_complete_set) ;
339 localvset &= other.localvset;
356 if (is_complete_set) (*this) =
vertex_set(
true);
357 else (*
this) = other;
359 else if (other.lazy) {
360 if (other.is_complete_set) (*this) =
vertex_set(
true);
364 localvset |= other.localvset;
386 if (is_complete_set) (*this) = ~other;
389 else if (other.lazy) {
390 if (other.is_complete_set) (*this) =
vertex_set(
false);
394 localvset -= other.localvset;
423 is_complete_set = !is_complete_set;
435 #include <graphlab/macros_undef.hpp>