graphnest
v1.0.0
Published
A directed and undirected multi-graph library
Readme
graphnest
A lightweight JavaScript library for creating, modifying, and analyzing directed and undirected graphs — with a clean core API and built-in graph algorithms.
🚀 Features
- Directed & undirected graph support
- Node and edge metadata
- Clean, predictable API
- Built-in graph algorithms
- Works in Node.js and browser
- Lightweight and extensible
📦 Installation
npm
npm install graphnestBower
bower install graphnestBrowser Usage
<script src="http://PATH/TO/graphnest.min.js"></script>
<script>
var g = new graphnest.Graph();
// build your graph here
</script>🧱 Build From Source
Requires npm.
make distBuild output:
dist/
graphnest.js
graphnest.min.js⚡ Quick Start Example
var Graph = require("graphnest").Graph;
// Create a fresh directed graph instance
var g = new Graph();
// Register node "a" with no associated value
g.setNode("a");
// Verify node presence
g.hasNode("a");
// => true
// Register node "b" with a string value
g.setNode("b", "b's value");
// Retrieve stored value for node "b"
g.node("b");
// => "b's value"
// Register node "c" with an object payload
g.setNode("c", { k: 123 });
// Return all node ids currently in the graph
g.nodes();
// => `[ 'a', 'b', 'c' ]`
// Create a directed edge from a → b without metadata
g.setEdge("a", "b");
// Create a directed edge from c → d with metadata.
// Node "d" is auto-created if missing.
g.setEdge("c", "d", { k: 456 });
// Return every edge in the graph
g.edges();
// => `[ { v: 'a', w: 'b' },
// { v: 'c', w: 'd' } ]`.
// Get edges that originate from node "a"
g.outEdges("a");
// => `[ { v: 'a', w: 'b' } ]`
// Get all edges connected to node "d"
g.nodeEdges("d");
// => `[ { v: 'c', w: 'd' } ]`🧪 Development
Install dependencies:
npm installBuild distributables:
make distRun tests (if configured):
make test🐞 Issues & Bug Reports
Report bugs or request features here: https://github.com/Nest-Graph/graphnest/issues
Please include:
- library version
- runtime (Node/browser)
- minimal reproduction
- expected vs actual behavior
🤝 Contributing
Pull requests are welcome.
Suggested workflow:
- Fork the repository
- Create a feature branch
- Add or update tests
- Run build and tests
- Submit a pull request
📄 License
MIT License — see the LICENSE file for details.
