# Graph with Reflection and Refinement This repository contains a lightweight JavaScript implementation of a graph data structure that supports: - **Self‑referential 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 self‑referential) 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` – Re‑exports 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 assignment’s requirement of no external IDE usage.*