Graph displayer is now displaying nodes. Edges remain still undisplayed yet.
1 #include"lp_solver_skeleton.h"
3 #include<lemon/list_graph.h>
7 void lpTest(LpSolverBase & lp)
9 typedef LpSolverBase LP;
11 std::vector<LP::Col> x;
12 for(int i=0;i<10;i++) x.push_back(lp.addCol());
14 std::vector<LP::Col> y(10);
17 std::map<int,LP::Col> z;
19 z.insert(std::make_pair(12,INVALID));
20 z.insert(std::make_pair(2,INVALID));
21 z.insert(std::make_pair(7,INVALID));
22 z.insert(std::make_pair(5,INVALID));
28 LP::Col p1,p2,p3,p4,p5;
58 e=((p1+p2)+(p1-p2)+(p1+12)+(12+p1)+(p1-12)+(12-p1)+
59 (f+12)+(12+f)+(p1+f)+(f+p1)+(f+g)+
60 (f-12)+(12-f)+(p1-f)+(f-p1)+(f-g)+
118 lp.addRow(LP::INF,e,23);
119 lp.addRow(LP::INF,3.0*(x[1]+x[2]/2)-x[3],23);
120 lp.addRow(LP::INF,3.0*(x[1]+x[2]*2-5*x[3]+12-x[4]/3)+2*x[4]-4,23);
122 lp.addRow(x[1]+x[3]<=x[5]-3);
123 lp.addRow(-7<=x[1]+x[3]-12<=3);
124 lp.addRow(x[1]<=x[5]);
129 template<class G,class C>
130 double maxFlow(const G &g,const C &cap,typename G::Node s,typename G::Node t)
135 typedef typename G::Node Node;
136 typedef typename G::NodeIt NodeIt;
137 typedef typename G::Edge Edge;
138 typedef typename G::EdgeIt EdgeIt;
139 typedef typename G::OutEdgeIt OutEdgeIt;
140 typedef typename G::InEdgeIt InEdgeIt;
142 typename G::EdgeMap<LpGlpk::Col> x(g);
145 for(EdgeIt e(g);e!=INVALID;++e) {
146 lp.setColUpperBound(x[e],cap[e]);
147 lp.setColLowerBound(x[e],0);
150 for(NodeIt n(g);n!=INVALID;++n) if(n!=s&&n!=t) {
152 for(InEdgeIt e(g,n);e!=INVALID;++e) ex+=x[e];
153 for(OutEdgeIt e(g,n);e!=INVALID;++e) ex-=x[e];
158 for(InEdgeIt e(g,t);e!=INVALID;++e) ex+=x[e];
159 for(OutEdgeIt e(g,t);e!=INVALID;++e) ex-=x[e];
170 LpSolverSkeleton lp_skel;
177 ListGraph::Node s=g.addNode();
178 ListGraph::Node t=g.addNode();
180 ListGraph::EdgeMap<double> cap(g);