%*** input graph adjacency matrix G and nodal coordinates (for visualisation): % [G,XY] = getgraph; % creation d'un graph test %[G,XY] = getgraphTree(20); % creation de la matrice d'adjacence "arbre" %[G,XY] = getgraphBus(9); % creation de la matrice d'adjacence "bus" %[G,XY] = getgraphRing(9); % creation de la matrice d'adjacence "anneau" [G,XY] = getgraphDoublering(9); % creation de la matrice d'adjacence "double anneau" %[G,XY] = getgraphStar(9); % creation de la matrice d'adjacence "étoile" %[G,XY] = getgraphDoublestar(9); % creation de la matrice d'adjacence "double étoile" %[G,XY] = getgraphTrianglemesh(9); % creation de la matrice d'adjacence "triangle mesh" %[G,XY] = getgraphRhomboidmesh(9); % creation de la matrice d'adjacence "triangle mesh" %*** nnod: number of nodes, nseg: number of segments: nnod = size(G,1); nseg = nnz(G)/2; % G(5,9)=.3;G(9,5)=0.3; %% change le coût d'un lien %*** same volume of data (=1) is sent from all nodes to all nodes (equipotential): STraffic = 0*G; for nfrom = 1:nnod for nto = 1:nnod if (nfrom ~= nto) [Paths,S] = gettraffic(G,nfrom,nto); STraffic = STraffic + S; end; end; end; %--- STraffic(i,j) = t, (t) units of data passed through segment i-->j %*** visualize graph and traffic: figure; clf gplot(G,XY); [i,j,k] = find(triu(STraffic)); EXY = 0.3*XY(i,:) + 0.7*XY(j,:); tx1=text(EXY(:,1),EXY(:,2),num2str(k,'%3.1f')); [i,j,k] = find(triu(STraffic')); EXY = 0.3*XY(j,:) + 0.7*XY(i,:); tx2=text(EXY(:,1),EXY(:,2),num2str(k,'%3.1f')); hold on tx3 = text(XY(:,1),XY(:,2),num2str((1:nnod)')); set(tx1,'FontSize',18) set(tx2,'FontSize',18) set(tx3,'FontSize',18) set(tx3,'Color','r') axis equal axis off %**** calculate length [lengthNet] = getlength(G,XY,nnod); hold on, ti=title(strcat('length: ',num2str(lengthNet))); set(ti,'FontSize',16);