pub struct SubgraphMerge<K>where
K: Key,{ /* private fields */ }Expand description
Datastructure for merging subgraphs while maintaining topological sort order.
Maintains a global topo-sorted Vec of all operators. Each subgraph (merged group) occupies a contiguous range in this Vec. Merging two groups combines their ranges and re-sorts the affected window so groups remain contiguous and correctly ordered.
Implementations§
Source§impl<K> SubgraphMerge<K>where
K: Key,
impl<K> SubgraphMerge<K>where
K: Key,
Sourcepub fn new<PredsIter>(
keys: impl IntoIterator<Item = K>,
preds_fn: impl FnMut(K) -> PredsIter,
enemies_iter: impl IntoIterator<Item = (K, K)>,
) -> Result<Self, Vec<K>>where
PredsIter: IntoIterator<Item = K>,
pub fn new<PredsIter>(
keys: impl IntoIterator<Item = K>,
preds_fn: impl FnMut(K) -> PredsIter,
enemies_iter: impl IntoIterator<Item = (K, K)>,
) -> Result<Self, Vec<K>>where
PredsIter: IntoIterator<Item = K>,
Creates a new SubgraphMerge from nodes and their predecessor edges.
enemies specifies pairs of nodes that must never be placed in the same subgraph.
These are checked in O(1) during Self::try_merge and maintained as representatives
change.
Returns Err with a cycle if the input graph is not a DAG.
Sourcepub fn same_set(&mut self, u: K, v: K) -> bool
pub fn same_set(&mut self, u: K, v: K) -> bool
Returns true if u and v are in the same subgraph.
Auto Trait Implementations§
impl<K> Freeze for SubgraphMerge<K>
impl<K> RefUnwindSafe for SubgraphMerge<K>where
K: RefUnwindSafe,
impl<K> Send for SubgraphMerge<K>where
K: Send,
impl<K> Sync for SubgraphMerge<K>where
K: Sync,
impl<K> Unpin for SubgraphMerge<K>where
K: Unpin,
impl<K> UnsafeUnpin for SubgraphMerge<K>
impl<K> UnwindSafe for SubgraphMerge<K>where
K: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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