[Lemon-user] A question using lemon library

Kovács Péter kpeter at inf.elte.hu
Mon Jan 10 23:37:55 CET 2011


Hi,

First of all, let me draw your attention to the LEMON tutorial:
http://lemon.cs.elte.hu/pub/tutorial/
The first few sections could answer some of your questions.

> I am a new user of Lemon library. Now I am doing MIP with cplex and I
> just want to use Lemon for my maxflow solver.(As far as I know, solve
> maxflow in a LP is much worse than using a flow algorithm)

Yes, indeed.

> So I construct my own graph structure(better fit the syntax of cplex),
> and every time I would like to solve a maxflow problem, I will construct
> a capacity vector, and the graph remains exactly the same.
>
> To do that, I initiate a lemon graph in the first place, and call a
> function that use the lemon graph instance and the capacity vector(an
> stl vector), say
>
> double maxflow(SmartDigraph g, vector<double> capacity)
> {
> }

You cannot use this syntax, because the graph structures are _not_ 
copy-constructable. You must use
   const SmartDigraph& g
instead of
   SmartDigraph g
parameter. The std::vector is copy-constructable, but it is more 
efficient to pass it by a (const) reference, as well.

Furthermore, note that you can only use LEMON map structures in 
conjunction with a graph. You cannot use a capacity vector. (For more 
information about maps, see the corresponding section of the Tutorial.)

Regards,
Peter

> The question is, I could not directly use the functions in g. There are
> always errors. Can anyone give me a short example using lemon just as a
> solver using its algorithms?
 >
> Thanks,
> --
> Sincerely:
> Song Yongjia(宋永佳)
>
> Department of Industrial and Systems Engineering
> College of Engineering, University of Wisconsin-Madison
> 3241 Mechanical Engineering Building
> 1513 University Avenue, Madison, WI 53706




More information about the Lemon-user mailing list