Skip to main content

ReferenceGraph

Struct ReferenceGraph 

Source
pub struct ReferenceGraph { /* private fields */ }
Expand description

An undirected simple graph with exact connectivity queries.

Every stored edge appears in both endpoints’ adjacency sets. Sets exclude self-loops and duplicate edges; every endpoint has a vertex entry. Deleting an edge preserves its vertices. Storage is O(V + E), where V and E are the current vertex and undirected edge counts.

Internal test oracle; no stability promise. It exists for differential tests and benchmarks and may change or disappear in any release; see docs/stability.md. Use Graph or ConnectivityGraph instead.

Implementations§

Source§

impl ReferenceGraph

Source

pub fn new() -> Self

Creates an empty graph in O(1) time.

Source

pub fn add_node(&mut self, node: NodeId) -> bool

Adds an isolated vertex, returning true only if it was absent.

An existing vertex and its edges are unchanged. Worst-case time: O(log V).

Inserts an undirected edge, creating absent endpoints.

Returns true only when the edge is new. Reversed endpoints identify the same edge. Worst-case time: O(log V).

§Errors

Returns GraphError::SelfLoop for equal endpoints, without changing the graph.

Source

pub fn cut( &mut self, source: NodeId, target: NodeId, ) -> Result<bool, GraphError>

Removes an undirected edge while preserving both vertices.

Returns false if the edge or either endpoint is absent. Worst-case time: O(log V).

§Errors

Returns GraphError::SelfLoop for equal endpoints, without changing the graph.

Source

pub fn connected( &self, source: NodeId, target: NodeId, ) -> Result<bool, GraphError>

Reports whether a path exists between two existing vertices.

An existing vertex connects to itself by the empty path. Worst-case time is O((V + E) log V); scratch memory is O(V). These are worst-case bounds, not amortized bounds. Traversal stops early when the target is found.

§Errors

Returns GraphError::UnknownNode for an absent endpoint, checking source before target.

Source

pub fn node_count(&self) -> usize

Returns the number of vertices, including isolated ones, in O(1) time.

Source

pub fn edge_count(&self) -> usize

Returns the number of undirected edges in O(1) time.

Trait Implementations§

Source§

impl Debug for ReferenceGraph

Source§

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

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

impl Default for ReferenceGraph

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Forget for ReferenceGraph

§

impl Freeze for ReferenceGraph
where *const LeafNode<u64, BTreeSet<u64>> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(u64, BTreeSet<u64>)>>: Freeze,

§

impl Move for ReferenceGraph

§

impl RefUnwindSafe for ReferenceGraph

§

impl Send for ReferenceGraph
where NodeRef<Owned, u64, BTreeSet<u64>, LeafOrInternal>: Send, BoxRaw<(u64, BTreeSet<u64>)>: Send,

§

impl Sync for ReferenceGraph
where NodeRef<Owned, u64, BTreeSet<u64>, LeafOrInternal>: Sync, BoxRaw<(u64, BTreeSet<u64>)>: Sync,

§

impl Unpin for ReferenceGraph
where *const LeafNode<u64, BTreeSet<u64>> is !null: Unpin, Box<(u64, BTreeSet<u64>)>: Unpin,

§

impl UnsafeUnpin for ReferenceGraph
where *const LeafNode<u64, BTreeSet<u64>> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(u64, BTreeSet<u64>)>>: UnsafeUnpin,

§

impl UnwindSafe for ReferenceGraph

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.