pub struct Graph { /* private fields */ }Expand description
Immutable document graph with pre-built adjacency indices. Indices are automatically rebuilt on deserialization.
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn new(nodes: IndexMap<String, Node>, edges: Vec<Edge>) -> Self
pub fn new(nodes: IndexMap<String, Node>, edges: Vec<Edge>) -> Self
Build a graph from nodes and edges. Constructs adjacency indices.
pub fn node(&self, id: &str) -> Option<&Node>
pub fn nodes(&self) -> &IndexMap<String, Node>
pub fn edges(&self) -> &[Edge]
Sourcepub fn incoming_indices(&self, id: &str) -> &[usize]
pub fn incoming_indices(&self, id: &str) -> &[usize]
Edge indices where target == id.
Sourcepub fn incoming_edges(&self, id: &str) -> Vec<&Edge>
pub fn incoming_edges(&self, id: &str) -> Vec<&Edge>
Edges pointing to id.
Sourcepub fn outgoing_edges(&self, id: &str) -> Vec<&Edge>
pub fn outgoing_edges(&self, id: &str) -> Vec<&Edge>
Edges originating from id.
pub fn node_count(&self) -> usize
pub fn edge_count(&self) -> usize
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Graph
Deserialize nodes + edges, then automatically rebuild indices.
impl<'de> Deserialize<'de> for Graph
Deserialize nodes + edges, then automatically rebuild indices.
Older graph.json files without a schema_version field are
treated as version 0, which the reader can still handle because
the on-disk shape through v1 was backward-compatible (pure field
additions). Any newer version surfaces a Deserialize error that
propagates up as PARSE_ERROR — the user is instructed to
nodex build --full to regenerate.
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graph
impl UnwindSafe for Graph
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