8 lines
317 B
Matlab
8 lines
317 B
Matlab
function path = computePath(tree, parentIndices, currentIdx)
|
|
% Backtrack from the goal index to the start index using the parent indices
|
|
path = tree(:, currentIdx);
|
|
while parentIndices(currentIdx) ~= 0
|
|
currentIdx = parentIndices(currentIdx);
|
|
path = [tree(:, currentIdx), path];
|
|
end
|
|
end |