Batches#

dyng::edge_batch and its view: insertions (upserts), deletions and weight changes applied by update() under the graph’s batch semantics (ADR 0010).

template<typename vertex_t, typename weight_t>
struct edge_batch_view#

A non-owning batch of changes. An empty array means “none of this kind”.

How the batch is interpreted (upsert, deletions first, self-loops, …) is a property of the graph it is applied to (graph_properties::semantics), not of the batch.

Template Parameters:
  • vertex_t – Vertex id type.

  • weight_t – Weight type.

Public Functions

inline std::size_t num_insertions() const noexcept#

Number of edge insertions.

Returns:

insert_src.size().

inline std::size_t num_deletions() const noexcept#

Number of edge deletions.

Returns:

delete_src.size().

inline bool empty() const noexcept#

Whether the batch has no operation at all.

Returns:

True if every array is empty.

Public Members

array_view<const vertex_t> insert_src#

source of each insertion

array_view<const vertex_t> insert_dst#

destination of each insertion

array_view<const weight_t> insert_weights#

num_weights per insertion, insertion-major

array_view<const vertex_t> delete_src#

source of each deletion

array_view<const vertex_t> delete_dst#

destination of each deletion

array_view<const vertex_t> insert_vertices#

new vertices (0.4, DynLP)

array_view<const std::int8_t> insert_vertex_labels#

optional labels of new vertices

array_view<const vertex_t> delete_vertices#

removed vertices (0.4, DynLP)

int num_weights = is_unweighted_v<weight_t> ? 0 : 1#

weights per insertion (0: unweighted)

template<typename vertex_t, typename weight_t>
class edge_batch#

An owning host batch with a builder interface.

Operations keep the order in which they were added; the order matters (the last insertion of a pair wins under upsert semantics).

Template Parameters:
  • vertex_t – Vertex id type.

  • weight_t – Weight type.

Public Functions

inline explicit edge_batch(int num_weights = default_num_weights)#

An empty batch.

Parameters:

num_weights – [in] Weights per insertion (the number of objectives of the graph; 0 for weight_t = unweighted).

Throws:

invalid_argument_error – if num_weights is negative, or not 0 for an unweighted batch.

inline void insert_edge(vertex_t u, vertex_t v, std::initializer_list<weight_t> weights)#

Add an edge insertion (or an upsert of an existing edge).

Exception safety:

Strong: after an exception the batch is unchanged.

Parameters:
  • u – [in] Source.

  • v – [in] Destination.

  • weights – [in] Its num_weights() weights.

Throws:
inline void insert_edge(vertex_t u, vertex_t v)#

Add an edge insertion without weights (a batch with num_weights() == 0, e.g. of an unweighted graph).

Exception safety:

Strong: after an exception the batch is unchanged.

Parameters:
  • u – [in] Source.

  • v – [in] Destination.

Throws:
inline void insert_edge(vertex_t u, vertex_t v, array_view<const weight_t> weights)#

Add an edge insertion (or an upsert of an existing edge).

Exception safety:

Strong: after an exception the batch is unchanged.

Parameters:
  • u – [in] Source.

  • v – [in] Destination.

  • weights – [in] Its num_weights() weights (host memory).

Throws:
inline void delete_edge(vertex_t u, vertex_t v)#

Add an edge deletion.

Exception safety:

Strong: after an exception the batch is unchanged.

Parameters:
  • u – [in] Source.

  • v – [in] Destination.

Throws:

out_of_memory_error – if the arrays cannot grow.

inline void reserve(std::size_t insertions, std::size_t deletions)#

Reserve capacity.

Exception safety:

Strong for the contents (the operations are unchanged; some arrays may keep a larger capacity).

Parameters:
  • insertions – [in] Expected number of insertions.

  • deletions – [in] Expected number of deletions.

Throws:

out_of_memory_error – if the capacity cannot be allocated.

inline void clear() noexcept#

Remove every operation (keeps num_weights() and the capacity).

Exception safety:

No-throw.

inline int num_weights() const noexcept#

Weights per insertion.

Returns:

The value given at construction.

inline std::size_t num_insertions() const noexcept#

Number of edge insertions.

Returns:

The insertion count.

inline std::size_t num_deletions() const noexcept#

Number of edge deletions.

Returns:

The deletion count.

inline bool empty() const noexcept#

Whether the batch is empty.

Returns:

True if it has no operation.

inline const std::vector<vertex_t> &insert_src() const noexcept#

Sources of the insertions.

Returns:

The array, in insertion order.

inline const std::vector<vertex_t> &insert_dst() const noexcept#

Destinations of the insertions.

Returns:

The array, in insertion order.

inline const std::vector<weight_t> &insert_weights() const noexcept#

Weights of the insertions, num_weights() per insertion.

Returns:

The insertion-major array.

inline const std::vector<vertex_t> &delete_src() const noexcept#

Sources of the deletions.

Returns:

The array, in deletion order.

inline const std::vector<vertex_t> &delete_dst() const noexcept#

Destinations of the deletions.

Returns:

The array, in deletion order.

inline edge_batch_view<vertex_t, weight_t> view() const noexcept#

A read-only view of the batch.

Returns:

A host edge_batch_view; valid while this batch is alive and unmodified.

Public Static Attributes

static constexpr int default_num_weights = is_unweighted_v<weight_t> ? 0 : 1#

The default number of weights per insertion: 0 for weight_t = unweighted, else 1.