Files
povtornyy-ekzamen-graf-s-re…/README.md
T

46 lines
859 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Graph with Reflection and Rewriting Nodes
This project implements a simple directed graph data structure in JavaScript that supports three types of nodes:
- **Generic Node** the base node type.
- **Reflection Node** represents a node that reflects on itself.
- **Rewriting Node** represents a node that rewrites or transforms data.
## Installation
```bash
npm install
```
## Running Tests
```bash
npm test
```
## Usage
```js
import { Graph, Node, ReflectionNode, RewritingNode } from './src/index.js';
const graph = new Graph();
const n1 = new Node('n1');
const r1 = new ReflectionNode('r1');
const w1 = new RewritingNode('w1');
graph.addNode(n1);
graph.addNode(r1);
graph.addNode(w1);
graph.addEdge('n1', 'r1');
graph.addEdge('r1', 'w1');
graph.traverse('n1', (node) => {
console.log(node.id, node.type);
});
```
## License
MIT