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

859 B
Raw Blame History

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

npm install

Running Tests

npm test

Usage

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