Skip to content

Commit

Permalink
Move measurement tools to visualization project
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-venher committed Nov 19, 2023
1 parent b1d056d commit 3654c52
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 37 deletions.
13 changes: 0 additions & 13 deletions dijkstra-prim-measurement/package-lock.json

This file was deleted.

13 changes: 0 additions & 13 deletions dijkstra-prim-measurement/package.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -10,7 +10,7 @@ const generateAdjacencyList = (
nodesCount,
probability,
minWeight,
maxWeight
maxWeight,
) => {
const adjacencyList = new Array(nodesCount);

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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);

Expand Down Expand Up @@ -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({
Expand All @@ -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`,
);
}

Expand Down

0 comments on commit 3654c52

Please sign in to comment.