Skip to main content

Graph

Struct Graph 

Source
pub struct Graph {
    pub nodes: BTreeMap<NodeKey, Node>,
    pub edges: Vec<Edge>,
    /* private fields */
}
Expand description

Graph holds every node and every edge, with the edges indexed by their endpoints.

Fields§

§nodes: BTreeMap<NodeKey, Node>

The nodes, by key.

§edges: Vec<Edge>

The edges, sorted, without duplicates.

Implementations§

Source§

impl Graph

Source

pub fn add_edges(&mut self, raw: Vec<RawEdge>)

add_edges adds the declared edges raw, with their nodes and inverses, to a graph that was built with no declared edge. raw holds the edges near the start nodes of the graph, read from the store (CACHE-1_AC-38).

Source§

impl Graph

Source

pub fn new(nodes: BTreeMap<NodeKey, Node>, edges: Vec<Edge>) -> Graph

new builds a graph from nodes and edges, and sorts the edges and removes duplicates.

Source

pub fn set_archived(&mut self, paths: impl IntoIterator<Item = RepoPath>)

set_archived marks the documents at paths as archived (CLI-7_AC-67). The call replaces the archived documents from any earlier call.

Source

pub fn is_archived(&self, key: &NodeKey) -> bool

is_archived returns whether the node at key is an archived document.

Source

pub fn add_key( &mut self, path: &RepoPath, slug: &str, key: &str, line: usize, citing: &[RepoPath], )

add_key adds a key node with a defined-in edge to its document and a cites edge from each document in citing, and gives each edge its inverse (CLI-7_AC-74, CLI-7_AC-75).

Source

pub fn with_hydrator(self, hydrator: Hydrator, built: HashSet<NodeKey>) -> Graph

with_hydrator gives the graph a hydrator. The document nodes in built already carry their fields. The hydrator reads the file of every other document node when the node is first visited (CACHE-1_AC-22).

Source

pub fn hydrate(&mut self, key: &NodeKey)

hydrate reads the fields of the document node at key, and does nothing when it has read them before or the graph has no hydrator.

Source

pub fn node(&self, key: &NodeKey) -> Option<&Node>

node returns the node at key.

Source

pub fn kind(&self, key: &NodeKey) -> Option<NodeKind>

kind returns the kind of the node at key.

Source

pub fn edges_from(&self, key: &NodeKey) -> impl Iterator<Item = &Edge>

edges_from returns the edges from key, in graph order.

Source

pub fn edge_indices_from(&self, key: &NodeKey) -> &[usize]

edge_indices_from returns the indices of the edges from key, in graph order.

Source

pub fn inverse_indices(&self, edge: &Edge) -> impl Iterator<Item = usize>

inverse_indices returns the indices of the inverses of edge, declared or synthesised, in graph order. An inverse is an edge with the endpoints swapped, the same kind, region, and line, and a rel that is the inverse of edge’s rel. inverse_indices checks the match in both directions: the inverse of edge’s rel is the other edge’s rel, or the inverse of the other edge’s rel is edge’s rel. A custom rel is one that the SOKF format does not define, and its inverse is relates-to. So a declared relates-to edge is the inverse of every edge with a custom rel that runs in the opposite direction between the same endpoints. An edge can have several inverses.

Source

pub fn parent(key: &NodeKey) -> Option<NodeKey>

parent returns the directory that contains a path node, or None for the repository root and for a node without a path.

Source

pub fn ensure(&mut self, path: RepoPath, kind: NodeKind)

ensure gives the node at path the kind kind. The code that resolves each START of sokf graph calls it when the START is a directory or a repository file (CLI-7_AC-35, CLI-7_AC-37). If the node exists, it takes the new kind and keeps its fields. If the node doesn’t exist, ensure adds it with no fields.

Trait Implementations§

Source§

impl Clone for Graph

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Graph

Source§

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

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

impl Default for Graph

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl !RefUnwindSafe for Graph

§

impl !Send for Graph

§

impl !Sync for Graph

§

impl !UnwindSafe for Graph

§

impl Forget for Graph

§

impl Freeze for Graph

§

impl Move for Graph

§

impl Unpin for Graph

§

impl UnsafeUnpin for Graph

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'a, T> FromIn<'a, T> for T

Source§

fn from_in(t: T, _: &'a Allocator) -> T

Converts to this type from the input type within the given allocator.
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<'a, T, U> IntoIn<'a, U> for T
where U: FromIn<'a, T>,

Source§

fn into_in(self, allocator: &'a Allocator) -> U

Converts this type into the (usually inferred) input type within the given allocator.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.