pipe_network — solves the pipe network problem
[x,pi] = pipe_network(g)
row vector of the value of the flow on the arcs
row vector of the value of the potential on the nodes
pipe_network
returns the value of the flows and of the potentials
for the pipe network problem: flow problem with two Kirchhoff laws.
The graph must be directed. The problem must be feasible (the sum of
the node demands must be equal to 0). The resistances on the arcs must
be strictly positive and are given as the values of the
weight field of the graph edges_data_structure.
The problem is solved by using sparse matrices LU factorization.
ta=[1 1 2 2 3 3 4 4 5 5 5 5 6 6 6 7 7 15 15 15 15 15 15 15 8 9 10 11 12 13 14]; he=[10 13 9 14 8 11 9 11 8 10 12 13 8 9 12 8 11 1 2 3 4 5 6 7 16 16 16 16 16 16 16]; g=make_graph('foo',1,16,ta,he); g.nodes.graphics.x=[42 615 231 505 145 312 403 233 506 34 400 312 142 614 260 257]; g.nodes.graphics.y=[143 145 154 154 147 152 157 270 273 279 269 273 273 274 50 376]; g.nodes.graphics.diam(15:16)=30; g=add_node_data(g,'demand',[0 0 0 0 0 0 0 0 0 0 0 0 0 0 -100 100]); w = [1 3 2 6 4 7 8 1 2 2 2 4 7 8 9 2 3 5 7 3 2 5 8 2 5 8 6 4 3 5 6]; g=add_edge_data(g,'weight',w); g.nodes.graphics.display='demand'; g.edges.graphics.display='weight'; show_graph(g); [x,pi] = pipe_network(g) g=add_edge_data(g,'flow',round(100*x)/100); g.edges.graphics.display='flow'; show_graph(g);