mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-06-01 14:39:33 +00:00
Major new package implementing a distributed hypergraph database with: ## Core Components (crates/ruvector-graph/) - Cypher-compatible query parser with lexer, AST, optimizer - Query execution engine with SIMD optimization and parallel execution - ACID transaction support with MVCC isolation levels - Distributed consensus and federation layer - Vector-graph hybrid queries for AI/RAG workloads - Performance optimizations (100x faster than Neo4j target) ## Bindings - WASM bindings (crates/ruvector-graph-wasm/) - NAPI-RS Node.js bindings (crates/ruvector-graph-node/) - NPM packages for both targets ## CLI Integration - 8 new graph commands: create, query, shell, import, export, info, benchmark, serve ## CI/CD - Updated build-native.yml for graph packages - New graph-ci.yml for testing and benchmarks - New graph-release.yml for automated publishing ## Data Generation - OpenRouter/Kimi K2 integration (packages/graph-data-generator/) - Agentic-synth benchmark suite integration ## Tests & Benchmarks - 11 test files covering all components - Criterion benchmarks for performance validation - Neo4j compatibility test suite ## Architecture Highlights - CSR graph layout for cache-friendly access - SIMD-vectorized query operators - Roaring bitmaps for label indexes - Bloom filters for fast negative lookups - Adaptive radix tree for property indexes Note: This is a comprehensive implementation created by 15 parallel agents. Some integration fixes may be needed to resolve cross-module dependencies. Co-authored-by: Claude AI Swarm <swarm@claude.ai>
126 lines
3.8 KiB
JavaScript
126 lines
3.8 KiB
JavaScript
const { GraphDatabase, version, hello } = require('./index.js');
|
|
|
|
console.log('RuVector Graph Node Test');
|
|
console.log('========================\n');
|
|
|
|
// Test 1: Version and hello
|
|
console.log('1. Testing version and hello functions:');
|
|
console.log(' Version:', version());
|
|
console.log(' Hello:', hello());
|
|
console.log(' ✓ Basic functions work\n');
|
|
|
|
// Test 2: Create database
|
|
console.log('2. Creating graph database:');
|
|
const db = new GraphDatabase({
|
|
distanceMetric: 'Cosine',
|
|
dimensions: 3
|
|
});
|
|
console.log(' ✓ Database created\n');
|
|
|
|
// Test 3: Create nodes
|
|
console.log('3. Creating nodes:');
|
|
(async () => {
|
|
try {
|
|
const nodeId1 = await db.createNode({
|
|
id: 'alice',
|
|
embedding: new Float32Array([1.0, 0.0, 0.0]),
|
|
properties: { name: 'Alice', age: '30' }
|
|
});
|
|
console.log(' Created node:', nodeId1);
|
|
|
|
const nodeId2 = await db.createNode({
|
|
id: 'bob',
|
|
embedding: new Float32Array([0.0, 1.0, 0.0]),
|
|
properties: { name: 'Bob', age: '25' }
|
|
});
|
|
console.log(' Created node:', nodeId2);
|
|
console.log(' ✓ Nodes created\n');
|
|
|
|
// Test 4: Create edge
|
|
console.log('4. Creating edge:');
|
|
const edgeId = await db.createEdge({
|
|
from: 'alice',
|
|
to: 'bob',
|
|
description: 'knows',
|
|
embedding: new Float32Array([0.5, 0.5, 0.0]),
|
|
confidence: 0.95
|
|
});
|
|
console.log(' Created edge:', edgeId);
|
|
console.log(' ✓ Edge created\n');
|
|
|
|
// Test 5: Create hyperedge
|
|
console.log('5. Creating hyperedge:');
|
|
const nodeId3 = await db.createNode({
|
|
id: 'charlie',
|
|
embedding: new Float32Array([0.0, 0.0, 1.0])
|
|
});
|
|
|
|
const hyperedgeId = await db.createHyperedge({
|
|
nodes: ['alice', 'bob', 'charlie'],
|
|
description: 'collaborated_on_project',
|
|
embedding: new Float32Array([0.33, 0.33, 0.33]),
|
|
confidence: 0.85
|
|
});
|
|
console.log(' Created hyperedge:', hyperedgeId);
|
|
console.log(' ✓ Hyperedge created\n');
|
|
|
|
// Test 6: Query
|
|
console.log('6. Querying graph:');
|
|
const results = await db.query('MATCH (n) RETURN n');
|
|
console.log(' Query results:', JSON.stringify(results, null, 2));
|
|
console.log(' ✓ Query executed\n');
|
|
|
|
// Test 7: Search hyperedges
|
|
console.log('7. Searching hyperedges:');
|
|
const searchResults = await db.searchHyperedges({
|
|
embedding: new Float32Array([0.3, 0.3, 0.3]),
|
|
k: 5
|
|
});
|
|
console.log(' Search results:', searchResults);
|
|
console.log(' ✓ Search completed\n');
|
|
|
|
// Test 8: k-hop neighbors
|
|
console.log('8. Finding k-hop neighbors:');
|
|
const neighbors = await db.kHopNeighbors('alice', 2);
|
|
console.log(' Neighbors:', neighbors);
|
|
console.log(' ✓ Neighbors found\n');
|
|
|
|
// Test 9: Statistics
|
|
console.log('9. Getting statistics:');
|
|
const stats = await db.stats();
|
|
console.log(' Stats:', stats);
|
|
console.log(' ✓ Statistics retrieved\n');
|
|
|
|
// Test 10: Transactions
|
|
console.log('10. Testing transactions:');
|
|
const txId = await db.begin();
|
|
console.log(' Transaction started:', txId);
|
|
await db.commit(txId);
|
|
console.log(' Transaction committed');
|
|
console.log(' ✓ Transaction test passed\n');
|
|
|
|
// Test 11: Batch insert
|
|
console.log('11. Testing batch insert:');
|
|
const batchResult = await db.batchInsert({
|
|
nodes: [
|
|
{ id: 'n1', embedding: new Float32Array([1, 0, 0]) },
|
|
{ id: 'n2', embedding: new Float32Array([0, 1, 0]) }
|
|
],
|
|
edges: [
|
|
{
|
|
from: 'n1',
|
|
to: 'n2',
|
|
description: 'connects',
|
|
embedding: new Float32Array([0.5, 0.5, 0])
|
|
}
|
|
]
|
|
});
|
|
console.log(' Batch result:', batchResult);
|
|
console.log(' ✓ Batch insert completed\n');
|
|
|
|
console.log('✅ All tests passed!');
|
|
} catch (error) {
|
|
console.error('❌ Test failed:', error);
|
|
process.exit(1);
|
|
}
|
|
})();
|