How to implement all or nothing assignment in a graph / network ?
Afficher commentaires plus anciens
Hi,
I have a transport network of n nodes represented by a ( nxn ) matrix A . This matrix contains zeros for non existing links between nodes and positive numbers for existing links. These numbers reflect the weight/cost of the link. I have applied graphshortestpath to A , in a loop, in order to find the shortest paths, with corresponding node sequencies and predecessors, from each node to every other node.
I also have a transport Origin-Destination ( OD ) demand matrix which indicates how many people want o travel between two nodes i and j .
What I want to do now is to find the traffic flows on each edge, according to the shortest path between each OD pair, performing all-or-nothing assignment. This means that the total demand between two nodes i and j will be transferred only through the edges which belong to the shortest path between i and j .
As example I use the following A and OD matrices:
A=[0 3 5 0 0;
0 0 2 6 0;
0 1 0 4 6;
0 0 0 0 4;
3 0 0 7 0];
OD=[0 2 7 3 1;
2 0 2 6 8;
1 4 0 4 6;
4 10 9 0 4;
5 6 3 6 0];
and the following loop to produce the matrix with the Shortest Paths, node sequencies and predecessors
for jj=1:size(A,1)
[SP,path,pred] = graphshortestpath(sparse(A),jj);
SPmat(jj,:)=SP;
pathMat(jj,:)=path;
predMat(jj,:)=pred;
end
Can anyone suggest what is the easiest way to do implement the above with these inputs?
Thanks,
Iro
2 commentaires
Muhammad Tabish Bilal
le 19 Avr 2021
Well coded, simplified yet briliantly explained assignment code.
Réponses (0)
Catégories
En savoir plus sur Directed Graphs dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!