24#ifndef __PBeFS_ExplicitGraph
25 #define __PBeFS_ExplicitGraph
54#if defined( PBEFS_STRUCTURES_STD )
76 void add( std::uint32_t u , std::uint32_t v , Cost c ) {
77 v_adj[ u ].emplace_back( v , c );
83 void for_each( std::uint32_t u , F && f )
const {
84 for(
const auto & [ v , c ] : v_adj[ u ] )
90 [[nodiscard]] std::size_t
size(
void )
const noexcept {
91 return( v_adj.size() );
98 std::vector< std::vector< std::pair< std::uint32_t , Cost > > > v_adj;
113#if defined( PBEFS_STRUCTURES_BOOST )
114 #include "PBeFS/astar/structures/boost/ExplicitAdjacency.h"
115#elif defined( PBEFS_STRUCTURES_ADS )
137template<
class Cost =
int >
154 : f_source( s ) , f_target( t ) , f_adj( n ) , v_h( n , Cost( 0 ) ) {
155 if( ( s >= n ) || ( t >= n ) )
156 throw( std::invalid_argument(
"ExplicitGraph::ExplicitGraph: source or "
157 "target out of range" ) );
164 bool directed =
false ) {
165 if( ( u >= f_adj.size() ) || ( v >= f_adj.size() ) || ( c < 0 ) )
166 throw( std::invalid_argument(
"ExplicitGraph::add_edge: bad arc" ) );
167 f_adj.add( u , v , c );
169 f_adj.add( v , u , c );
181 if( s >= f_adj.size() )
182 throw( std::invalid_argument(
"ExplicitGraph::set_source: bad node" ) );
193 return( s == f_target );
197 return( ADS::splitmix64( s ) );
206 f_adj.for_each( s , [ & ](
state_type v , Cost c ) {
207 f( v , c , v_h[ v ] );
214 return( f_adj.size() );
219 f( std::size_t( s ) );
232 [[nodiscard]] std::size_t
size(
void )
const noexcept {
233 return( f_adj.size() );
243 std::vector< Cost > v_h;
Header file for the concepts a search problem has to satisfy in order to be searched by the algorithm...
Header file for the class template ExplicitAdjacency of the set of data structures of ADS [see Struct...
Header file for the choice of the set of data structures of A*: the arena of the nodes (NodePool),...
the arcs of a weighted graph, on the GraphBuilder and ArrayGraph of ADS
Definition ExplicitAdjacency.h:63
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
std::uint64_t perfect_hash(state_type s) const noexcept
the perfect hash: the node
Definition ExplicitGraph.h:225
void for_each_feature(state_type s, F &&f) const
Definition ExplicitGraph.h:218
state_type initial_state(void) const noexcept
Definition ExplicitGraph.h:188
void for_each_successor(state_type s, Cost, F &&f) const
Definition ExplicitGraph.h:205
std::uint64_t hash(state_type s) const noexcept
Definition ExplicitGraph.h:196
void set_source(state_type s)
sets the source of the search
Definition ExplicitGraph.h:180
bool is_goal(state_type s) const noexcept
Definition ExplicitGraph.h:192
void add_edge(state_type u, state_type v, Cost c, bool directed=false)
adds the arc ( u , v ) of cost c, and ( v , u ) too unless directed
Definition ExplicitGraph.h:163
std::size_t size(void) const noexcept
the number of nodes
Definition ExplicitGraph.h:232
std::size_t num_features(void) const noexcept
Definition ExplicitGraph.h:213
void set_heuristic(state_type u, Cost h)
sets the heuristic value of the node u
Definition ExplicitGraph.h:175
Cost heuristic(state_type s) const noexcept
Definition ExplicitGraph.h:200
Cost cost_type
the cost type
Definition ExplicitGraph.h:147
std::uint32_t state_type
a node
Definition ExplicitGraph.h:146
ExplicitGraph(std::size_t n, state_type s, state_type t)
constructor of a graph with n nodes and no arc, searched from s to t
Definition ExplicitGraph.h:153
namespace for the Parallel Best-First Search library
Definition AStar.h:83