ruvector/packages/graph-data-generator/examples/basic-usage.ts
Claude bcc85f5faf
feat: Add Neo4j-compatible hypergraph database package (ruvector-graph)
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>
2025-11-25 23:11:54 +00:00

90 lines
2.9 KiB
TypeScript

/**
* Basic usage examples for @ruvector/graph-data-generator
*/
import { createGraphDataGenerator } from '../src/index.js';
import fs from 'fs';
async function main() {
// Initialize generator with OpenRouter API key
const generator = createGraphDataGenerator({
apiKey: process.env.OPENROUTER_API_KEY,
model: 'moonshot/kimi-k2-instruct'
});
console.log('=== Knowledge Graph Generation ===');
const knowledgeGraph = await generator.generateKnowledgeGraph({
domain: 'technology',
entities: 50,
relationships: 150,
includeEmbeddings: true,
embeddingDimension: 768
});
console.log(`Generated ${knowledgeGraph.data.nodes.length} nodes`);
console.log(`Generated ${knowledgeGraph.data.edges.length} edges`);
console.log(`Duration: ${knowledgeGraph.metadata.duration}ms`);
// Generate Cypher statements
const cypher = generator.generateCypher(knowledgeGraph.data, {
useConstraints: true,
useIndexes: true,
useMerge: false
});
// Save to file
fs.writeFileSync('knowledge-graph.cypher', cypher);
console.log('Saved Cypher to knowledge-graph.cypher');
console.log('\n=== Social Network Generation ===');
const socialNetwork = await generator.generateSocialNetwork({
users: 100,
avgConnections: 10,
networkType: 'small-world',
includeMetadata: true,
includeEmbeddings: false
});
console.log(`Generated ${socialNetwork.data.nodes.length} users`);
console.log(`Generated ${socialNetwork.data.edges.length} connections`);
const socialCypher = generator.generateCypher(socialNetwork.data);
fs.writeFileSync('social-network.cypher', socialCypher);
console.log('Saved Cypher to social-network.cypher');
console.log('\n=== Temporal Events Generation ===');
const temporalEvents = await generator.generateTemporalEvents({
startDate: '2024-01-01',
endDate: '2024-01-31',
eventTypes: ['login', 'purchase', 'logout', 'error'],
eventsPerDay: 20,
entities: 25,
includeEmbeddings: false
});
console.log(`Generated ${temporalEvents.data.nodes.length} nodes`);
console.log(`Generated ${temporalEvents.data.edges.length} edges`);
const temporalCypher = generator.generateCypher(temporalEvents.data);
fs.writeFileSync('temporal-events.cypher', temporalCypher);
console.log('Saved Cypher to temporal-events.cypher');
console.log('\n=== Entity Relationships Generation ===');
const erGraph = await generator.generateEntityRelationships({
domain: 'e-commerce',
entityCount: 75,
relationshipDensity: 0.2,
includeEmbeddings: false
});
console.log(`Generated ${erGraph.data.nodes.length} entities`);
console.log(`Generated ${erGraph.data.edges.length} relationships`);
const erCypher = generator.generateCypher(erGraph.data);
fs.writeFileSync('entity-relationships.cypher', erCypher);
console.log('Saved Cypher to entity-relationships.cypher');
console.log('\n✓ All examples completed successfully!');
}
main().catch(console.error);