From 3654c52560451373f490f300dffea294a4d6a022 Mon Sep 17 00:00:00 2001 From: Andrii Venher Date: Sun, 19 Nov 2023 20:22:53 +0100 Subject: [PATCH] Move measurement tools to visualization project --- dijkstra-prim-measurement/package-lock.json | 13 ------------- dijkstra-prim-measurement/package.json | 13 ------------- .../src}/measurement/dataset.js | 6 +++--- .../src}/measurement/measure.js | 16 ++++++++-------- .../src}/measurement/prepare.js | 0 5 files changed, 11 insertions(+), 37 deletions(-) delete mode 100644 dijkstra-prim-measurement/package-lock.json delete mode 100644 dijkstra-prim-measurement/package.json rename {dijkstra-prim-measurement => dijkstra-prim-visualization/src}/measurement/dataset.js (93%) rename {dijkstra-prim-measurement => dijkstra-prim-visualization/src}/measurement/measure.js (86%) rename {dijkstra-prim-measurement => dijkstra-prim-visualization/src}/measurement/prepare.js (100%) diff --git a/dijkstra-prim-measurement/package-lock.json b/dijkstra-prim-measurement/package-lock.json deleted file mode 100644 index ef72f32..0000000 --- a/dijkstra-prim-measurement/package-lock.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "benchmark", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "benchmark", - "version": "1.0.0", - "license": "ISC" - } - } -} diff --git a/dijkstra-prim-measurement/package.json b/dijkstra-prim-measurement/package.json deleted file mode 100644 index 76ecacc..0000000 --- a/dijkstra-prim-measurement/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "benchmark", - "version": "1.0.0", - "type": "module", - "description": "", - "main": "test.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC" -} diff --git a/dijkstra-prim-measurement/measurement/dataset.js b/dijkstra-prim-visualization/src/measurement/dataset.js similarity index 93% rename from dijkstra-prim-measurement/measurement/dataset.js rename to dijkstra-prim-visualization/src/measurement/dataset.js index 717c1ab..8a55155 100644 --- a/dijkstra-prim-measurement/measurement/dataset.js +++ b/dijkstra-prim-visualization/src/measurement/dataset.js @@ -1,6 +1,6 @@ import fs from "fs"; import path from "path"; -import { createAdjacencyListEntry } from "../../dijkstra-prim-visualization/src/algorithms/graph.js"; +import { createAdjacencyListEntry } from "../algorithms/graph.js"; const directory = "datasets"; @@ -10,7 +10,7 @@ const generateAdjacencyList = ( nodesCount, probability, minWeight, - maxWeight + maxWeight, ) => { const adjacencyList = new Array(nodesCount); @@ -75,7 +75,7 @@ const readAdjacencyList = (nodesCount) => { const [node, weight] = chunk.split(","); return createAdjacencyListEntry( Number.parseInt(node), - Number.parseInt(weight) + Number.parseInt(weight), ); }); adjacencyList[i - 1] = row; diff --git a/dijkstra-prim-measurement/measurement/measure.js b/dijkstra-prim-visualization/src/measurement/measure.js similarity index 86% rename from dijkstra-prim-measurement/measurement/measure.js rename to dijkstra-prim-visualization/src/measurement/measure.js index e8ee5dc..6d6bf78 100644 --- a/dijkstra-prim-measurement/measurement/measure.js +++ b/dijkstra-prim-visualization/src/measurement/measure.js @@ -1,9 +1,9 @@ import fs from "fs"; import path from "path"; import { generateAdjacencyList } from "./dataset.js"; -import { prim } from "../../dijkstra-prim-visualization/src/algorithms/prim.js"; -import createMinHeap from "../../dijkstra-prim-visualization/src/algorithms/minHeap.js"; -import createLinkedList from "../../dijkstra-prim-visualization/src/algorithms/linkedList.js"; +import { prim } from "../algorithms/prim.js"; +import createMinHeap from "../algorithms/minHeap.js"; +import createLinkedList from "../algorithms/linkedList.js"; const args = process.argv.slice(2); @@ -80,14 +80,14 @@ const measure = () => { nodesCount, config.edgeProbability, config.minEdgeWeight, - config.maxEdgeWeght + config.maxEdgeWeght, ); const deltaMinHeap = measureAverageTime(() => - prim(adjacencyList, createMinHeap) + prim(adjacencyList, createMinHeap), ); const deltaLinkedList = measureAverageTime(() => - prim(adjacencyList, createLinkedList) + prim(adjacencyList, createLinkedList), ); resultsMinHeap.push({ @@ -100,10 +100,10 @@ const measure = () => { }); console.log( - `Result (min heap): nodesCount = ${nodesCount}, delta = ${deltaMinHeap} ms` + `Result (min heap): nodesCount = ${nodesCount}, delta = ${deltaMinHeap} ms`, ); console.log( - `Result (linked list): nodesCount = ${nodesCount}, delta = ${deltaLinkedList} ms` + `Result (linked list): nodesCount = ${nodesCount}, delta = ${deltaLinkedList} ms`, ); } diff --git a/dijkstra-prim-measurement/measurement/prepare.js b/dijkstra-prim-visualization/src/measurement/prepare.js similarity index 100% rename from dijkstra-prim-measurement/measurement/prepare.js rename to dijkstra-prim-visualization/src/measurement/prepare.js