[Lemon-user] Integrating LGL with R via Rcpp

Juan Ignacio Perotti juanpool at gmail.com
Mon Feb 14 14:32:45 CET 2011


Hi Alpár,

Thanks for your kind response and interest.  If I'll try to answer your
question maybe I can formulate more precisely my own. When you
write a R package there are 2 main subdirectories, one named R/
and other src/. Inside R/ you put all your .R files (the files with the R
code) and inside src/ you put all your .cpp and .h files. Eventually
you build the package with the R builder which will compile and link the
.cpp and .h files in src/, in libraries files .so that you can "load"
from the R code.

Now, that seems to be the way when you use your own .cpp and .h
files. In the case of using Lemon I think in two possibilities:

1) Installing it, so all the .h and (may be .so, I don't know if there are
some
of them) files will be some where in the systems accessible via the
 system PATHs. So one can use the tools provided by the library by means
of a simple line like:

#include<lemon/dijkstra.h>

in your/s .cpp file/s. And this is what I had done. I first try this options
because
I don't know what the installation of the Lemon library does. So maybe the
process of installation is necessary in order that the Lemon library works.

2) Now, I'm thinking in this other option (which I do not test yet). Just
copying
the /lemon/ directory inside the src/ directory and access the .h files
trough
a line like (for example):

#include "lemon/dijkstra.h"

that is, now the .h files (I don't know what happens if there are or must be
.so
files in the Lemon library) are not accessed via the system PATHs, but
directly inside the src/ directory. This option is in some way better for me
(and maybe for others) if it works. Why? Simply, in this way one can build
a self-sufficient R package that can be easily installed in other systems
that uses R via a simple R command from a R console like this (suppose
that the package is named LemonPkg):

> install.packages("LemonPkg")

and that is !!! You can use all the power of R (the main power of
R is that it integrates conveniently a lot of libraries, also it seems
a nice language to work with) and Lemon in a very easy way.
But only if this second option works. I will try this at some point.

Best Regards

P.S.: Sorry if my mail is so extent.

On Mon, Feb 14, 2011 at 7:45 AM, Alpár Jüttner <alpar at cs.elte.hu> wrote:

> Hi Juan,
>
> Thanks for sharing your experience. I am not familiar with R, but went
> trough your blogpost and I found it really exciting.
>
> At the end of your post (and at http://stackoverflow.com/) you have a
> question about using LEMON without installing it. Is it a general issue
> using Rcpp, or something LEMON specific?
>
> In general, LEMON headers must be included like
> #include<lemon/dijkstra.h>, indeed, but this shouldn't cause any problem
> for you - simply create a lemon subdirectory within your include dir and
> put the lemon headers there.
>
> Regards,
> Alpár
>
> P.S. It was nice to find other happy users following the links in your
> post.
>
>
>
> On Fri, 2011-02-11 at 19:51 -0300, Juan Ignacio Perotti wrote:
> > Hi, everybody.
> >
> >
> > I'm just new on this. Few months before I had started to learn R
> > (http://www.r-project.org/). R is nice, but it may be slow.
> > I'm a physicist and normally I do high performance computations.
> > Eventually I get to know that one can integrate C++ code
> > into R. As I normally work in complex networks, I was looking for C++
> > libraries developed for that purpose. In fact, igraph is
> > a package available to R users. So eventually I think to look at the C
> > implementation of it. But I found the C igraph library
> > a bit "dirty" to deal with. Eventually I also found the Boost Graph
> > Library, but I read about it that it has a step learning curve.
> > Then I found LGL (Lemon Graph Library). It looks pretty nice to work
> > with, and it seems "transparent" so one can understand
> > it easily. Also it seems that can deal with hard computations. So, I
> > decide to try the integration of R with LGL using a R
> > package called Rcpp (which is also awesome!!!). So after a while I had
> > success on it. More precisely, I just got working
> > a very small and simple program that integrates LGL via Rcpp into R.
> >
> >
> > I wrote the details of this in my blog. So I want to share it with the
> > LGL community.
> >
> >
> http://deliriosderayohauno.blogspot.com/2011/02/lemon-graph-library-lgl-instalation.html
> >
> http://deliriosderayohauno.blogspot.com/2011/02/r-learning-building-r-packages-that_468.html
> >
> >
> > Maybe, some others are walking on the same road. Let my know about
> > that.
> >
> >
> > Best Regards
> >
> > --
> > Lic. Juan I. Perotti
> >
> > Instituto de Física Enrique Gaviola (IFEG).
> > Facultad de Matemática Astronomía y Física (FaMAF).
> > Universidad Nacional de Córdoba (UNC).
> > Medina Allende y Haya de la Torre s/n
> > Ciudad Universitaria  - X5000HUA
> > Oficina 233
> > Te: +54-351-4334051 (int. 233)
> > Fax: +54-351-4334054
> > home page: http://www.famaf.unc.edu.ar/~perotti/
> >
> >
> > _______________________________________________
> > Lemon-user mailing list
> > Lemon-user at lemon.cs.elte.hu
> > http://lemon.cs.elte.hu/mailman/listinfo/lemon-user
>
>
>


-- 
Lic. Juan I. Perotti

Instituto de Física Enrique Gaviola (IFEG).
Facultad de Matemática Astronomía y Física (FaMAF).
Universidad Nacional de Córdoba (UNC).
Medina Allende y Haya de la Torre s/n
Ciudad Universitaria  - X5000HUA
Oficina 233
Te: +54-351-4334051 (int. 233)
Fax: +54-351-4334054
home page: http://www.famaf.unc.edu.ar/~perotti/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lemon.cs.elte.hu/pipermail/lemon-user/attachments/20110214/78f76c03/attachment.html>


More information about the Lemon-user mailing list