feat(graph): vault-wide statistics when sourcePath omitted (closes #132)#213
Open
aaronsb wants to merge 1 commit into
Open
feat(graph): vault-wide statistics when sourcePath omitted (closes #132)#213aaronsb wants to merge 1 commit into
aaronsb wants to merge 1 commit into
Conversation
Before: graph.statistics threw 'Source path is required' when called
without sourcePath, blocking the baseline use case (vault health
snapshots, dashboards). Users had to pick an arbitrary seed and reason
about its neighborhood — not representative.
After: when sourcePath is omitted, return a new vaultStatistics shape:
totalNotes — count of .md files in the vault
totalLinks — sum of resolved link occurrences (Obsidian
semantics: A→B referenced 3× counts as 3)
orphanCount — singletons (no links in either direction)
averageDegree — 2 * totalLinks / totalNotes
largestComponentSize — biggest connected subgraph (undirected)
isolatedClusters — total connected-component count,
inclusive of singletons (so non-trivial =
isolatedClusters - orphanCount)
Per-node statistics behaviour is unchanged when sourcePath is provided.
Implementation: GraphTraversal.getVaultStatistics does one O(V+E)
pass over the resolvedLinks adjacency, plus BFS for components.
Treats the graph as undirected for component analysis (a link from A
to B means A and B are in the same component) while keeping link
counts directed (matches how metadataCache exposes them).
Tests: tests/graph-statistics-vault-wide.test.ts covers the
vault-wide path (the topology described above), per-node fallback,
empty vault, repeated occurrences, non-md filtering, and the
directed-edges-undirected-components invariant.
|
✅ Build succeeded! Artifacts are available in the Actions tab. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #132. `graph.statistics` previously threw `Source path is required` when called without `sourcePath`, blocking the baseline use case (vault-health snapshots, dashboards). Users had to pick an arbitrary seed and reason about its neighborhood, which isn't representative of the vault.
When `sourcePath` is omitted, the operation now returns a new `vaultStatistics` shape (per the issue's proposal):
Per-node statistics behavior is unchanged when `sourcePath` is provided.
Implementation
Tests
`tests/graph-statistics-vault-wide.test.ts` (7 cases):
Test plan