matrice d'incidence sommets-arcs ou sommets-sommets d'un graphe
a = graph_2_mat(g,mat)
graphe (liste)
chaîne optionnelle, 'node-arc'
ou
'node-node'
matrice d'incidence (creuse)
graph_2_mat
calcule la matrice d'incidence
sommets-arcs ou sommets-sommets d'un graphe g
.
Si l'argument optionnel mat
est omis ou est égal
à la chaîne de caractères 'node-arc'
, la matrice
sommets-arcs est calculée. Si mat
est la chaîne de
caractères 'node-node'
, la matrice sommets-sommets est
calculée.
Si n
est le nombre de sommets du graphe et
m
est le nombre d'arêtes du graphe, la matrice
sommets-arcs est une matrice creuse de taille
(n,m)
.
Elle est définie comme suit; si le graphe est orienté :
a(i,j) = +1
si le sommet i
est
l'origine de l'arc j
a(i,j) = -1
si le sommet i
est
la destination de l'arc j
Si le graphe est non-orienté :
a(i,j) = 1
si le sommet i
est
l'origine ou la destination de l'arc j
Si n
est le nombre de sommets du graphe, la
matrice sommets-sommets est une matrice creuse de taille
(n,n)
.
Elle est définie comme suit :
a(i,j) = 1
si il y a un arc du sommet
i
au sommet j
ta = [10,3,6,2,3,7,6,9,5,10,8,2,5,8,4,9,1,8,9,4,7] he = [3,6,10,6,2,6,9,7,3,5,2,5,8,4,9,8,4,1,2,7,10] g=make_graph('foo',1,10,ta,he); g.nodes.graphics.x = [398,333,212,312,132,208,46,445,301,69]; g.nodes.graphics.y = [54,217,179,12,245,133,95,283,92,170]; g.nodes.graphics.display='number'; show_graph(g); a=graph_2_mat(g,'node-node'); a=[['' string(1:10)];[string(1:10)' string(full(a))]] a=graph_2_mat(g); string(full(a))' | ![]() | ![]() |