tweak: Small convenience fixes
This commit is contained in:
parent
22bb8610e1
commit
f82043d24a
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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([])
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user