moved helper functions to default settings

This commit is contained in:
Andriy Kashcha 2017-09-17 21:48:54 -07:00
parent d89a962a1e
commit 91ebc37fcd
2 changed files with 27 additions and 5 deletions

View File

@ -11,7 +11,13 @@ module.exports = {
NO_PATH: NO_PATH,
// heap settings
setHeapIndex: setHeapIndex
setHeapIndex: setHeapIndex,
// nba:
setH1: setH1,
setH2: setH2,
compareF1Score: compareF1Score,
compareF2Score: compareF2Score,
}
function blindHeuristic(/* a, b */) {
@ -32,4 +38,20 @@ function compareFScore(a, b) {
function setHeapIndex(nodeSearchState, heapIndex) {
nodeSearchState.heapIndex = heapIndex;
}
function compareF1Score(a, b) {
return a.f1 - b.f1;
}
function compareF2Score(a, b) {
return a.f2 - b.f2;
}
function setH1(node, heapIndex) {
node.h1 = heapIndex;
}
function setH2(node, heapIndex) {
node.h2 = heapIndex;
}

View File

@ -60,12 +60,12 @@ function nba(graph, options) {
// the nodes that we still need to evaluate
var open1Set = new NodeHeap({
compare: function(a, b) { return a.f1 - b.f1; },
setNodeId: function(node, heapIndex) { node.h1 = heapIndex }
compare: defaultSettings.compareF1Score,
setNodeId: defaultSettings.setH1
});
var open2Set = new NodeHeap({
compare: function(a, b) { return a.f2 - b.f2; },
setNodeId: function(node, heapIndex) { node.h2 = heapIndex }
compare: defaultSettings.compareF2Score,
setNodeId: defaultSettings.setH2
});
var minNode;