30 #ifndef GRAPHLAB_GRAPH_STORAGE_HPP
31 #define GRAPHLAB_GRAPH_STORAGE_HPP
52 #include <boost/version.hpp>
53 #include <boost/bind.hpp>
54 #include <boost/unordered_set.hpp>
55 #include <boost/iterator.hpp>
56 #include <boost/iterator/counting_iterator.hpp>
57 #include <boost/iterator/iterator_facade.hpp>
60 #include <graphlab/logger/assertions.hpp>
62 #include <graphlab/serialization/iarchive.hpp>
63 #include <graphlab/serialization/oarchive.hpp>
65 #include <graphlab/util/random.hpp>
66 #include <graphlab/util/generics/shuffle.hpp>
67 #include <graphlab/graph/graph_basic_types.hpp>
70 #include <graphlab/parallel/atomic.hpp>
72 #include <graphlab/macros_def.hpp>
81 template<
typename VertexData,
typename EdgeData>
88 typedef EdgeData edge_data_type;
91 typedef VertexData vertex_data_type;
101 edge_type () : _source(-1), _target(-1), _edge_id(-1),
110 _source(_source), _target(_target), _edge_id(_eid),
111 _dir(_dir), _empty(false) {
127 inline bool empty()
const {
return _empty; }
136 friend class graph_storage;
140 class edge_iterator {
142 typedef std::random_access_iterator_tag iterator_category;
143 typedef edge_type value_type;
144 typedef ssize_t difference_type;
145 typedef edge_type* pointer;
146 typedef edge_type reference;
151 edge_iterator () : offset(-1), empty(true) { }
153 edge_iterator (
lvid_type _center,
size_t _offset,
155 center(_center), offset(_offset), itype(_itype), vid_arr(_vid_arr),
159 inline edge_type operator*()
const {
162 inline typename arrow_type::type operator->()
const {
163 return arrow_type::make(make_value());
166 operator_arrow_dispatch<edge_type, edge_type*>::result_type arrow_type;
167 inline arrow_type operator->()
const {
168 return arrow_type(make_value());
171 inline bool operator==(
const edge_iterator& it)
const {
175 inline bool operator!=(
const edge_iterator& it)
const {
176 return !(*
this == it);
180 inline edge_iterator& operator++() {
184 inline edge_iterator operator++(
int) {
188 inline ssize_t operator-(
const edge_iterator& it)
const {
192 inline edge_iterator operator+(difference_type i)
const {
196 inline edge_iterator& operator+=(difference_type i) {
201 inline edge_type make_value()
const {
210 typedef edge_iterator iterator;
211 typedef edge_iterator const_iterator;
212 typedef edge_type value_type;
214 edge_iterator begin_iter, end_iter;
217 edge_list(
const edge_iterator begin_iter = edge_iterator(),
218 const edge_iterator end_iter = edge_iterator()) :
219 begin_iter(begin_iter), end_iter(end_iter) { }
220 inline size_t size()
const {
return end_iter - begin_iter;}
221 inline edge_type operator[](
size_t i)
const {
return *(begin_iter + i);}
222 iterator begin()
const {
return begin_iter; }
223 iterator end()
const {
return end_iter; }
224 bool empty()
const {
return size() == 0; }
230 graph_storage() : use_skip_list(false) { }
236 size_t edge_size()
const {
return num_edges; }
239 size_t vertices_size()
const {
return num_vertices; }
242 size_t num_in_edges (
const lvid_type v)
const {
246 size_t num_out_edges (
const lvid_type v)
const {
261 const edge_data_type& edge_data(
lvid_type source,
266 edge_data_type& edge_data(edge_type edge) {
270 const edge_data_type& edge_data(edge_type edge)
const {
274 edge_list in_edges(
const lvid_type v)
const {
278 edge_list out_edges(
const lvid_type v)
const {
288 void finalize(
size_t _num_of_v, edge_info &edges){
306 std::vector<std::vector> CSC_dst;
312 void load(iarchive& arc) {
317 void save(oarchive& arc)
const {
321 void swap(graph_storage& other) {
327 #include <graphlab/macros_undef.hpp>