Creates a graph, optionally populated from parsed files.
Parsed markdown files to build the graph from; when empty, the graph starts with no nodes.
Replaces the recorded dependency set for a file with the one on the parsed file. The node's own dependency set is updated too when the file already has a node.
Parsed markdown file whose dependencies should be recorded.
Adds or replaces the node for a file, seeded with the file's own dependency list. Dependents are not recomputed; call DependencyGraph.build to refresh them.
Parsed markdown file to add, keyed by its filePath.
Rebuilds the graph from scratch: clears existing state, creates a node for every file, records each file's dependencies and then derives the reverse (dependents) relationships. Each file's dependents field is updated to match.
Parsed markdown files that make up the graph.
Removes every node and edge from the graph.
Finds dependency cycles using a depth-first search over every node.
One path per cycle found, listed in traversal order with the first file repeated at the end; empty when the graph is acyclic.
Lists the paths of every node in the graph.
The node paths in insertion order.
Lists the files a file directly depends on.
Path of the file to inspect.
The direct dependency paths, or an empty array when the path has no recorded dependencies.
Lists the files that directly depend on a file. Paths without a node of their own, such as linked images, are resolved by scanning the recorded dependencies of every file.
Path of the file to inspect.
The paths of the files that link to it.
Looks up the node for a file.
Path the file was added under.
The node, or undefined when the path has no node (for example a linked asset that was never parsed as markdown).
Collects every file reachable by following dependencies from a file, directly or indirectly. Cycles are tolerated and each path appears once.
Path of the file to start from.
The distinct dependency paths, excluding the starting file unless a cycle leads back to it.
Collects every file that depends on a file, directly or through a chain of other files. Cycles are tolerated and each path appears once.
Path of the file to start from.
The distinct paths of all files affected by a change to the starting file.
Removes a file from the graph along with every reference to it in other nodes' dependency and dependent sets. Does nothing when the path has no node.
Path of the file to remove.
Reports how many nodes the graph holds.
The number of nodes.
Serialises the dependency edges for JSON.stringify.
A map from each file path to the paths it depends on.
Orders the files so that each file appears after everything it depends on. In a graph with cycles, each cycle is broken at the point where the search first revisits a file.
File paths in dependency-first order.
Renames a file throughout the graph: its node and edges are moved to the new path, and every other node's dependency and dependent sets that mention the old path are rewritten. Paths without a node of their own, such as linked assets, still have references to them rewritten.
Path the file is currently known by.
Path to replace it with.
Builds and analyzes dependency relationships between markdown files.
The DependencyGraph tracks file relationships through links, references, and imports to enable intelligent file operations. It supports cycle detection, topological sorting, impact analysis, and dependency-aware ordering for operations like joining and splitting.
Example
Building a dependency graph
Example
Impact analysis