{"library":"simple-graphdb","title":"Lightweight In-Memory Graph Database","description":"Simple-graphdb is an open-source, lightweight, in-memory graph database designed for managing graph data structures directly within a JavaScript/TypeScript application. Currently at version 3.1.0, it offers a stable API for creating, manipulating, and traversing nodes and edges with properties. Unlike persistent graph databases such as Neo4j or Ontotext's GraphDB, simple-graphdb does not offer data persistence or advanced enterprise features like clustering or complex query languages. Its primary differentiators are its simplicity, zero-dependency footprint, and suitability for use cases where graph data needs to be modeled and queried programmatically within a single application process, such as social network simulations, routing algorithms, or in-memory knowledge graphs for smaller datasets. The library typically follows a moderate, stable release cadence, focusing on core graph operations and performance within its in-memory scope.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install simple-graphdb"],"cli":null},"imports":["import { Graph } from 'simple-graphdb';","import { Node } from 'simple-graphdb';","import { Edge } from 'simple-graphdb';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { Graph } from 'simple-graphdb';\n\n// Create a new graph instance\nconst graph = new Graph();\n\n// Add nodes with types and properties\nconst userNode = graph.addNode('User', { name: 'Alice', email: 'alice@example.com' });\nconst productNode = graph.addNode('Product', { name: 'Laptop', price: 1200 });\nconst orderNode = graph.addNode('Order', { orderId: 'ORD001', date: new Date() });\n\n// Add directed edges to represent relationships\ngraph.addEdge(userNode.id, orderNode.id, 'PLACED');\ngraph.addEdge(orderNode.id, productNode.id, 'CONTAINS', { quantity: 1 });\n\n// Query the graph\nconst aliceOrders = graph.getChildren(userNode.id, { edgeType: 'PLACED' });\nconsole.log('Alice\\'s orders:', aliceOrders.map(node => node.properties));\n\nconst orderProducts = graph.getChildren(orderNode.id, { edgeType: 'CONTAINS' });\nconsole.log('Products in Order ORD001:', orderProducts.map(node => node.properties));\n\n// Find a path between Alice and the Laptop product\nconst path = graph.traverse(userNode.id, productNode.id, { method: 'bfs' });\nif (path) {\n  console.log('Path from Alice to Laptop:', path);\n} else {\n  console.log('No path found from Alice to Laptop.');\n}","lang":"typescript","description":"This quickstart demonstrates how to initialize a graph, add nodes and edges with properties, and perform basic traversal and querying operations to find related data.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}