Skip to main content

ElementPredecessors

Trait ElementPredecessors 

Source
pub trait ElementPredecessors: TopologyBase {
    type Predecessors<'view>: Iterator<Item = Self::ElementId>
       where Self: 'view;

    // Required method
    fn element_predecessors(
        &self,
        element: Self::ElementId,
    ) -> Self::Predecessors<'_>;
}
Expand description

Capability for expanding an element to its directed predecessor elements.

This is the substrate-neutral form of “follow incoming connections to this element.” For binary graphs the predecessors are the sources of incoming edges; for hypergraphs they are the vertices that reach this vertex through outgoing hyperedges. Substrate-agnostic algorithms (reverse BFS, reverse reachability) bind on this trait so the same code drives any topology view that can answer the question.

Implementations define whether parallel connections produce repeated predecessor elements. Implementations that preserve multiplicity should document that behavior; consumers that need set semantics should deduplicate at their own level.

§Performance

Creating the iterator should be O(1) unless an implementation documents a weaker contract. Yielding k predecessors should be O(k) and should not allocate unless the implementation documents otherwise.

Required Associated Types§

Source

type Predecessors<'view>: Iterator<Item = Self::ElementId> where Self: 'view

Iterator over predecessor element IDs reaching one element.

§Performance

Advancing the iterator should be amortized O(1) unless an implementation documents otherwise.

Required Methods§

Source

fn element_predecessors( &self, element: Self::ElementId, ) -> Self::Predecessors<'_>

Returns elements that reach element through outgoing connections.

§Performance

Expected O(1) to create the iterator; yielding k predecessors is expected O(k).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§