6 #ifndef METALL_EXAMPLE_GRAPH_DATA_STRUCTURE_CSR_HPP
7 #define METALL_EXAMPLE_GRAPH_DATA_STRUCTURE_CSR_HPP
15 template <
typename index_t = uint64_t,
typename vid_t = uint64_t,
16 typename allocator_t = std::allocator<char>>
24 using index_allocator_t =
typename std::allocator_traits<
25 allocator_t>::template rebind_alloc<index_t>;
26 using index_pointer_t =
27 typename std::allocator_traits<index_allocator_t>::pointer;
30 using edge_allocator_t =
31 typename std::allocator_traits<allocator_t>::template rebind_alloc<vid_t>;
32 using edge_pointer_t =
33 typename std::allocator_traits<edge_allocator_t>::pointer;
36 csr(
const std::size_t num_vertices,
const std::size_t num_edges,
37 allocator_t allocator = allocator_t())
38 : m_num_vertices(num_vertices),
39 m_num_edges(num_edges),
42 m_allocator(allocator) {
44 auto index_allocator = index_allocator_t(m_allocator);
45 m_indices = index_allocator.allocate(m_num_vertices + 1);
46 auto edge_allocator = edge_allocator_t(m_allocator);
47 m_edges = edge_allocator.allocate(num_edges);
52 auto index_allocator = index_allocator_t(m_allocator);
53 index_allocator.deallocate(m_indices, m_num_vertices + 1);
54 auto edge_allocator = edge_allocator_t(m_allocator);
55 edge_allocator.deallocate(m_edges, m_num_edges);
60 return metall::to_raw_pointer(m_indices);
67 return metall::to_raw_pointer(m_edges);
73 const std::size_t m_num_vertices;
74 const std::size_t m_num_edges;
75 index_pointer_t m_indices;
76 edge_pointer_t m_edges;
77 allocator_t m_allocator;
Simple CSR graph data structure that can take a custom C++ allocator and be stored in persistent memo...
Definition: csr.hpp:17
~csr()
Definition: csr.hpp:50
index_t * indices()
Returns a raw pointer to the indices array.
Definition: csr.hpp:59
vid_t * edges()
Returns a raw pointer to the edges array.
Definition: csr.hpp:66
csr(const std::size_t num_vertices, const std::size_t num_edges, allocator_t allocator=allocator_t())
Definition: csr.hpp:36