Borrar filtros
Borrar filtros

flow capacity in link of a directed graph

1 visualización (últimos 30 días)
sastra university
sastra university el 30 de Jul. de 2022
Comentada: sastra university el 25 de Sept. de 2023
Dear All,
I have data for a graph of the traffic network.
Entr=[1 ; 1 ; 4 ; 4 ; 5 ; 5 ; 6 ; 6 ; 7 ; 7 ; 8 ; 9 ; 9 ; 10 ; 11 ; 11 ; 12 ; 12 ; 13];
Ext=[5 ; 12 ; 5 ; 9 ; 6 ; 9 ; 7 ; 10 ; 8 ; 11 ; 2 ; 10 ; 13 ; 11 ; 2 ; 3 ; 6 ; 8 ; 3];
i need to calculate the flow of each link(edge) from node 1 to 2 when i am sending 1000 vehicles from origin. Please suggest me matlab code for this. I tried maxflow command. but it is not worked out as i expected.
Thank you in advance.
Thanks & Regards,
Muthukannan

Respuestas (1)

Nipun
Nipun el 22 de Sept. de 2023
Hi Sastra,
To my understanding, you are trying to compute a flow from node 1 to 2 across each edge when 1000 flow is pushed from origin. Since the weights are not given, I assume that the edge capacities as 500. Additionally since nodes 1 and 2 are only in Entr and Ext respectively, I assume that node 1 as source and node 2 as sink.
I am refering to Max-Flow documentation to get maxflow in a digraph. Here is the code that I have used to calculate edge link flows.
Entr=[1 ; 1 ; 4 ; 4 ; 5 ; 5 ; 6 ; 6 ; 7 ; 7 ; 8 ; 9 ; 9 ; 10 ; 11 ; 11 ; 12 ; 12 ; 13];
Ext=[5 ; 12 ; 5 ; 9 ; 6 ; 9 ; 7 ; 10 ; 8 ; 11 ; 2 ; 10 ; 13 ; 11 ; 2 ; 3 ; 6 ; 8 ; 3];
% Add edges to the graph with weight 500 for each edge
G = digraph(Entr, Ext, 500*ones(size(Ext)));
% For visualization of the graph
H = plot(G,'EdgeLabel',G.Edges.Weight);
% Compute the max flow using 'augment path' algorithm between source and
% sink
[mf,GF] = maxflow(G,1,2,'augmentpath');
% Highlighting the max flow path
H.EdgeLabel = {};
highlight(H,GF,'EdgeColor','r','LineWidth',2);
st = GF.Edges.EndNodes;
labeledge(H,st(:,1),st(:,2),GF.Edges.Weight);
Hope this helps. In case different edge weights are required, let me know.
Regards,
Nipun

Categorías

Más información sobre Graph and Network Algorithms en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by