<< max_flow Flows min_lcost_flow1 >>

metanet >> metanet > Flows > min_lcost_cflow

min_lcost_cflow

minimum linear cost constrained flow

Calling Sequence

[c,phi,v,flag] = min_lcost_cflow(i,j,cv,g)

Parameters

i

integer, source node number

j

integer, sink node number

cv

scalar, value of constrained flow

g

a graph_data_structure.

c

value of cost

phi

row vector of the values of flow on the arcs

v

value of flow from source to sink

flag

feasible constrained flow flag (0 or 1)

Description

min_lcost_cflow computes the minimum cost flow in the network g, with the value of the flow from source node i to sink node j constrained to be equal to cv.

min_lcost_cflow returns the total cost of the flows on the arcs c, the row vector of the flows on the arcs phi and the value of the flow v on the virtual arc from sink to source. If v is less than cv, a message is issued, but the computation is done: in this case flag is equal to 0, otherwise it is equal to 1.

The bounds of the flow are given by the g.edges.data.min_cap and g.edges.data.max_cap fields of the graph.

The value of the the maximum capacity must be non negative and must be integer numbers. The value of the minimum capacity must be equal to 0.

If the value of min_cap or max_cap is not given it is assumed to be equal to 0 on each edge.

The costs on the edges are given by the element g.edges.data.cost of the fields of the graph. The costs must be non negative. If the value of cost is not given, it is assumed to be equal to 0 on each edge.

If the min_cap or max_cap or cost data fields are not present in the graph structure they can be added and set using the add_edge_data function.

This function uses the algorithm of Busacker and Goven.

Examples

ta=[1 1 2 2 2 3 4 4 5 6 6 6 7 7 7 8 9 10 12 12 13 13 13 14 15 14 9 11 10];
he=[2 6 3 4 5 1 3 5 1 7 10 11 5 8 9 5 8 11 10 11 9 11 15 13 14 4 6 9 1];
g=make_graph('foo',1,15,ta,he);
g.nodes.graphics.x=[155,153,85,155,237,244,244,334,338,346,442,440,439,333,438];
g.nodes.graphics.y=[45,145,221,222,221,82,139,225,142,69,140,72,232,318,319];
source=15;g.nodes.graphics.type(source)=2; //source node
sink=1;g.nodes.graphics.type(sink)=1; //sink node
show_graph(g);

g=add_edge_data(g,'max_cap',[11,8,9,19,20,8,9,16,6,11,6,12,12,3,6,14,16,2,14,5,9,18,13,11,5,18,3,7,18]);
g=add_edge_data(g,'cost',[9,6,11,7,11,2,8,5,7,10,2,9,10,7,7,9,2,7,2,8,4,6,11,8,1,7,4,4,7]);
flow_constraint=5;
[c,phi,v,flag]=min_lcost_cflow(source,sink,flow_constraint,g);

g.edges.graphics.foreground(find(phi<>0))=color('red');
g=add_edge_data(g,'flow',phi)
g.edges.graphics.display='flow';
show_graph(g);

See Also


<< max_flow Flows min_lcost_flow1 >>