diff --git a/lib/comparisonView.js b/lib/comparisonView.js index f6489c4..794b65f 100644 --- a/lib/comparisonView.js +++ b/lib/comparisonView.js @@ -11,7 +11,7 @@ import { pushToMongo } from "./pushToMongo.js" import { maxMergeSortSteps, expectedNumMergeSortSteps } from "./utils.js" /* DEFINTIONS */ -const DEFAULT_COMPARE = 2 // 1, unless you're testing smth. +const DEFAULT_COMPARE = () => 0.5 // 1/Math.random() - 1// 1, unless you're testing smth. /* Helpers */ let increasingList = (n) => Array.from(Array(n).keys()) @@ -204,7 +204,7 @@ export default function ComparisonView({ listOfElementsForView }) { let newQuantitativeComparisons = [...quantitativeComparisons, newQuantitativeComparison] setQuantitativeComparisons(newQuantitativeComparisons) - setSliderValue(DEFAULT_COMPARE) + setSliderValue(DEFAULT_COMPARE()) setReasoning('') changeNumSteps(numSteps + 1) if (successStatus) { @@ -216,7 +216,7 @@ export default function ComparisonView({ listOfElementsForView }) { // Make sure to do this after the setIsListOrdered(true) setOrderedList(result) - }, 5000); + }, 500); } } diff --git a/lib/findPaths.js b/lib/findPaths.js index 05c32aa..8467ff8 100644 --- a/lib/findPaths.js +++ b/lib/findPaths.js @@ -155,6 +155,38 @@ function abridgeArrayAndDisplay(array) { return result } +export async function buildRows(isListOrdered, orderedList, listOfElements, links){ + // Not used yet. + let rows = [] + if (isListOrdered && ! (orderedList.length < listOfElements.length) && rows.length == 0) { + let nodes = [] + let positionDictionary=({}) + orderedList.forEach((id, pos) => { + nodes.push({ ...listOfElements[id], position: pos }) + positionDictionary[id] = pos + }) + // let nodes = orderedList.map((id, pos) => ({ ...listOfElements[id], position: pos })) + /* Pre-process links to talk in terms of distances */ + links = links.map(link => ({...link, + sourceElementPosition: positionDictionary[link.source], + targetElementPosition: positionDictionary[link.target] + })) + + let distances = await findDistancesForAllElements({ nodes, links }) + rows = nodes.map((element, i) => ({ + id: numToAlphabeticalString(element.position), + position: element.position, + name: element.name, + distances: distances[i] + })) + console.log("rows@CreateTableWithDistances") + console.log(rows) + }else{ + rows = [] + } + return rows +} + export function CreateTableWithDistances({ isListOrdered, orderedList, listOfElements, links }) { const [rows, setRows] = useState([])