flow capacity in link of a directed graph

조회 수: 3 (최근 30일)
sastra university
sastra university 2022년 7월 30일
댓글: sastra university 2023년 9월 25일
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

답변 (1개)

Nipun
Nipun 2023년 9월 22일
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

카테고리

Help CenterFile Exchange에서 Networks에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by