www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/MaximumFlowInGraphExample.m

    %% Maximum Flow in Graph
% Create and plot a weighted graph. The weighted edges represent flow
% capacities.

% Copyright 2015 The MathWorks, Inc.

s = [1 1 2 2 3 4 4 4 5 5];
t = [2 3 3 4 5 3 5 6 4 6];
weights = [0.77 0.44 0.67 0.75 0.89 0.90 2 0.76 1 1];
G = digraph(s,t,weights);
plot(G,'EdgeLabel',G.Edges.Weight,'Layout','layered');

%%
% Determine the maximum flow from node 1 to node 6.
mf = maxflow(G,1,6)