STAPL API Reference          
Overview   Containers   Algorithms   Views   Skeletons   Run-Time System
Modules     Classes    
List of all members | Public Member Functions | Public Types | Static Public Attributes | Protected Attributes
stapl::csr_vector_storage< Traits > Class Template Reference

An CSR using an std::vector for storing vertices. Used inside the csr_model to store vertices. More...

Public Member Functions

 csr_vector_storage (size_t const &start_vd, size_t const &num_vds, vertex_impl_type const &default_value)
 Constructs a storage with the given number of vertices starting from the specified descriptor, with the given default value. Vertices have contiguous descriptors. More...
 
 csr_vector_storage (csr_vector_storage const &other)
 
void resize (size_t nv)
 Resize the internal storage to accommodate specified number of vertices.
 
iterator begin ()
 Returns an iterator to the start of the vertices.
 
iterator end ()
 Returns an iterator to the end of the vertices.
 
const_iterator begin () const
 Returns an iterator to the start of the vertices.
 
const_iterator end () const
 Returns an iterator to the end of the vertices.
 
edge_iterator edges_begin ()
 Returns an edge_iterator to the start of the edges.
 
edge_iterator edges_end ()
 Returns an edge_iterator to the end of the edges.
 
uncommitted_edge_iterator uncommitted_edges_begin ()
 Returns an edge_iterator to the begin of the uncommitted edges.
 
uncommitted_edge_iterator uncommitted_edges_end ()
 Returns an edge_iterator to the end of the uncommitted edges.
 
const_edge_iterator edges_begin () const
 Returns an edge_iterator to the start of the edges.
 
const_edge_iterator edges_end () const
 Returns an edge_iterator to the end of the edges.
 
size_t size () const
 Returns the number of vertices in the storage; for use in g.num_vertices().
 
void add_edge (edge_descriptor_type const &ed, edge_property const &ep)
 Adds an edge with given descriptor and default edge property. More...
 
void add_edge (full_edge_type const &e)
 Adds an edge from a full edge. More...
 
void clear (void)
 Erases all vertices and edges in the graph.
 
iterator find_vertex (vertex_descriptor const &vd)
 Finds the vertex with the specified descriptor, and returns an iterator pointing to it. If not found, the end of the graph is returned. More...
 
void update_descriptor (vertex_descriptor const &, iterator const &)
 Not used by CSR graph, provided for compatibility.
 
void update_next_descriptor (vertex_descriptor const &vd)
 Updates the vertex descriptor generator with the next free descriptor.
 
vertex_descriptor get_max_descriptor ()
 Returns the current max descriptor.
 
std::pair< std::size_t, std::size_t > commit ()
 Freezes the CSR graph so that no further addition of edges is possible. More...
 
void uncommit ()
 Uncommit the CSR graph. More...
 
template<typename Comp >
void sort_edges (Comp &&cmp)
 Sorts edges of each vertex by user-defined comparison function. More...
 
template<typename Pred >
void erase_edges_if (Pred &&pred)
 Erases all edges that match a user-defined predicate. More...
 
void remove_duplicate_edges ()
 Removes all duplicate edges with the same (source, target) pair. More...
 

Public Types

typedef Traits::vertex_descriptor vertex_descriptor
 
using edge_property = typename Traits::edge_property
 
typedef Traits::vertex_property vertex_property
 
typedef Traits::full_edge_type full_edge_type
 
using uncommitted_edgelist_type = csr_edgelist_impl< full_edge_type >
 
using uncommitted_edge_iterator = typename uncommitted_edgelist_type::iterator
 
using edge_type = typename Traits::edge_type
 
using edge_descriptor_type = typename edge_type::edge_descriptor_type
 
using vertex_impl_type = typename Traits::vertex_impl_type
 
using edgelist_type = typename Traits::edgelist_type
 
typedef sequential::vdg_base_int< vertex_descriptor > vdg_type
 Type of the vertex descriptor generator.
 
typedef std::vector< vertex_impl_type > vertex_set_type
 The vertices are stored in an std::vector.
 
typedef vertex_set_type::iterator iterator
 
typedef vertex_set_type::const_iterator const_iterator
 
typedef edgelist_type::iterator edge_iterator
 
typedef edgelist_type::const_iterator const_edge_iterator
 

Static Public Attributes

static constexpr graph_attributes m_type = Traits::m_type
 

Protected Attributes

vdg_type m_vdg
 The vertex descriptor generator.
 
vertex_set_type m_storage
 The container for storing vertices.
 
uncommitted_edgelist_type m_uncommitted_edges
 The container for storing uncommitted edges.
 
edgelist_type m_edgelist
 The container for storing edges.
 
vertex_descriptor my_local_start_vd
 The descriptor of the starting vertex in this storage.
 
bool m_committed
 The flag indicates if the CSR is frozen. Edges may only be added to the CSR as long as it is unfrozen. Once it has been frozen by calling the commit() method, no further addition of edges is allowed. The CSR graph starts off in an unfrozen state, and may only be committed once, and may not be uncommitted thereafter.
 
size_t m_ne
 The number of edges in the graph.
 
size_t m_se
 The number of self edges in the graph.
 

Detailed Description

template<class Traits>
class stapl::csr_vector_storage< Traits >

An CSR using an std::vector for storing vertices. Used inside the csr_model to store vertices.

Template Parameters
TraitsThe traits class for specifying the types of descriptors, storages, edges and vertices.

Constructor & Destructor Documentation

◆ csr_vector_storage()

template<class Traits >
stapl::csr_vector_storage< Traits >::csr_vector_storage ( size_t const &  start_vd,
size_t const &  num_vds,
vertex_impl_type const &  default_value 
)

Constructs a storage with the given number of vertices starting from the specified descriptor, with the given default value. Vertices have contiguous descriptors.

Parameters
start_vdThe starting descriptor of the vertices.
num_vdsThe number of vertices to be initially stored.
default_valueThe default value for the vertices.

Member Function Documentation

◆ add_edge() [1/2]

template<class Traits >
void stapl::csr_vector_storage< Traits >::add_edge ( edge_descriptor_type const &  ed,
edge_property const &  ep 
)

Adds an edge with given descriptor and default edge property.

Parameters
edDescriptor of the desired edge.

◆ add_edge() [2/2]

template<class Traits >
void stapl::csr_vector_storage< Traits >::add_edge ( full_edge_type const &  e)

Adds an edge from a full edge.

Parameters
eThe edge to add.

◆ find_vertex()

template<class Traits >
iterator stapl::csr_vector_storage< Traits >::find_vertex ( vertex_descriptor const &  vd)

Finds the vertex with the specified descriptor, and returns an iterator pointing to it. If not found, the end of the graph is returned.

Parameters
vdDescriptor of the vertex.
Returns
An iterator to the specified vertex, if found, or an iterator to the end of the graph otherwise.

◆ commit()

template<class Traits >
std::pair<std::size_t, std::size_t> stapl::csr_vector_storage< Traits >::commit ( )

Freezes the CSR graph so that no further addition of edges is possible.

Note
This method must be called before using the CSR graph, and only after all edges have been added to it. Edges may only be added to the CSR as long as it is unfrozen. Once it has been frozen by calling commit(), no further addition of edges is allowed. The CSR may only be committed once, and may not be uncommitted thereafter.

The CSR graph starts off in an unfrozen state. Freezing it internally sorts and copies the edges to the CSR format and updates the vertices accordingly to point to their adjacent sections in the edgelist.

Returns
A pair of the number of edges and the number of self edges after committing

◆ uncommit()

template<class Traits >
void stapl::csr_vector_storage< Traits >::uncommit ( )

Uncommit the CSR graph.

Place the graph in a state so that edges can be added. While the graph is uncommited, it is not possible to access its edges.

◆ sort_edges()

template<class Traits >
template<typename Comp >
void stapl::csr_vector_storage< Traits >::sort_edges ( Comp &&  cmp)

Sorts edges of each vertex by user-defined comparison function.

Note
The graph must be committed in order to sort its edges

◆ erase_edges_if()

template<class Traits >
template<typename Pred >
void stapl::csr_vector_storage< Traits >::erase_edges_if ( Pred &&  pred)

Erases all edges that match a user-defined predicate.

Note
The graph must be not committed
Parameters
predA unary predicate that receives a single edge

◆ remove_duplicate_edges()

template<class Traits >
void stapl::csr_vector_storage< Traits >::remove_duplicate_edges ( )

Removes all duplicate edges with the same (source, target) pair.

Note
The graph must be not committed

The documentation for this class was generated from the following file: