// Copyright (c) 2023, Sam Hadow // //path.js // // This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along with this program. If not, see . function path_to_follow(matrix,origin,target) { // calculate edges to follow to reach target from origin (origin and target are nodes id) // matrix should be next_b or next_e // return a list with the id of these edges, and estimated travel time as first element. let current_node = origin; let path = [] while (current_node != target) { edge = matrix[current_node][target][1] current_node = matrix[current_node][target][0] path.push([current_node, edge]); } return path }