BfsBuilder

Struct BfsBuilder 

Source
pub struct BfsBuilder<Expander, Callback, Provider, const EXPANSION_NODES: usize> { /* private fields */ }
Expand description

Used to define all the parameters of a BFS and run it.

Implementations§

Source§

impl<Expander, Callback, Provider, const EXPANSION_NODES: usize> BfsBuilder<Expander, Callback, Provider, EXPANSION_NODES>
where Expander: BfsExpander<EXPANSION_NODES> + Clone + Sync, Callback: BfsCallback + Clone + Sync, Provider: BfsSettingsProvider + Sync,

Source

pub fn new() -> Self

Creates a default builder with no parameters set.

Source

pub fn threads(self, threads: usize) -> Self

The number of threads to use in the search.

Source

pub fn chunk_size_bytes(self, chunk_size_bytes: usize) -> Self

The size of each bit array chunk in bytes. Must be at most 2^29.

Source

pub fn update_memory(self, update_memory: usize) -> Self

The amount of memory to use for storing updates (adjacent nodes) in bytes.

Source

pub fn num_update_blocks(self, num_update_blocks: usize) -> Self

The number of blocks in which to divide the update memory.

Source

pub fn capacity_check_frequency(self, capacity_check_frequency: usize) -> Self

The frequency (one check per capacity_check_frequency new nodes) at which to check the capacity of an update block. When capacity is reached, the block will be stored and a new block taken.

Source

pub fn initial_states(self, initial_states: &[u64]) -> Self

The nodes at depth 0, from which the search starts.

Source

pub fn state_size(self, state_size: u64) -> Self

The number of nodes in the graph.

Source

pub fn root_directories(self, root_directories: &[PathBuf]) -> Self

The working directories that will contain all of the intermediate data. Each directory should be on a different hard drive.

Source

pub fn initial_memory_limit(self, initial_memory_limit: usize) -> Self

Approximate amount of memory in bytes to use for the initial in-memory breadth-first search, before switching to the disk-based search.

Source

pub fn available_disk_space_limit(self, available_disk_space_limit: u64) -> Self

The minimum amount of available disk space (in bytes) that should be kept free on each drive.

Source

pub fn update_array_threshold(self, update_array_threshold: u64) -> Self

The threshold at which to switch from writing an update file containing a list of node indices, to writing a bit array of updates.

Source

pub fn use_locked_io(self, use_locked_io: bool) -> Self

Whether disk I/O should be locked using a mutex to prevent multiple threads from performing I/O on the same disk at the same time.

Source

pub fn sync_filesystem(self, sync_filesystem: bool) -> Self

Whether to call sync on the filesystem before deleting files. If this is set to false and a system failure occurs, it’s possible that data could be lost and the search would need to be restarted from the beginning.

Source

pub fn compute_checksums(self, compute_checksums: bool) -> Self

Whether to compute and verify checksums for all data written to disk.

Source

pub fn use_compression(self, use_compression: bool) -> Self

Whether update files and bit arrays should be compressed.

Source

pub fn expander(self, expander: Expander) -> Self

The implementor of the BfsExpander trait that defines the graph to traverse.

Source

pub fn callback(self, callback: Callback) -> Self

The implementor of the BfsCallback trait that defines callbacks to run during the search.

Source

pub fn settings_provider(self, settings_provider: Provider) -> Self

The implementor of the BfsSettingsProvider trait that provides various additional settings for the search.

Source

pub fn run_no_defaults(self) -> Result<(), BfsBuilderError>

Runs the BFS with the given settings, requiring all fields of the BfsBuilder to be set explicitly, without using any default values.

Source

pub fn run(self) -> Result<(), BfsBuilderError>

Runs the BFS with the given settings, using default values for any parameters that were not set, if possible.

Default values are:

  • threads: 1
  • update_memory: 1 GiB
  • capacity_check_frequency: 256
  • initial_memory_limit: 64 MiB
  • use_locked_io: false
  • sync_filesystem: true
  • compute_checksums: true
  • use_compression: true
  • update_array_threshold: chunk_size_bytes
  • num_update_blocks: 2 * threads * num_chunks, where num_chunks = state_size / (8 * chunk_size_bytes)

Trait Implementations§

Source§

impl<Expander: Debug, Callback: Debug, Provider: Debug, const EXPANSION_NODES: usize> Debug for BfsBuilder<Expander, Callback, Provider, EXPANSION_NODES>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Expander, Callback, Provider, const EXPANSION_NODES: usize> Default for BfsBuilder<Expander, Callback, Provider, EXPANSION_NODES>
where Expander: BfsExpander<EXPANSION_NODES> + Clone + Sync, Callback: BfsCallback + Clone + Sync, Provider: BfsSettingsProvider + Sync,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Expander, Callback, Provider, const EXPANSION_NODES: usize> Freeze for BfsBuilder<Expander, Callback, Provider, EXPANSION_NODES>
where Expander: Freeze, Callback: Freeze, Provider: Freeze,

§

impl<Expander, Callback, Provider, const EXPANSION_NODES: usize> RefUnwindSafe for BfsBuilder<Expander, Callback, Provider, EXPANSION_NODES>
where Expander: RefUnwindSafe, Callback: RefUnwindSafe, Provider: RefUnwindSafe,

§

impl<Expander, Callback, Provider, const EXPANSION_NODES: usize> Send for BfsBuilder<Expander, Callback, Provider, EXPANSION_NODES>
where Expander: Send, Callback: Send, Provider: Send,

§

impl<Expander, Callback, Provider, const EXPANSION_NODES: usize> Sync for BfsBuilder<Expander, Callback, Provider, EXPANSION_NODES>
where Expander: Sync, Callback: Sync, Provider: Sync,

§

impl<Expander, Callback, Provider, const EXPANSION_NODES: usize> Unpin for BfsBuilder<Expander, Callback, Provider, EXPANSION_NODES>
where Expander: Unpin, Callback: Unpin, Provider: Unpin,

§

impl<Expander, Callback, Provider, const EXPANSION_NODES: usize> UnwindSafe for BfsBuilder<Expander, Callback, Provider, EXPANSION_NODES>
where Expander: UnwindSafe, Callback: UnwindSafe, Provider: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more