6 #ifndef METALL_EXAMPLE_GRAPH_DATA_STRUCTURE_CSR_USING_VECTOR_HPP
7 #define METALL_EXAMPLE_GRAPH_DATA_STRUCTURE_CSR_USING_VECTOR_HPP
10 #include <boost/container/vector.hpp>
12 namespace bc = boost::container;
18 template <
typename index_t = uint64_t,
typename vid_t = uint64_t,
19 typename allocator_t = std::allocator<char>>
27 using index_allocator_t =
typename std::allocator_traits<
28 allocator_t>::template rebind_alloc<index_t>;
29 using index_vector_t = bc::vector<index_t, index_allocator_t>;
32 using edge_allocator_t =
33 typename std::allocator_traits<allocator_t>::template rebind_alloc<vid_t>;
34 using edge_vector_t = bc::vector<vid_t, edge_allocator_t>;
38 allocator_t allocator = allocator_t())
39 : m_num_vertices(num_vertices),
40 m_num_edges(num_edges),
41 m_indices(m_num_vertices + 1, allocator),
42 m_edges(m_num_edges, allocator) {}
45 index_t *
indices() {
return m_indices.data(); }
48 vid_t *
edges() {
return m_edges.data(); }
51 const std::size_t m_num_vertices;
52 const std::size_t m_num_edges;
53 index_vector_t m_indices;
54 edge_vector_t m_edges;
Simple CSR graph data structure that can take a custom C++ allocator and be stored in persistent memo...
Definition: csr_using_vector.hpp:20
csr_using_vector(const std::size_t num_vertices, const std::size_t num_edges, allocator_t allocator=allocator_t())
Definition: csr_using_vector.hpp:37
vid_t * edges()
Returns a raw pointer to the edges array.
Definition: csr_using_vector.hpp:48
index_t * indices()
Returns a raw pointer to the indices array.
Definition: csr_using_vector.hpp:45