dijkstra-backend/helpers/test_dijkstra.js

18 lines
517 B
JavaScript
Raw Normal View History

2020-02-08 18:59:51 +00:00
const searchPath = require('../helpers/dijkstra_algo');
const cities = require('../data/test_data/cities');
const roads = require('../data/test_data/roads');
let { path, distance} = searchPath(cities, roads, 1, 9);
const formatedPath = [];
// I didn't use map or filter because it doesn't preserve the order
for (let path_city of path) {
for (let city of cities) {
if (city.id == path_city) {
formatedPath.push({ id: city.id, name: city.name });
}
}
}
console.log(formatedPath)