Skip to content

Instantly share code, notes, and snippets.

@import-benjamin
Created November 25, 2017 14:26
Show Gist options
  • Save import-benjamin/eb8a64ce2f82663ce69a3f6541f1aa3b to your computer and use it in GitHub Desktop.
Save import-benjamin/eb8a64ce2f82663ce69a3f6541f1aa3b to your computer and use it in GitHub Desktop.
graph theory : convert adjency list to matrix in scilab
// desc : retourne une liste d'adjacence sous forme de matrice
// input : liste d'adjacence (S, T)
// output : matrice (MS)
function MS=listes2mat (S, T)
nbSommets = length(T)-1 // le nombre de sommets
MS = zeros(nbSommets, nbSommets) // on initialise une matrice d'adjacence vide
for k=1:nbSommets
MS(k, liste_succ(S,T,k)) = 1
end
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment