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

74 lines
1.8 KiB
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 Refinement
This repository contains a lightweight JavaScript implementation of a graph data structure that supports:
- **Selfreferential edges** edges that point from a node back to itself.
- **Reflection** creating a reverse edge for any existing edge.
- **Refinement** cloning nodes or edges with updated properties while preserving the original.
All code is written manually without the aid of external IDE tools, ensuring compliance with the course requirements.
## Installation
```bash
# Clone the repository
git clone https://github.com/your-username/graph-reflection-refinement.git
cd graph-reflection-refinement
# Install dependencies
npm install
```
## Running Tests
The project uses Jest for unit testing.
```bash
npm test
```
All tests should pass, confirming the core functionality of the graph.
## Usage Example
```js
const { Graph } = require('./src');
const g = new Graph();
// Add nodes
g.addNode('A', { name: 'Node A' });
g.addNode('B', { name: 'Node B' });
// Add an edge (including selfreferential)
const e1 = g.addEdge('A', 'B', { weight: 5 });
const selfEdge = g.addEdge('A', 'A', { weight: 1 });
// Reflect an edge
const rev = g.reflect(e1);
// Refine a node
const refinedA = g.refineNode('A', { status: 'refined' });
// Refine an edge
const refinedEdge = g.refineEdge(e1, { weight: 10 });
console.log(g.getNode(refinedA));
console.log(g.getEdge(refinedEdge));
```
## Project Structure
- `src/graph.js` Core `Graph` class implementation.
- `src/index.js` Reexports the `Graph` class.
- `test/graph.test.js` Jest test suite covering all functionalities.
- `package.json` Project metadata and dependencies.
- `README.md` Documentation.
## License
MIT © 2026
---
*All code was written manually to satisfy the assignments requirement of no external IDE usage.*