Skip to main content

HdtGraph

Struct HdtGraph 

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

Exact connectivity using deterministic HDT levels and AVL tours.

Preserves the crate::Graph contract, including growing arbitrary u64 vertices. This is an experimental implementation, not a production latency guarantee. Compact BFS remains the default engine.

Stable interface, experimental engine. This type, its methods and its trait implementations are stable for 1.x: they are removed or changed incompatibly only after a deprecation and in a major release. The experimental qualification covers performance, maturity and usage recommendation only: the cost bounds below describe the current implementation and are not a compatibility promise (compatibility policy).

Queries cost O(log V) algorithmically on the base forest, with expected O(1) hash map ID lookup, and allocate no scratch. Across a history with at most N registered vertices, edge updates have O(log² N) amortized cost; one cut may still inspect many edges. Logical storage is O(E + V log V): each level holds one spanning-forest copy of its tree edges and records only for vertices currently in that forest or holding exact-level incidences. Records that become isolated are released for reuse and emptied incidence sets free their nodes, so storage follows the live level structure rather than the history of promotions; arena and vector capacities, and released record slots, still retain their peaks (vector capacity is at most twice the peak length). Vertex insertion costs O(1) amortized for base forest, including ID indexing. Upper levels store only vertices touched by promotions; creating these records is charged to promotions. Vector reallocations can still cause linear spikes. Neither graph state nor query answers are protected by internal locks.

Implementations§

Source§

impl HdtGraph

Source

pub fn new() -> Self

Creates an empty graph in O(1) time.

Source

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

Registers an isolated vertex, returning false if already present.

Registers only in the base forest. Growing the universe relaxes upper level size bounds; implicit isolated vertices need no upper records.

Inserts an edge at level zero, creating absent endpoints.

Returns false for a duplicate, including reversed endpoints.

§Errors

Rejects self-loops before creating any vertex.

Source

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

Removes an edge, retaining all vertices; absent edges return false.

Every repair completes before returning. A single expensive cut is still possible: the update bound is amortized over edge lifetimes and promotions.

§Errors

Rejects self-loops without changing state.

Source

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

Answers exact connectivity in O(log V) algorithmic tree root time on level 0, with expected O(1) hash map ID lookup, without allocation or mutation.

A known vertex connects to itself. Unknown source is reported first.

§Errors

Returns GraphError::UnknownNode for an unregistered endpoint.

Source

pub fn node_count(&self) -> usize

Returns the number of registered vertices in O(1).

Source

pub fn edge_count(&self) -> usize

Returns the number of graph edges in O(1).

Source

pub fn stats(&self) -> HdtStats

Returns the diagnostic counters accumulated since creation or the last Self::reset_stats, in O(1) without changing any state.

HdtStats lists which properties of the values are guaranteed.

Source

pub fn reset_stats(&mut self)

Sets every diagnostic counter to zero without altering graph state.

Source

pub fn storage_stats(&self) -> HdtStorageStats

Collects structural storage accounting without changing graph state.

The values are computed at the call and describe the graph at that moment; the returned snapshot does not follow later mutations. Calling it changes neither the graph nor Self::stats. Takes O(V log V + E) time in the worst case and allocates the returned per-level snapshot. Call outside measured operations. Vector capacities exclude allocator overhead; mapping payload excludes hash table overhead and spare slots. This is deliberately not a total heap or RSS estimate.

crate::HdtStorageStats and crate::HdtLevelStorage list which properties of the values are guaranteed and which are implementation-dependent.

Trait Implementations§

Source§

impl Debug for HdtGraph

Source§

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

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

impl Default for HdtGraph

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Forget for HdtGraph

§

impl Freeze for HdtGraph
where *const u8 is !null: Freeze, PhantomData<(u64, usize)>: Freeze, PhantomData<((usize, usize), Edge)>: Freeze, PhantomData<Level>: Freeze,

§

impl Move for HdtGraph

§

impl RefUnwindSafe for HdtGraph

§

impl Send for HdtGraph
where RawTable<(u64, usize)>: Send, RawTable<((usize, usize), Edge)>: Send, RawVecInner: Send, NonZero<usize>: Send, NodeRef<Owned, usize, SetValZST, LeafOrInternal>: Send, BoxRaw<(usize, SetValZST)>: Send, RawTable<(usize, usize)>: Send,

§

impl Sync for HdtGraph
where RawTable<(u64, usize)>: Sync, RawTable<((usize, usize), Edge)>: Sync, RawVecInner: Sync, NonZero<usize>: Sync, NodeRef<Owned, usize, SetValZST, LeafOrInternal>: Sync, BoxRaw<(usize, SetValZST)>: Sync, RawTable<(usize, usize)>: Sync,

§

impl Unpin for HdtGraph
where *const u8 is !null: Unpin, (usize, usize): Unpin, NonZero<usize>: Unpin, *const LeafNode<usize, SetValZST> is !null: Unpin, Box<(usize, SetValZST)>: Unpin,

§

impl UnsafeUnpin for HdtGraph

§

impl UnwindSafe for HdtGraph

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.