pub struct LinkGraph { /* private fields */ }Expand description
The citation graph extracted from a vault’s [[wikilinks]].
Maps note name → outgoing/incoming link sets, handles duplicate filenames
across folders via path-based resolution, and retains a record-by-name map
so LinkPredicate::Where can recurse the predicate into linked records.
Implementations§
Source§impl LinkGraph
impl LinkGraph
Sourcepub fn build(records: &[Record]) -> Self
pub fn build(records: &[Record]) -> Self
Build the link index from a set of records. All records must have raw_content loaded.
Sourcepub fn build_with_root(records: &[Record], vault_root: Option<&Path>) -> Self
pub fn build_with_root(records: &[Record], vault_root: Option<&Path>) -> Self
Build with a vault root for path resolution.
Sourcepub fn record_by_name(&self, name: &str) -> Option<&Record>
pub fn record_by_name(&self, name: &str) -> Option<&Record>
Look up a record by its virtual name (filename without .md).
Sourcepub fn is_ambiguous(&self, name: &str) -> bool
pub fn is_ambiguous(&self, name: &str) -> bool
Check if a filename has duplicates across folders.
Sourcepub fn paths_for_name(&self, name: &str) -> Vec<&str>
pub fn paths_for_name(&self, name: &str) -> Vec<&str>
Get all paths for a given filename.
Sourcepub fn outgoing_links(&self, name: &str) -> Vec<&str>
pub fn outgoing_links(&self, name: &str) -> Vec<&str>
Get outgoing links for a note.
Sourcepub fn incoming_links(&self, name: &str) -> Vec<&str>
pub fn incoming_links(&self, name: &str) -> Vec<&str>
Get incoming links (backlinks) for a note.
Sourcepub fn outgoing_count(&self, name: &str) -> usize
pub fn outgoing_count(&self, name: &str) -> usize
Count of outgoing links.
Sourcepub fn incoming_count(&self, name: &str) -> usize
pub fn incoming_count(&self, name: &str) -> usize
Count of incoming links (backlinks).
Sourcepub fn traverse(
&self,
start: &str,
max_depth: usize,
direction: Direction,
) -> Vec<(String, usize)>
pub fn traverse( &self, start: &str, max_depth: usize, direction: Direction, ) -> Vec<(String, usize)>
BFS traversal from a starting note. Returns (name, depth) pairs for all reachable notes within max_depth, with the starting node included at depth 0.
Sourcepub fn has_link_to(&self, from: &str, to: &str) -> bool
pub fn has_link_to(&self, from: &str, to: &str) -> bool
Check if note from has an outgoing link to note to.
Sourcepub fn has_link_from(&self, to: &str, from: &str) -> bool
pub fn has_link_from(&self, to: &str, from: &str) -> bool
Check if note to has an incoming link from note from.
Sourcepub fn unresolved(&self) -> Vec<UnresolvedLink>
pub fn unresolved(&self) -> Vec<UnresolvedLink>
All wikilinks pointing to non-existent records, returned as
(source, target) pairs. Targets are normalised via the same
folder-stripping rule used during graph construction.