20#ifndef __PBeFS_ads_ExplicitAdjacency
21 #define __PBeFS_ads_ExplicitAdjacency
38#include "ADS/graph/ArrayGraph.h"
40#include "ADS/graph/GraphBuilder.h"
72 : f_n( n ) , f_b( int( n ) , true ) {}
77 : f_n( o.f_n ) , f_b( o.f_b ) {}
86 f_frozen.store(
false , std::memory_order_relaxed );
94 void add( std::uint32_t u , std::uint32_t v , Cost c ) {
97 f_b.addEdge(
int( u ) ,
int( v ) , c );
98 f_frozen.store(
false , std::memory_order_relaxed );
105 if( ! f_frozen.load( std::memory_order_acquire ) )
107 f_g->forEachEdge(
int( u ) , [ & ](
int v ,
const Cost & c ) {
108 f( std::uint32_t( v ) , c );
114 [[nodiscard]] std::size_t
size(
void )
const noexcept {
return( f_n ); }
122 void freeze(
void )
const {
123 std::lock_guard< std::mutex > lock( f_lock );
124 if( f_frozen.load( std::memory_order_relaxed ) )
126 f_g.emplace( f_b.toArrayGraph() );
127 f_frozen.store(
true , std::memory_order_release );
133 ADS::GraphBuilder< Cost > f_b;
134 mutable std::optional< ADS::ArrayGraph< Cost > > f_g;
136 mutable std::atomic< bool > f_frozen{
false };
137 mutable std::mutex f_lock;
void for_each(std::uint32_t u, F &&f) const
calls f( v , c ) for each arc ( u , v ) of cost c
Definition ExplicitAdjacency.h:104
ExplicitAdjacency(std::size_t n)
constructor of n nodes and no arc
Definition ExplicitAdjacency.h:71
void add(std::uint32_t u, std::uint32_t v, Cost c)
adds the arc ( u , v ) of cost c
Definition ExplicitAdjacency.h:94
std::size_t size(void) const noexcept
the number of nodes
Definition ExplicitAdjacency.h:114
ExplicitAdjacency & operator=(const ExplicitAdjacency &o)
copy assignment: the arcs, to be frozen again
Definition ExplicitAdjacency.h:81
ExplicitAdjacency(const ExplicitAdjacency &o)
copy constructor: the arcs, to be frozen again
Definition ExplicitAdjacency.h:76
namespace for the Parallel Best-First Search library
Definition AStar.h:83