Created
November 25, 2017 14:48
-
-
Save import-benjamin/9a2ef297a87c53ef83b7a698c402b8ae to your computer and use it in GitHub Desktop.
graph theory : find all successors of a node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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