Skip to content

Instantly share code, notes, and snippets.

@import-benjamin
Created November 25, 2017 14:48
Show Gist options
  • Save import-benjamin/9a2ef297a87c53ef83b7a698c402b8ae to your computer and use it in GitHub Desktop.
Save import-benjamin/9a2ef297a87c53ef83b7a698c402b8ae to your computer and use it in GitHub Desktop.
graph theory : find all successors of a node
function LD = descendants (Pred, x)
count = length(Pred)
LD = []
for k=1:count
if (find(chemin_arbre(Pred, k)==x)~=[]) then
LD = [LD, k]
end
end
endfunction
// parcours en largeur
function LD = descendants_bis(Pred, x)
new = fils(Pred, x)
old = []
while (new ~= [])
new = [new, fils(Pred, new(1))]
old = [old, new(1)]
new(1) = []
end
LD = old
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment