New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

weavatrix-graph

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

weavatrix-graph

Deterministic, evidence-carrying Rust graph core for Node.js and Bun

latest
Source
npmnpm
Version
0.6.5
Version published
Weekly downloads
10
-41.18%
Maintainers
1
Weekly downloads
 
Created
Source

weavatrix-graph

A deterministic, evidence-carrying directed graph with production algorithms — written in Rust, exposed to Node.js and Bun through Node-API.

Every edge carries provenance: which extractor produced it, what evidence backs it, how confident that evidence is, and optionally where in the source it came from. That is the difference between a graph you can query and a graph you can defend.

npm install weavatrix-graph
# or
bun add weavatrix-graph
const { Graph } = require('weavatrix-graph')

const graph = new Graph({
  nodes: [
    { id: 'api', label: 'API', kind: 'service' },
    { id: 'db', label: 'Database', kind: 'table' },
  ],
  edges: [{
    source: 'api',
    target: 'db',
    kind: 'reads',
    provenance: { extractor: 'architecture', evidence: 'parsed', confidence: 'exact' },
  }],
})

graph.shortestPath('api', 'db')          // ['api', 'db']
graph.hasCycle()                          // false
graph.pageRank({ damping: 0.85 })         // [{ id, score }, …]
graph.outgoing('api')[0].provenance        // why that edge exists

Input

GraphNode

FieldTypeNotes
idstringStable identity. Must be unique.
labelstringHuman-readable name.
kindstringFree-form node category.
languagestring?
spanSourceSpan?{ file, start: { line, column }, end: { line, column } }
attributesRecord<string, AttributeValue>?Nested JSON values are allowed.

GraphEdge

FieldTypeNotes
source, targetstringMust reference declared node ids.
kindstringRelation type, such as calls, reads, implements.
provenanceProvenanceRequired. { extractor, evidence, confidence, span?, detail? } where confidence is 'exact' | 'high' | 'medium' | 'low'.
attributesRecord<string, AttributeValue>?

Requiring provenance on construction is deliberate: an edge nobody can justify never enters the graph.

API

new Graph(input)

Validates the whole input and throws on a duplicate node id, a dangling edge endpoint, or a malformed provenance record.

MemberReturnsNotes
nodeCountnumber
edgeCountnumber
canonical()GraphInputDeterministic serialization. Two graphs with equal content produce byte-identical output, which is what makes a graph diffable and cacheable.
node(id)GraphNode | undefined
outgoing(id)GraphEdge[]Edges leaving id, with provenance intact.
incoming(id)GraphEdge[]Edges arriving at id.
bfs(start)string[]Materialized breadth-first visit order.
shortestPath(source, target)string[] | undefinedNode ids inclusive of both ends; undefined when unreachable.
stronglyConnectedComponents()string[][]Each component in deterministic order.
topologicalSort()string[] | undefinedundefined when the graph has a cycle.
hasCycle()boolean
pageRank(options?){ id, score }[]{ damping = 0.85, iterations = 20 }. Deterministic for a given graph and settings.
toDot()stringDeterministic Graphviz DOT.

Traversal methods throw InvalidArg for an unknown node id, rather than silently returning nothing.

Determinism

Component order, visit order, DOT output, and canonical serialization are all derived from content, never from insertion order or thread scheduling. The same input produces the same bytes on every platform and every run.

Errors

codeCause
InvalidArgMalformed input JSON, duplicate node id, edge endpoint that references no node, unknown node id passed to a traversal, invalid PageRank settings.

What ships

RuntimesNode.js 18+ (Node-API 8), Bun 1.4+
PlatformsWindows x64/arm64, macOS x64/arm64, glibc Linux x64/arm64
Install scriptnone
Network at installnone
Runtime dependenciesnone
Platform packagesnone — all six bindings are in this one tarball

The Node-API 8 ABI keeps the addon independent of any single Node major version.

Measured

benchmark/RESULTS.md is generated from the weavatrix-benchmarks harness, which forces both sides to materialize the identical BFS visit order before either is timed. The competitor is graphology, the standard JavaScript graph library.

Medians of three independent runs over 50,000 nodes and 149,991 edges:

ContractNode 24Bun 1.3
Materialized directed BFS node ids2.98x (2.91–3.14)2.98x (2.82–3.20)

graphology stores a plain topology; the Weavatrix graph also retains typed provenance on every edge, so it is carrying more and still traversing faster. On a ten-node graph both sides sit in timer noise, and this project makes no small-graph claim.

Graph owns its repository, package, release evidence, and MIT license, and can be used entirely on its own.

Repository: Weavatrix/weavatrix-graph · Rust crate: crates.io/crates/weavatrix-graph · License: MIT

Keywords

graph

FAQs

Package last updated on 24 Aug 2026

Related posts