dijkstras-algorithm-ts
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -30,10 +30,6 @@ "use strict"; | ||
continue; | ||
edgeScoreFromCurrentToTargetNode = | ||
nonDirectedGraphMap[prevNode][targetNode]; | ||
const sumScoreFromCurrentNodeToTargetNode = resultsTable[prevNode].shortestDistanceFromNodeX + | ||
edgeScoreFromCurrentToTargetNode; | ||
if (sumScoreFromCurrentNodeToTargetNode < | ||
resultsTable[targetNode].shortestDistanceFromNodeX) { | ||
resultsTable[targetNode].shortestDistanceFromNodeX = | ||
sumScoreFromCurrentNodeToTargetNode; | ||
edgeScoreFromCurrentToTargetNode = nonDirectedGraphMap[prevNode][targetNode]; | ||
const sumScoreFromCurrentNodeToTargetNode = resultsTable[prevNode].shortestDistanceFromNodeX + edgeScoreFromCurrentToTargetNode; | ||
if (sumScoreFromCurrentNodeToTargetNode < resultsTable[targetNode].shortestDistanceFromNodeX) { | ||
resultsTable[targetNode].shortestDistanceFromNodeX = sumScoreFromCurrentNodeToTargetNode; | ||
resultsTable[targetNode].previousVertex = prevNode; | ||
@@ -64,5 +60,3 @@ } | ||
} | ||
return getShortestPathArrRecursive(destinationNode).concat([ | ||
destinationNode, | ||
]); | ||
return getShortestPathArrRecursive(destinationNode).concat([destinationNode]); | ||
} | ||
@@ -82,7 +76,5 @@ exports.getShortestPath = getShortestPath; | ||
// @ts-ignore | ||
return nodesPathArr | ||
.shift() | ||
.concat(getShortedPathArrowedFormattedStringRecursive(nodesPathArr)); | ||
return nodesPathArr.shift().concat(getShortedPathArrowedFormattedStringRecursive(nodesPathArr)); | ||
} | ||
exports.getShortedPathArrowedFormattedString = getShortedPathArrowedFormattedString; | ||
//# sourceMappingURL=dijkstrasAlgorithm.js.map |
@@ -58,9 +58,3 @@ "use strict"; | ||
test("test shortest path to c from a", () => { | ||
expect((0, dijkstrasAlgorithm_1.getShortestPath)(djistrasResultsLookUpTableFromA, "c")).toEqual([ | ||
"a", | ||
"b", | ||
"d", | ||
"f", | ||
"c", | ||
]); | ||
expect((0, dijkstrasAlgorithm_1.getShortestPath)(djistrasResultsLookUpTableFromA, "c")).toEqual(["a", "b", "d", "f", "c"]); | ||
}); | ||
@@ -67,0 +61,0 @@ test("test shortest path to c from a in directional arrow string format", () => { |
{ | ||
"name": "dijkstras-algorithm-ts", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"author": "christopher.pkm@gmail.com", | ||
@@ -50,3 +50,3 @@ "description": "typescript implementation of the greedy first search djikstra's shortest path algorithm, compatible with javascript projects too of course", | ||
"preversion": "npm run lint", | ||
"version": "npm run format && git add .", | ||
"version": "npm run format", | ||
"postversion": "git push && git push --tags" | ||
@@ -53,0 +53,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
21039
181