Skip to content

Commit

Permalink
refac/ Return paths by key, not index
Browse files Browse the repository at this point in the history
  • Loading branch information
brunolnetto committed Jan 22, 2022
1 parent adcc6ae commit 90a4840
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions data-structures/graph/Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,14 +642,16 @@ export default class Graph {
let ith_was_visited = is_visited[neighbor_i];

if(!ith_was_visited) {
let neighbor_i_index = this.getVertexByIndex(neighbor_i);

// store current node in path[]
local_path_list.push(neighbor_i);
local_path_list.push(neighbor_i_index);

this.#recurAcyclicPaths(neighbor_i, to_index, is_visited,
local_path_list, paths);

// remove current node in path[]
let idx = local_path_list.indexOf(neighbor_i);
let idx = local_path_list.indexOf(neighbor_i_index);
local_path_list.splice(idx, 1);

}
Expand Down

0 comments on commit 90a4840

Please sign in to comment.