Crate turbovault_graph

Crate turbovault_graph 

Source
Expand description

Link graph implementation for Obsidian vault relationships using petgraph.

Provides:

  • Directed graph of vault files and links
  • Link resolution (wikilinks, aliases, folder paths)
  • Backlink queries
  • Related notes discovery (BFS)
  • Orphan detection
  • Cycle detection
  • Graph statistics
  • Vault health analysis
  • Broken link detection

§Quick Start

use turbovault_graph::LinkGraph;

// Create a new link graph
let graph = LinkGraph::new();

// The graph is built by adding VaultFile objects
// and their links will be indexed automatically
println!("Nodes: {}", graph.node_count());
println!("Edges: {}", graph.edge_count());

§Core Concepts

§Nodes and Edges

  • Nodes: Represent vault files (notes)
  • Edges: Represent links between files
  • Directed: Links flow from source to target

§Graph Operations

  • Backlinks: Find all notes linking to a given note
  • Forward Links: Find all notes linked from a given note
  • Related Notes: Discover related notes through BFS traversal
  • Orphans: Find isolated notes with no links in or out

§Vault Health Metrics

The health analyzer provides:

  • Health Score: Overall vault connectivity (0-100)
  • Connectivity Rate: Percentage of connected notes
  • Link Density: Ratio of existing links to possible links
  • Broken Links: Links to non-existent targets
  • Orphaned Notes: Isolated notes with no relationships

§Advanced Usage

use turbovault_graph::{LinkGraph, HealthAnalyzer};

let graph = LinkGraph::new();

// Create health analyzer for comprehensive analysis
let analyzer = HealthAnalyzer::new(&graph);

// Analyze vault health (includes broken link detection)
if let Ok(report) = analyzer.analyze() {
    for broken in &report.broken_links {
        println!("Broken: {} -> {}",
            broken.source_file.display(),
            broken.target
        );
    }
}

§Graph Statistics

use turbovault_graph::LinkGraph;

let graph = LinkGraph::new();
println!("Nodes: {}", graph.node_count());
println!("Edges: {}", graph.edge_count());

§Modules

  • graph - Main LinkGraph implementation
  • health - Vault health analysis

§Performance Characteristics

Built on petgraph for optimal performance:

  • Graph construction: O(n + m) where n = nodes, m = edges
  • Backlink queries: O(degree) with caching
  • Orphan detection: O(n)
  • Cycle detection: O(n + m)
  • Health analysis: O(n + m)

Re-exports§

pub use graph::GraphStats;
pub use graph::LinkGraph;
pub use health::HealthAnalyzer;
pub use health::HealthReport;

Modules§

graph
Link graph using petgraph for vault relationship analysis
health
Vault health analysis and broken link detection.
prelude

Structs§

Block
A block in vault content (Obsidian block reference with ^id)
Callout
A callout block in vault content
CompositeValidator
Composite validator that runs multiple validators
ContentValidator
Validates file content structure
Counter
A lock-free counter metric (monotonically increasing)
FileMetadata
File metadata
Frontmatter
YAML frontmatter
FrontmatterValidator
Validates frontmatter structure and required fields
Heading
A heading in vault content
Histogram
A histogram for tracking value distributions
LineIndex
Pre-computed line starts for O(log n) line/column lookup.
Link
A link in vault content
LinkValidator
Validates link syntax and format
ListItem
A list item with optional checkbox and nested content.
MetricsContext
Global metrics context registry (rarely used)
MultiVaultManager
Multi-vault manager coordinating multiple vaults
ServerConfig
Global server configuration
SourcePosition
Position in source text (line, column, byte offset)
Tag
A tag in vault content
TaskItem
A task item in vault content
ValidationIssue
A validation issue found in content
ValidationReport
Result of validating content
VaultConfig
Configuration for a single vault
VaultFile
A complete vault file with parsed content
VaultInfo
Information about a registered vault

Enums§

CalloutType
Type of callout block
ConfigProfile
Profile selector for pre-configured deployments
ContentBlock
A parsed content block in a markdown document.
Error
The core error type for all Obsidian operations.
InlineElement
An inline element within a block.
LinkType
Type of link in Obsidian content
Severity
Severity level for validation issues
TableAlignment
Table column alignment.

Traits§

Validator
Trait for content validators

Type Aliases§

Result
Convenient Result type alias