pub struct Graph { /* private fields */ }Expand description
A ‘prototype’ chunk graph that is (relatively) inefficient to traverse but easy to modify. This is usually used to build and optimise the chunk graph before being converted into an efficient graph representation for use in tree search.
Implementations
sourceimpl Graph
impl Graph
Optimisation
sourcepub fn optimise(&mut self, passes: &[Mutex<Pass>], query: &Query)
pub fn optimise(&mut self, passes: &[Mutex<Pass>], query: &Query)
Repeatedly apply a sequence of Passes until the graph stops getting smaller, or 20
iterations are made. Use Graph::optimise_with_iter_limit to set a custom iteration
limit.
sourcepub fn optimise_with_iter_limit(
&mut self,
passes: &[Mutex<Pass>],
query: &Query,
limit: usize
)
pub fn optimise_with_iter_limit(
&mut self,
passes: &[Mutex<Pass>],
query: &Query,
limit: usize
)
Repeatedly apply a sequence of Passes until the graph either becomes static, or limit
many iterations are performed.
sourcepub fn split_by_start_chunk(&self) -> Vec<Graph>
pub fn split_by_start_chunk(&self) -> Vec<Graph>
For each start chunk in self, creates a copy of self with only that start chunk. This
partitions the set of generated compositions across these Graphs, but allows for better
optimisations because more is known about each Graph.
pub fn num_parts(&self) -> Rotation
sourcepub fn size(&self) -> (usize, usize, Reverse<usize>)
pub fn size(&self) -> (usize, usize, Reverse<usize>)
Return a value representing the ‘size’ of this graph. Optimisation passes are required to never increase this quantity. Graph size is compared on the following factors (in order of precedence, most important first):
- Number of nodes (smaller is better)
- Number of links (smaller is better)
- Number of required nodes (more is better)
sourceimpl Graph
impl Graph
Helpers for optimisation passes
sourcepub fn retain_chunks(&mut self, pred: impl FnMut(&ChunkId, &mut Chunk) -> bool)
pub fn retain_chunks(&mut self, pred: impl FnMut(&ChunkId, &mut Chunk) -> bool)
Removes all chunks for whom pred returns false
sourcepub fn retain_links(
&mut self,
pred: impl FnMut(&Link, &ChunkId, &Chunk, &ChunkId, &Chunk) -> bool
)
pub fn retain_links(
&mut self,
pred: impl FnMut(&Link, &ChunkId, &Chunk, &ChunkId, &Chunk) -> bool
)
Removes all links for whom pred returns false. The parameters of pred are
(link, chunk_from, chunk_to)
sourcepub fn retain_start_chunks(
&mut self,
pred: impl FnMut(&(ChunkId, StartIdx, Rotation)) -> bool
)
pub fn retain_start_chunks(
&mut self,
pred: impl FnMut(&(ChunkId, StartIdx, Rotation)) -> bool
)
Remove elements from Self::start_chunks for which a predicate returns false.
sourcepub fn retain_end_chunks(&mut self, pred: impl FnMut(&(ChunkId, End)) -> bool)
pub fn retain_end_chunks(&mut self, pred: impl FnMut(&(ChunkId, End)) -> bool)
Remove elements from Self::end_chunks for which a predicate returns false.
sourceimpl Graph
impl Graph
Getters & Iterators
pub fn get_link(&self, id: LinkId) -> Option<&Link>
pub fn get_link_mut(&mut self, id: LinkId) -> Option<&mut Link>
pub fn get_chunk<'graph>(&'graph self, id: &ChunkId) -> Option<&'graph Chunk>
pub fn get_chunk_mut<'graph>(
&'graph mut self,
id: &ChunkId
) -> Option<&'graph mut Chunk>
pub fn start_chunks(&self) -> &[(ChunkId, StartIdx, Rotation)]
pub fn end_chunks(&self) -> &[(ChunkId, End)]
pub fn chunk_map(&self) -> &HashMap<ChunkId, Chunk>
pub fn get_start(&self, idx: usize) -> Option<(&Chunk, StartIdx, Rotation)>
sourcepub fn just_chunks(&self) -> impl Iterator<Item = &Chunk>
pub fn just_chunks(&self) -> impl Iterator<Item = &Chunk>
sourceimpl Graph
impl Graph
sourcepub fn new_unoptimised(
query: &Query,
config: &Config
) -> Result<Self, BuildError>
pub fn new_unoptimised(
query: &Query,
config: &Config
) -> Result<Self, BuildError>
Generate a graph of all chunks which are reachable within a given length constraint.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnwindSafe for Graph
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more